summaryrefslogtreecommitdiff
path: root/beans
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2011-05-18 14:04:41 -0700
committerElliott Hughes <enh@google.com>2011-05-18 14:04:41 -0700
commitb5ef8434979368b7f637c12bef92ced60afcfe26 (patch)
tree9aa4c20df296175184b57f3a2e994f1eef9a9e51 /beans
parentfc95c99cfa4921fef424f3f411d013b821589e69 (diff)
downloadapache-harmony-b5ef8434979368b7f637c12bef92ced60afcfe26.tar.gz
Get the java.beans tests working.
Mainly deletion of the cruft we don't implement. Change-Id: I014df15889a7dd8915f4876e39ef3eba39d2de3a
Diffstat (limited to 'beans')
-rw-r--r--beans/src/test/java-internal/java/beans/ArrayPersistenceDelegateTest.java202
-rw-r--r--beans/src/test/java-internal/java/beans/ClassPersistenceDelegateTest.java79
-rw-r--r--beans/src/test/java-internal/java/beans/NullPersistenceDelegateTest.java71
-rw-r--r--beans/src/test/java-internal/java/beans/ProxyPersistenceDelegateTest.java98
-rw-r--r--beans/src/test/java-internal/java/beans/StringPersistenceDelegateTest.java59
-rw-r--r--beans/src/test/java-internal/java/beans/beancontext/BeanContextServicesSupportTest.java310
-rw-r--r--beans/src/test/java-internal/java/beans/beancontext/BeanContextSupportTest.java565
-rw-r--r--beans/src/test/java/org/apache/harmony/beans/tests/java/beans/BeanDescriptorTest.java211
-rw-r--r--beans/src/test/java/org/apache/harmony/beans/tests/java/beans/BeansTest.java598
-rw-r--r--beans/src/test/java/org/apache/harmony/beans/tests/java/beans/CustomizedPersistenceDelegateTest.java289
-rw-r--r--beans/src/test/java/org/apache/harmony/beans/tests/java/beans/DefaultPersistenceDelegateTest.java1226
-rw-r--r--beans/src/test/java/org/apache/harmony/beans/tests/java/beans/EncoderTest.java493
-rw-r--r--beans/src/test/java/org/apache/harmony/beans/tests/java/beans/EventHandlerTest.java1278
-rw-r--r--beans/src/test/java/org/apache/harmony/beans/tests/java/beans/EventSetDescriptorTest.java1416
-rw-r--r--beans/src/test/java/org/apache/harmony/beans/tests/java/beans/ExpressionTest.java1377
-rw-r--r--beans/src/test/java/org/apache/harmony/beans/tests/java/beans/FeatureDescriptorTest.java296
-rw-r--r--beans/src/test/java/org/apache/harmony/beans/tests/java/beans/FozzzEditor.java152
-rw-r--r--beans/src/test/java/org/apache/harmony/beans/tests/java/beans/IndexedPropertyDescriptorTest.java1611
-rw-r--r--beans/src/test/java/org/apache/harmony/beans/tests/java/beans/IntrospectionExceptionTest.java66
-rw-r--r--beans/src/test/java/org/apache/harmony/beans/tests/java/beans/IntrospectorTest.java6521
-rw-r--r--beans/src/test/java/org/apache/harmony/beans/tests/java/beans/MethodDescriptorTest.java172
-rw-r--r--beans/src/test/java/org/apache/harmony/beans/tests/java/beans/ParameterDescriptorTest.java42
-rw-r--r--beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PersistenceDelegateTest.java1479
-rw-r--r--beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PropertyDescriptorTest.java1339
-rw-r--r--beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PropertyEditorManagerRegressionTest.java163
-rw-r--r--beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PropertyEditorManagerTest.java897
-rw-r--r--beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PropertyEditorSupportTest.java444
-rw-r--r--beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PropertyVetoExceptionTest.java119
-rw-r--r--beans/src/test/java/org/apache/harmony/beans/tests/java/beans/SimpleBeanInfoTest.java100
-rw-r--r--beans/src/test/java/org/apache/harmony/beans/tests/java/beans/StatementTest.java1341
-rw-r--r--beans/src/test/java/org/apache/harmony/beans/tests/java/beans/VetoableChangeListenerProxyTest.java109
-rw-r--r--beans/src/test/java/org/apache/harmony/beans/tests/java/beans/VetoableChangeSupportTest.java1924
-rw-r--r--beans/src/test/java/org/apache/harmony/beans/tests/java/beans/XMLDecoderTest.java688
-rw-r--r--beans/src/test/java/org/apache/harmony/beans/tests/java/beans/XMLEncoderTest.java1953
-rw-r--r--beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextChildSupportTest.java1005
-rw-r--r--beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextEventTest.java217
-rw-r--r--beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextMembershipEventTest.java286
-rw-r--r--beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServiceAvailableEventTest.java157
-rw-r--r--beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServiceRevokedEventTest.java548
-rw-r--r--beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServicesSupport2Test.java72
-rw-r--r--beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServicesSupportTest.java1534
-rw-r--r--beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextSupport2Test.java85
-rw-r--r--beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextSupportTest.java2270
-rw-r--r--beans/src/test/resources/binary/java/beans/mock/MockJavaBean2.binbin1084 -> 0 bytes
-rw-r--r--beans/src/test/resources/binary/java/beans/mock/TestClassEditor.binbin232 -> 0 bytes
-rw-r--r--beans/src/test/resources/gif/harmony-logo.gifbin5220 -> 0 bytes
-rw-r--r--beans/src/test/resources/gif/test.gifbin856 -> 0 bytes
-rw-r--r--beans/src/test/resources/org/apache/harmony/beans/tests/java/beans/testB.jpgbin816 -> 0 bytes
-rw-r--r--beans/src/test/resources/serialization/java/beans/mock/MockAppletBean2.serbin164 -> 0 bytes
-rw-r--r--beans/src/test/resources/serialization/java/beans/mock/MockJavaBean2.serbin165 -> 0 bytes
-rw-r--r--beans/src/test/resources/serialization/org/apache/harmony/beans/tests/java/beans/IntrospectionExceptionTest.golden.serbin1709 -> 0 bytes
-rw-r--r--beans/src/test/resources/serialization/org/apache/harmony/beans/tests/java/beans/PropertyVetoExceptionTest.golden.serbin1962 -> 0 bytes
-rw-r--r--beans/src/test/resources/serialization/org/apache/harmony/beans/tests/java/beans/VetoableChangeSupportTest.golden.serbin698 -> 0 bytes
-rw-r--r--beans/src/test/resources/serialization/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextChildSupportTest.golden.serbin1217 -> 0 bytes
-rw-r--r--beans/src/test/resources/serialization/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextEventTest.golden.serbin1141 -> 0 bytes
-rw-r--r--beans/src/test/resources/serialization/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextMembershipEventTest.golden.serbin1296 -> 0 bytes
-rw-r--r--beans/src/test/resources/serialization/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServiceAvailableEventTest.golden.serbin1278 -> 0 bytes
-rw-r--r--beans/src/test/resources/serialization/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServiceRevokedEventTest.golden.serbin1294 -> 0 bytes
-rw-r--r--beans/src/test/resources/serialization/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServicesSupportTest.golden.serbin1371 -> 0 bytes
-rw-r--r--beans/src/test/resources/serialization/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextSupportTest.golden.serbin1886 -> 0 bytes
-rw-r--r--beans/src/test/resources/xml/Array.xml8
-rw-r--r--beans/src/test/resources/xml/Array_Illegal.xml21
-rw-r--r--beans/src/test/resources/xml/Array_Null.xml23
-rw-r--r--beans/src/test/resources/xml/Array_Object.xml29
-rw-r--r--beans/src/test/resources/xml/Array_Primitive.xml57
-rw-r--r--beans/src/test/resources/xml/Array_Wrapper.xml23
-rw-r--r--beans/src/test/resources/xml/ChangedObject.xml25
-rw-r--r--beans/src/test/resources/xml/Choice.xml45
-rw-r--r--beans/src/test/resources/xml/ClassID.xml25
-rw-r--r--beans/src/test/resources/xml/DependencyBean.xml13
-rw-r--r--beans/src/test/resources/xml/IntArray.xml14
-rw-r--r--beans/src/test/resources/xml/Integer.xml7
-rw-r--r--beans/src/test/resources/xml/Mock2EnumObject.xml26
-rw-r--r--beans/src/test/resources/xml/MockBean4Codec_BornFriendChange.xml15
-rw-r--r--beans/src/test/resources/xml/MockBean4Codec_ManyChanges.xml112
-rw-r--r--beans/src/test/resources/xml/MockBean4Codec_ManyChanges_2.xml10
-rw-r--r--beans/src/test/resources/xml/MockBean4Codec_NoChange.xml4
-rw-r--r--beans/src/test/resources/xml/MockBean4Owner_SetOwner.xml9
-rw-r--r--beans/src/test/resources/xml/MockBean4Owner_SetOwnerWithWriteStatement.xml11
-rw-r--r--beans/src/test/resources/xml/MockBean4StaticField.xml4
-rw-r--r--beans/src/test/resources/xml/MockBean4StaticField_Original.xml10
-rw-r--r--beans/src/test/resources/xml/MockCheckedCollection.xml38
-rw-r--r--beans/src/test/resources/xml/MockCheckedList.xml38
-rw-r--r--beans/src/test/resources/xml/MockCheckedMap.xml41
-rw-r--r--beans/src/test/resources/xml/MockCheckedRandomAccessList.xml38
-rw-r--r--beans/src/test/resources/xml/MockCheckedSet.xml38
-rw-r--r--beans/src/test/resources/xml/MockCheckedSortedMap.xml41
-rw-r--r--beans/src/test/resources/xml/MockCheckedSortedSet.xml38
-rw-r--r--beans/src/test/resources/xml/MockEnumObject.xml27
-rw-r--r--beans/src/test/resources/xml/MockGetPropertyClass.xml35
-rw-r--r--beans/src/test/resources/xml/MockListImplements.xml27
-rw-r--r--beans/src/test/resources/xml/MockOwner.xml26
-rw-r--r--beans/src/test/resources/xml/MockOwner_Ambiguous.xml27
-rw-r--r--beans/src/test/resources/xml/MockOwner_Null.xml27
-rw-r--r--beans/src/test/resources/xml/MockOwner_Specific.xml27
-rw-r--r--beans/src/test/resources/xml/MockSetImplements.xml27
-rw-r--r--beans/src/test/resources/xml/MockSynchronizedCollection.xml37
-rw-r--r--beans/src/test/resources/xml/MockSynchronizedList.xml37
-rw-r--r--beans/src/test/resources/xml/MockSynchronizedMap.xml40
-rw-r--r--beans/src/test/resources/xml/MockSynchronizedRandomAccessList.xml37
-rw-r--r--beans/src/test/resources/xml/MockSynchronizedSet.xml37
-rw-r--r--beans/src/test/resources/xml/MockSynchronizedSortedMap.xml40
-rw-r--r--beans/src/test/resources/xml/MockSynchronizedSortedSet.xml37
-rw-r--r--beans/src/test/resources/xml/MockTreeMap.xml29
-rw-r--r--beans/src/test/resources/xml/MockUnmodifiableCollection.xml37
-rw-r--r--beans/src/test/resources/xml/MockUnmodifiableList.xml37
-rw-r--r--beans/src/test/resources/xml/MockUnmodifiableMap.xml40
-rw-r--r--beans/src/test/resources/xml/MockUnmodifiableRandomAccessList.xml37
-rw-r--r--beans/src/test/resources/xml/MockUnmodifiableSet.xml37
-rw-r--r--beans/src/test/resources/xml/MockUnmodifiableSortedMap.xml40
-rw-r--r--beans/src/test/resources/xml/MockUnmodifiableSortedSet.xml37
-rw-r--r--beans/src/test/resources/xml/ObjectID.xml56
-rw-r--r--beans/src/test/resources/xml/Proxy.xml3
-rw-r--r--beans/src/test/resources/xml/SampleBean_StringCodec.xml15
-rw-r--r--beans/src/test/resources/xml/StaticField.xml25
-rw-r--r--beans/src/test/resources/xml/Test1.xml36
-rw-r--r--beans/src/test/resources/xml/Test2.xml32
-rw-r--r--beans/src/test/resources/xml/Test3.xml29
-rw-r--r--beans/src/test/resources/xml/Test4.xml29
-rw-r--r--beans/src/test/resources/xml/Test5.xml29
-rw-r--r--beans/src/test/resources/xml/Test6.xml64
-rw-r--r--beans/src/test/resources/xml/Test7.xml35
-rw-r--r--beans/src/test/resources/xml/bad_int.xml4
-rw-r--r--beans/src/test/resources/xml/int.xml4
-rw-r--r--beans/src/test/resources/xml/null.xml4
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/infos/MockFooButtonBeanInfo.java53
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/AType.java32
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/AnotherSampleProperty.java28
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/AnotherSamplePropertyEditor.java30
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/ChildBean.java28
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/ChildBeanBeanInfo.java48
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/GrannyBean.java38
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/GrannyBeanBeanInfo.java48
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/MisprintBean.java32
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/MisprintEvent.java29
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/MisprintListenerr.java33
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/MockOwnerClass.java36
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/OtherBean.java39
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/OtherEditor.java30
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/ParentBean.java28
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/ParentBeanBeanInfo.java49
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/SampleBean.java178
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/SampleBeanBeanInfo.java41
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/SampleEvent.java49
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/SampleException.java26
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/SampleListener.java31
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/SampleProperty.java28
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/SamplePropertyEditor.java30
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/StandardBean2BeanInfo.java41
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/StringEditor.java36
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/TInspectorCluster.java298
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/TestEventHandler.java245
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/MethodInvocationRecords.java225
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/Utils.java38
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockBeanContext.java353
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockBeanContextChild.java99
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockBeanContextChildComponentProxy.java38
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockBeanContextChildDelegateS.java66
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockBeanContextChildS.java78
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockBeanContextContainerProxy.java38
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockBeanContextDelegateS.java252
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockBeanContextMembershipListener.java61
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockBeanContextMembershipListenerS.java60
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockBeanContextProxy.java47
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockBeanContextProxyS.java58
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockBeanContextServiceProvider.java78
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockBeanContextServiceProviderBeanInfo.java124
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockBeanContextServiceProviderS.java54
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockBeanContextServiceRevokedListener.java44
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockBeanContextServices.java488
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockBeanContextServicesListener.java57
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockBeanContextServicesListenerS.java47
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockVetoChangeListener.java46
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockVetoableChangeListener.java45
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockVetoableChangeListenerS.java48
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockVisibility.java74
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/CorruptedSerBean.java22
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/CorruptedSerBean.ser1
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/EmptySerBean.ser0
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/FakeFox.java26
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/FakeFox01.java34
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/FakeFox011.java34
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/FakeFox01BeanInfo.java96
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/FakeFox02.java41
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/FakeFox02BeanInfo.java49
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/FakeFox03.java28
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/FakeFox031.java31
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/FakeFox031BeanInfo.java54
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/FakeFox03BeanInfo.java94
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/FakeFox04.java30
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/FakeFox041.java42
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/FakeFox0411.java31
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/Foz.java57
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/FozDefault.java57
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/Fozz.java57
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/FozzEditor.java152
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/Fozzz.java57
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockAppletBean.java53
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockAppletBean2.java61
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockAppletInitializer.java49
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockBean4Codec.java130
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockBean4CodecAdv.java162
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockBean4CodecBadGetter.java30
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockBean4CodecBadSetter.java30
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockBean4CodecPrimitives.java408
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockBean4Owner_Owner.java39
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockBean4Owner_Target.java34
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockBean4StaticField.java46
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockBean4StaticField_PD.java39
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockBeanListener2.java28
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockButton.java65
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockExceptionListener.java246
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockFakeListener.java25
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockFoo.java56
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockFoo2.java40
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockFoo2BeanInfo.java42
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockFoo2Parent.java34
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockFoo2ParentBeanInfo.java39
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockFooBeanInfo.java39
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockFooButton.java37
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockFooChild.java43
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockFooChildBeanInfo.java84
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockFooLabel.java52
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockFooLabelBeanInfo.java50
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockFooLiYang.java48
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockFooStop.java37
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockFooSub.java46
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockFooSubBeanInfo.java85
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockFooSubSub.java36
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockInterface.java23
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockInterfaceBeanInfo.java57
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockJavaBean.java377
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockNullSubClass.java22
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockNullSubClassBeanInfo.java45
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockNullSuperClass.java22
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockNullSuperClassBeanInfo.java37
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockSimpleBeanInfo.java27
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockSubClass.java22
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockSubClassBeanInfo.java66
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockSuperClass.java33
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockSuperClassBeanInfo.java38
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockTreeMapClass.java33
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/NonSerializedVCListener.java57
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/NotExistBean.serbin105 -> 0 bytes
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/SerializedVCListener.java55
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/WrongSerBean.java58
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/WrongSerBean.serbin106 -> 0 bytes
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/WrongSerBean2.java22
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/homonymy/mocksubject1/MockHomonymySubject.java33
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/homonymy/mocksubject1/info/MockHomonymySubjectBeanInfo.java36
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/homonymy/mocksubject2/MockHomonymySubject.java33
-rw-r--r--beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/homonymy/mocksubject2/info/MockHomonymySubjectBeanInfo.java36
252 files changed, 0 insertions, 44212 deletions
diff --git a/beans/src/test/java-internal/java/beans/ArrayPersistenceDelegateTest.java b/beans/src/test/java-internal/java/beans/ArrayPersistenceDelegateTest.java
deleted file mode 100644
index 4b8d622..0000000
--- a/beans/src/test/java-internal/java/beans/ArrayPersistenceDelegateTest.java
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- * 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 java.beans;
-
-import java.io.ByteArrayOutputStream;
-import java.lang.reflect.Array;
-
-import junit.framework.TestCase;
-
-/**
- * Test the internal class java.beans.ArrayPersistenceDelegate.
- */
-public class ArrayPersistenceDelegateTest extends TestCase {
-
- private ArrayPersistenceDelegate pd = null;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- pd = new ArrayPersistenceDelegate();
- }
-
- @Override
- protected void tearDown() throws Exception {
- pd = null;
- super.tearDown();
- }
-
- public void testMutates() {
- assertFalse(pd.mutatesTo(new int[] { 1 }, null));
- assertFalse(pd.mutatesTo(null, null));
- assertFalse(pd.mutatesTo(new int[1], new int[2]));
- assertTrue(pd.mutatesTo(new int[] { 1, 3 }, new int[] { 1, 2 }));
- }
-
- /*
- * test mutates with wrapper array
- */
- public void test_MutatesTo_WrapperArray() {
- // Regression for Harmony-4022
- // one wrapper array and null
- assertFalse(pd.mutatesTo(new Integer[] { 1, 2, 3 }, null));
- assertFalse(pd.mutatesTo(new Boolean[] { true, false }, null));
- assertFalse(pd.mutatesTo(new Short[] { 1, 2 }, null));
- assertFalse(pd.mutatesTo(new Long[] { 23000000094382l, 23000000094383l }, null));
- assertFalse(pd.mutatesTo(new Character[] { 'a', 'b', 'c'}, null));
- assertFalse(pd.mutatesTo(new Float[] { 0.1f, 0.2f }, null));
- assertFalse(pd.mutatesTo(new Double[] { 0.1, 0.2 }, null));
-
- // two wrapper arries with the same component type but different length
- assertFalse(pd.mutatesTo(new Integer[] { 1, 2, 3 }, new Integer[] { 1, 2}));
- assertFalse(pd.mutatesTo(new Boolean[] { true, false }, new Boolean[] { true }));
- assertFalse(pd.mutatesTo(new Short[] { 1, 2 }, new Short[] { 1, 2, 3}));
- assertFalse(pd.mutatesTo(new Long[] { 23000000094382l, 23000000094383l }, new Long[] { 23000000094382l}));
- assertFalse(pd.mutatesTo(new Character[] { 'a', 'b', 'c'}, new Character[] {}));
- assertFalse(pd.mutatesTo(new Float[] { 0.1f, 0.2f }, new Float[] { 0.1f, 0.2f, 0.3f}));
- assertFalse(pd.mutatesTo(new Double[] { 0.1, 0.2 }, new Double[] { 0.1 }));
-
- // two wrapper arries with the same length but different component types
- assertFalse(pd.mutatesTo(new Integer[] { 1, 2, 3 }, new Boolean[] { true, false }));
- assertFalse(pd.mutatesTo(new Boolean[] { true, false }, new Short[] { 1, 2 }));
- assertFalse(pd.mutatesTo(new Short[] { 1, 2 }, new Long[] { 23000000094382l, 23000000094383l }));
- assertFalse(pd.mutatesTo(new Long[] { 23000000094382l, 23000000094383l }, new Character[] { 'a', 'b', 'c'}));
- assertFalse(pd.mutatesTo(new Character[] { 'a', 'b', 'c'}, new Float[] { 0.1f, 0.2f }));
- assertFalse(pd.mutatesTo(new Float[] { 0.1f, 0.2f }, new Double[] { 0.1 }));
-
- // two wrapper arries with the same length and component type but different internal values
- assertTrue(pd.mutatesTo(new Integer[] { 1, 2, 3 }, new Integer[] { 5, 6, 7 }));
- assertTrue(pd.mutatesTo(new Boolean[] { true, false, false}, new Boolean[] { false, true, true}));
- assertTrue(pd.mutatesTo(new Short[] { 1, 2 }, new Short[] { 4, 5 }));
- assertTrue(pd.mutatesTo(new Long[] { 23000000094382l, 23000000094383l }, new Long[] { 534300002l, 23020094383l }));
- assertTrue(pd.mutatesTo(new Character[] { 'a', 'b', 'c'}, new Character[] { 'd', 'e', 'f'}));
- assertTrue(pd.mutatesTo(new Float[] { 0.1f, 0.2f }, new Float[] { 0.4f, 0.6f }));
- assertTrue(pd.mutatesTo(new Double[] { 0.1, 0.2 }, new Double[] { 0.3, 0.343 }));
- }
-
- /*
- * test mutatesTo with object array
- */
- public void test_MutatesTo_ObjectArray(){
- // Regression for Harmony-4022
- // one object array and null
- assertFalse(pd.mutatesTo(new MockAObject[] { new MockAObject() }, null));
- assertFalse(pd.mutatesTo(new MockBObject[] { new MockBObject() }, null));
- assertFalse(pd.mutatesTo(new MockObject[] { new MockAObject(), new MockBObject()}, null));
-
- // two wrapper arries with the same component type but different length
- assertFalse(pd.mutatesTo(new MockObject[1], new MockObject[2]));
- assertFalse(pd.mutatesTo(new MockAObject[1], new MockAObject[2]));
- assertFalse(pd.mutatesTo(new MockBObject[1], new MockBObject[2]));
-
- // two object array with the same length but different component types
- assertFalse(pd.mutatesTo(new MockAObject[] { new MockAObject() }, new MockBObject[] { new MockBObject() }));
- assertFalse(pd.mutatesTo(new MockObject[] {new MockObject()}, new MockAObject[] { new MockAObject() }));
- assertFalse(pd.mutatesTo(new MockObject[] {new MockAObject()}, new MockAObject[] { new MockAObject() }));
- assertFalse(pd.mutatesTo(new MockObject[] {new MockBObject()}, new MockAObject[] { new MockAObject() }));
- assertFalse(pd.mutatesTo(new MockObject[] {new MockObject()}, new MockBObject[] { new MockBObject() }));
- assertFalse(pd.mutatesTo(new MockObject[] {new MockBObject()}, new MockBObject[] { new MockBObject() }));
- assertFalse(pd.mutatesTo(new MockObject[] {new MockAObject()}, new MockBObject[] { new MockBObject() }));
-
- // two object array with the same length and component type but different internal values
- assertTrue(pd.mutatesTo(new MockObject[] { new MockAObject() }, new MockObject[] { new MockBObject() }));
- assertTrue(pd.mutatesTo(new MockAObject[] { new MockAObject(1) }, new MockAObject[] { new MockAObject(2) }));
- assertTrue(pd.mutatesTo(new MockBObject[] { new MockBObject(1) }, new MockBObject[] { new MockBObject(2) }));
- }
-
- public void testInitialize() {
- // TBD
- }
-
- public void testInstantiate_Normal() throws Exception {
- Object obj = new int[] { 1, 2, 3 };
- Expression exp = pd.instantiate(obj, new Encoder());
- assertSame(obj, exp.getValue());
- assertSame(Array.class, exp.getTarget());
- assertEquals("newInstance", exp.getMethodName());
- assertEquals(2, exp.getArguments().length);
- assertSame(Integer.TYPE, exp.getArguments()[0]);
- assertEquals(new Integer(3), exp.getArguments()[1]);
- }
-
- public class MockObject {
-
- }
-
- public class MockAObject extends MockObject {
- String name = "A Object";
- int id = 0x01;
-
- public MockAObject() {
-
- }
-
- public MockAObject(int idValue){
- id = idValue;
- }
- }
-
- public class MockBObject extends MockObject {
- String name = "B Object";
- int id = 0x02;
-
- public MockBObject(){
-
- }
-
- public MockBObject(int idValue){
- id = idValue;
- }
- }
-
- public static class ParentClass {
-
- String multiArray[][][] = { { { "1", "2" } }, { { "3", "4", "5" } },
- { { "1", "2" }, { "3", "4", "5" } } };
-
- public ParentClass() {
- }
-
- public String[][][] getMultiArray() {
- return multiArray;
- }
-
- public void setMultiArray(String[][][] array) {
- multiArray = array;
- }
-
- }
-
- public static class ChildClass extends ParentClass {
-
- public ChildClass() {
-
- }
-
- }
-
- public void testInitialize_MultiArray() throws Exception {
- ChildClass child = new ChildClass();
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- XMLEncoder xmlEncoder = new XMLEncoder(bos);
- xmlEncoder.writeObject(child);
- xmlEncoder.close();
- assertFalse(bos.toString("UTF-8").contains("multiArray"));
- }
-
-}
diff --git a/beans/src/test/java-internal/java/beans/ClassPersistenceDelegateTest.java b/beans/src/test/java-internal/java/beans/ClassPersistenceDelegateTest.java
deleted file mode 100644
index 8cb8cbb..0000000
--- a/beans/src/test/java-internal/java/beans/ClassPersistenceDelegateTest.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * 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 java.beans;
-
-import java.beans.Encoder;
-import java.beans.Expression;
-import java.beans.ClassPersistenceDelegate;
-
-import junit.framework.TestCase;
-
-/**
- * Test the internal class java.beans.ClassPersistenceDelegate.
- */
-public class ClassPersistenceDelegateTest extends TestCase {
-
- private ClassPersistenceDelegate pd = null;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- pd = new ClassPersistenceDelegate();
- }
-
- public void testMutates() {
- assertFalse(pd.mutatesTo(Class.class, null));
- assertFalse(pd.mutatesTo(null, null));
- assertFalse(pd.mutatesTo(Class.class, String.class));
- assertTrue(pd.mutatesTo(String.class, String.class));
- }
-
- public void testInitialize() {
- pd.initialize(null, null, null, null);
- }
-
- public void testInstantiate_Normal() throws Exception {
- Expression exp = pd.instantiate(Integer.class, new Encoder());
-
- assertSame(Integer.class, exp.getValue());
- assertTrue(exp.getTarget() instanceof Class);
- assertEquals("forName", exp.getMethodName());
- assertEquals(1, exp.getArguments().length);
- assertEquals("java.lang.Integer", exp.getArguments()[0]);
- }
-
- public void testInstantiate_Primitive() throws Exception {
- Expression exp = pd.instantiate(Integer.TYPE, new Encoder());
-
- assertSame(Integer.TYPE, exp.getValue());
- assertTrue(exp.getTarget() instanceof java.lang.reflect.Field);
- assertEquals("get", exp.getMethodName());
- assertEquals(1, exp.getArguments().length);
- assertNull(exp.getArguments()[0]);
- }
-
- public void testInstantiate_Class() throws Exception {
- Expression exp = pd.instantiate(Class.class, new Encoder());
-
- assertSame(Class.class, exp.getValue());
- assertTrue(exp.getTarget() instanceof Class);
- assertEquals("forName", exp.getMethodName());
- assertEquals(1, exp.getArguments().length);
- assertEquals("java.lang.Class", exp.getArguments()[0]);
- }
-}
diff --git a/beans/src/test/java-internal/java/beans/NullPersistenceDelegateTest.java b/beans/src/test/java-internal/java/beans/NullPersistenceDelegateTest.java
deleted file mode 100644
index 25c75a3..0000000
--- a/beans/src/test/java-internal/java/beans/NullPersistenceDelegateTest.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * 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 java.beans;
-
-import junit.framework.TestCase;
-
-/**
- * Test the internal class java.beans.NullPersistenceDelegate.
- */
-public class NullPersistenceDelegateTest extends TestCase {
-
- private PersistenceDelegate pd = null;
-
- private Encoder enc = null;
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- enc = new Encoder();
- pd = enc.getPersistenceDelegate(null);
- }
-
- public void test_instantiate_LObject_LEncoder() throws Exception {
- Expression exp = pd.instantiate(null, enc);
- assertNull(exp);
-
- exp = pd.instantiate(new Object(), enc);
- assertNull(exp);
-
- exp = pd.instantiate(null, null);
- assertNull(exp);
-
- exp = pd.instantiate(new Object(), null);
- assertNull(exp);
- }
-
- public void test_mutatesTo_LObject_Object() {
- assertFalse(pd.mutatesTo(null, null));
- assertFalse(pd.mutatesTo(null, new Object()));
- assertFalse(pd.mutatesTo(new Object(), null));
-
- Object o = new Object();
- assertTrue(pd.mutatesTo(o, o));
- assertTrue(pd.mutatesTo(new Object(), new Object()));
- assertFalse(pd.mutatesTo(new Object(), new Integer(1)));
- }
-
- public void test_writeObject_LObject_LEncoder() {
- pd.writeObject(null, null);
- }
-
- public void test_initialize() {
- pd.initialize(null, null, null, null);
- }
-
-}
diff --git a/beans/src/test/java-internal/java/beans/ProxyPersistenceDelegateTest.java b/beans/src/test/java-internal/java/beans/ProxyPersistenceDelegateTest.java
deleted file mode 100644
index bc7fb7f..0000000
--- a/beans/src/test/java-internal/java/beans/ProxyPersistenceDelegateTest.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * 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 java.beans;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-
-import junit.framework.TestCase;
-
-public class ProxyPersistenceDelegateTest extends TestCase {
-
- private ProxyPersistenceDelegate pd = null;
-
- protected void setUp() throws Exception {
- super.setUp();
- pd = new ProxyPersistenceDelegate();
- }
-
- protected void tearDown() throws Exception {
- pd = null;
- super.tearDown();
- }
-
- /*
- * test mutatesTo method
- */
- public void test_MutatesTo() {
- // Regression for Harmony-4022
- Object proxy1 = Proxy.newProxyInstance(
- this.getClass().getClassLoader(), new Class[] {
- ITestReturnObject.class, ITestReturnString.class },
- new TestProxyHandler(new TestProxyImpl()));
- Object proxy2 = Proxy.newProxyInstance(
- this.getClass().getClassLoader(),
- new Class[] { ITestReturnObject.class }, new TestProxyHandler(
- new TestProxyImpl()));
-
- assertFalse(pd.mutatesTo(null, null));
- assertFalse(pd.mutatesTo(new MockAObject(), new MockAObject()));
- assertFalse(pd.mutatesTo(new MockAObject(), new MockBObject()));
- assertFalse(pd.mutatesTo(proxy1, null));
- assertFalse(pd.mutatesTo(proxy1, proxy2));
- assertTrue(pd.mutatesTo(proxy1, proxy1));
- }
-
- public class MockAObject {
-
- }
-
- public class MockBObject {
-
- }
-
- public static interface ITestReturnObject {
- Object f();
- }
-
- public static interface ITestReturnString {
- String f();
- }
-
- public static class TestProxyImpl implements ITestReturnObject,
- ITestReturnString {
- public String f() {
- return null;
- }
- }
-
- public static class TestProxyHandler implements InvocationHandler {
- private Object proxied;
-
- public TestProxyHandler(Object object) {
- proxied = object;
- }
-
- public Object invoke(Object object, Method method, Object[] args)
- throws Throwable {
- return method.invoke(proxied, args);
- }
- }
-
-}
diff --git a/beans/src/test/java-internal/java/beans/StringPersistenceDelegateTest.java b/beans/src/test/java-internal/java/beans/StringPersistenceDelegateTest.java
deleted file mode 100644
index efd9d97..0000000
--- a/beans/src/test/java-internal/java/beans/StringPersistenceDelegateTest.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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 java.beans;
-
-import java.beans.Encoder;
-import java.beans.Expression;
-import java.beans.StringPersistenceDelegate;
-
-import junit.framework.TestCase;
-
-/**
- * Test the internal class java.beans.StringPersistenceDelegate.
- */
-public class StringPersistenceDelegateTest extends TestCase {
-
- private StringPersistenceDelegate pd = null;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- pd = new StringPersistenceDelegate();
- }
-
- public void testMutates() {
- assertFalse(pd.mutatesTo("", null));
- assertFalse(pd.mutatesTo(null, null));
- assertFalse(pd.mutatesTo("str1", "str2"));
- assertTrue(pd.mutatesTo("str1", "str1"));
- }
-
- public void testInitialize() {
- pd.initialize(null, null, null, null);
- }
-
- public void testInstantiate_Normal() throws Exception {
- Expression exp = pd.instantiate("str", new Encoder());
-
- assertSame("str", exp.getValue());
- assertSame(String.class, exp.getTarget());
- assertEquals("new", exp.getMethodName());
- assertEquals(1, exp.getArguments().length);
- assertEquals("str", exp.getArguments()[0]);
- }
-}
diff --git a/beans/src/test/java-internal/java/beans/beancontext/BeanContextServicesSupportTest.java b/beans/src/test/java-internal/java/beans/beancontext/BeanContextServicesSupportTest.java
deleted file mode 100644
index bfdd82f..0000000
--- a/beans/src/test/java-internal/java/beans/beancontext/BeanContextServicesSupportTest.java
+++ /dev/null
@@ -1,310 +0,0 @@
-/*
- * 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.
- */
-
-/**
- * @author Sergey A. Krivenko
- */
-package java.beans.beancontext;
-
-import java.util.Locale;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-/**
- * Test class for java.beans.beancontext.BeanContextServicesSupport.
- * <p>
- *
- * @author Sergey A. Krivenko
- */
-
-public class BeanContextServicesSupportTest extends TestCase {
-
- /** STANDARD BEGINNING * */
-
- /**
- * No arguments constructor to enable serialization.
- * <p>
- */
- public BeanContextServicesSupportTest() {
- super();
- }
-
- /**
- * Constructs this test case with the given name.
- * <p>
- *
- * @param name -
- * The name for this test case.
- * <p>
- */
- public BeanContextServicesSupportTest(String name) {
- super(name);
- }
-
- /** TEST CONSTRUCTORS * */
-
- /**
- * Test constructor with BeanContextServices, Locale, boolean, boolean
- * parameters.
- * <p>
- *
- * @see BeanContextServicesSupport#BeanContextServicesSupport(
- * BeanContextServices, Locale, boolean, boolean)
- */
- public void testConstructorBeanContextServicesLocalebooleanboolean() {
- new BeanContextServicesSupport(null, null, true, true);
- }
-
- /**
- * Test constructor with BeanContextServices, Locale, boolean parameters
- *
- * @see BeanContextServicesSupport#BeanContextServicesSupport(
- * BeanContextServices, Locale, boolean)
- */
- public void testConstructorBeanContextServicesLocaleboolean() {
- new BeanContextServicesSupport(null, null, true);
- }
-
- /**
- * Test constructor with BeanContextServices, Locale parameters.
- * <p>
- *
- * @see BeanContextServicesSupport#BeanContextServicesSupport(
- * BeanContextServices, Locale)
- */
- public void testConstructorBeanContextServicesLocale() {
- new BeanContextServicesSupport(null, null);
- }
-
- /**
- * Test constructor with BeanContextServices parameter.
- * <p>
- *
- * @see BeanContextServicesSupport#BeanContextServicesSupport(
- * BeanContextServices)
- */
- public void testConstructorBeanContextServices() {
- new BeanContextServicesSupport(null);
- }
-
- /**
- * * Test constructor with no parameters.
- * <p>
- *
- * @see BeanContextServicesSupport#BeanContextServicesSupport()
- */
- public void testConstructor() {
- new BeanContextServicesSupport();
- }
-
- /** TEST METHODS * */
-
- /**
- * Test method createBCSChild() with Object, Object parameters.
- * <p>
- */
- public void testCreateBCSChildObjectObject() {
- // Just call the method
- BeanContextServicesSupport sup = new BeanContextServicesSupport();
- sup.createBCSChild(new Object(), new Object());
- }
-
- /**
- * Test method addService() with Class, BeanContextServiceProvider, boolean
- * parameters.
- * <p>
- */
- public void testAddServiceClassBeanContextServiceProviderboolean() {
- // Instantiate services and add service
- BeanContextServicesSupport sup = new BeanContextServicesSupport();
- sup.addService(Object.class, getProvider(), true);
-
- assertEquals("One service should be registered", 1, sup.services.size());
- }
-
- /**
- * Test method revokeService() with Class, BeanContextServiceProvider,
- * boolean parameters.
- * <p>
- */
- public void testRevokeServiceClassBeanContextServiceProviderboolean() {
- // Instantiate services, add and remove service
- BeanContextServicesSupport sup = new BeanContextServicesSupport();
- BeanContextServiceProvider pr = getProvider();
- sup.addService(Object.class, pr, true);
- sup.revokeService(Object.class, pr, true);
-
- assertEquals("No service should be registered", 0, sup.services.size());
- }
-
- /**
- * Test method addService() with Class, BeanContextServiceProvider
- * parameters.
- * <p>
- */
- public void testAddServiceClassBeanContextServiceProvider() {
- // Instantiate services and add service
- BeanContextServicesSupport sup = new BeanContextServicesSupport();
- sup.addService(Object.class, getProvider());
- }
-
- /**
- * Test method hasService() with Class parameter.
- * <p>
- */
- public void testHasServiceClass() {
- // Instantiate services and add service
- BeanContextServicesSupport sup = new BeanContextServicesSupport();
- Class<?> cl = new Object().getClass();
- sup.addService(cl, getProvider(), true);
-
- assertTrue("Service not found", sup.hasService(cl));
- }
-
- /**
- * Test method getBeanContextServicesPeer() with no parameters.
- * <p>
- */
- public void testGetBeanContextServicesPeer() {
- // Instantiate services
- BeanContextServicesSupport sup = new BeanContextServicesSupport();
-
- assertTrue("The objects are not equal", sup
- .getBeanContextServicesPeer().equals(sup));
- }
-
- /**
- * Test method releaseBeanContextResources() with no parameters.
- * <p>
- */
- public void testReleaseBeanContextResources() {
- // Instantiate services
- BeanContextServicesSupport sup = new BeanContextServicesSupport();
- sup.releaseBeanContextResources();
-
- assertNull("The resources are not released", sup.proxy);
- }
-
- /**
- * Test method initializeBeanContextResources() with no parameters.
- * <p>
- */
- public void testInitializeBeanContextResources() {
- // Instantiate services
- BeanContextServicesSupport sup = new BeanContextServicesSupport();
- sup.initializeBeanContextResources();
-
- // if (sup.proxy == null) {
- // fail("The resources are not initialized");
- // }
- }
-
- /**
- * Test method hasService() with Class=null parameter.
- * <p>
- */
- 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.
- * <p>
- */
- 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.
- * <p>
- */
- 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.
- * <p>
- */
- 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
- */
- @SuppressWarnings("unchecked")
- 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.
- * <p>
- */
- public static Test suite() {
- return new TestSuite(BeanContextServicesSupportTest.class);
- }
-}
diff --git a/beans/src/test/java-internal/java/beans/beancontext/BeanContextSupportTest.java b/beans/src/test/java-internal/java/beans/beancontext/BeanContextSupportTest.java
deleted file mode 100644
index da7d210..0000000
--- a/beans/src/test/java-internal/java/beans/beancontext/BeanContextSupportTest.java
+++ /dev/null
@@ -1,565 +0,0 @@
-/*
- * 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.
- */
-
-/**
- * @author Sergey A. Krivenko
- */
-package java.beans.beancontext;
-
-import java.util.Locale;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-/**
- * Test class for java.beans.beancontext.BeanContextSupport.
- * <p>
- */
-
-public class BeanContextSupportTest extends TestCase {
-
- /** STANDARD BEGINNING * */
-
- /**
- * No arguments constructor to enable serialization.
- * <p>
- */
- public BeanContextSupportTest() {
- super();
- }
-
- /**
- * Constructs this test case with the given name.
- * <p>
- *
- * @param name -
- * The name for this test case.
- * <p>
- */
- public BeanContextSupportTest(String name) {
- super(name);
- }
-
- /** TEST CONSTRUCTORS * */
-
- /**
- * * Test constructor with BeanContext, Locale, boolean, boolean parameters.
- * <p>
- *
- * @see BeanContextSupport#BeanContextSupport(BeanContext, Locale, boolean,
- * boolean)
- */
- public void testConstructorBeanContextLocalebooleanboolean() {
- new BeanContextSupport(null, null, true, true);
- }
-
- /**
- * * Test constructor with BeanContext, Locale, boolean parameters.
- * <p>
- *
- * @see BeanContextSupport#BeanContextSupport(BeanContext, Locale, boolean)
- */
- public void testConstructorBeanContextLocaleboolean() {
- new BeanContextSupport(null, null, true);
- }
-
- /**
- * * Test constructor with BeanContext, Locale parameters.
- * <p>
- *
- * @see BeanContextSupport#BeanContextSupport(BeanContext, Locale)
- */
- public void testConstructorBeanContextLocale() {
- new BeanContextSupport(null, null);
- }
-
- /**
- * * Test constructor with BeanContext parameter.
- * <p>
- *
- * @see BeanContextSupport#BeanContextSupport(BeanContext)
- */
- public void testConstructorBeanContext() {
- new BeanContextSupport(null);
- }
-
- /**
- * * Test constructor with no parameters.
- * <p>
- *
- * @see BeanContextSupport#BeanContextSupport()
- */
- public void testConstructor() {
- new BeanContextSupport();
- }
-
- /** TEST METHODS * */
-
- /**
- * Test method createBCSChild() with Object, Object parameters.
- * <p>
- */
- public void testCreateBCSChildObjectObject() {
- BeanContextSupport sup = new BeanContextSupport();
- sup.createBCSChild(new BeanContextSupport(), new BeanContextSupport());
- }
-
- /**
- * Test method setLocale() with Locale parameter.
- * <p>
- */
- public void testSetLocaleLocale() throws Exception {
- BeanContextSupport sup = new BeanContextSupport();
- sup.setLocale(null);
-
- assertEquals("BeanContext should have default locale", java.util.Locale
- .getDefault(), sup.getLocale());
- }
-
- /**
- * Test method bcsChildren() with no parameters.
- * <p>
- */
- @SuppressWarnings("unchecked")
- public void testBcsChildren() {
- BeanContextSupport sup = new BeanContextSupport();
- sup.add(new BeanContextChildSupport());
-
- for (java.util.Iterator it = sup.bcsChildren(); it.hasNext();) {
- Object next = it.next();
-
- assertTrue("Children must be instances of "
- + "BeanContextSupport.BCSChild class "
- + "but at least one of them: " + next.getClass(),
- next instanceof BeanContextSupport.BCSChild);
- }
- }
-
- /**
- * Test method retainAll() with Collection parameter.
- * <p>
- */
- public void testRetainAllCollection() {
- /*
- * // Create an instance and add one child BeanContextSupport sup = new
- * BeanContextSupport(); BeanContextChildSupport ch = new
- * BeanContextChildSupport(); sup.add(ch); // Create collection with an
- * instance of the child that was added java.util.Collection col = new
- * java.util.ArrayList(); col.add(ch); // Remove all children that are
- * not in the collection // The collection must remain unchanged if
- * (sup.retainAll(col)) { fail("False should be returned"); } // Just
- * one child must be present if (sup.size() != 1) { fail("The size of
- * the collection must be 1"); } // Add a new child in the collection
- * and remove the old one col.clear(); col.add(new Object()); // Remove
- * all children that are not in the collection // The collection must
- * have 0 elements after that if (!sup.retainAll(col)) { fail("True
- * should be returned"); } // No children must be present if (sup.size() !=
- * 0) { fail("The size of the collection must be 0"); }
- */
- }
-
- /**
- * Test method removeAll() with Collection parameter.
- * <p>
- */
- public void testRemoveAllCollection() {
- /*
- * // Create an instance and add one child BeanContextSupport sup = new
- * BeanContextSupport(); BeanContextChildSupport ch = new
- * BeanContextChildSupport(); sup.add(ch); // Create collection with an
- * instance of an arbitrary child java.util.Collection col = new
- * java.util.ArrayList(); col.add(new Object()); // Remove all children
- * that are in the collection // The collection should not change after
- * that if (sup.removeAll(col)) { fail("False should be returned"); } //
- * Add a child that is a member of the BeanContext col.add(ch); //
- * Remove all children that are in the collection // The collection
- * should change after that if (!sup.removeAll(col)) { fail("True should
- * be returned"); } // No children must be present if (sup.size() != 0) {
- * fail("The size of the collection must be 0 but is " + sup.size()); }
- */
- }
-
- /**
- * Test method containsAll() with Collection parameter.
- * <p>
- */
- public void testContainsAllCollection() {
- /*
- * // Create an instance and add two children BeanContextSupport sup =
- * new BeanContextSupport(); BeanContextChildSupport ch = new
- * BeanContextChildSupport(); Object obj = new Object(); sup.add(ch);
- * sup.add(obj); // Create collection with BCS children that just were
- * added java.util.Collection col = new java.util.ArrayList();
- *
- * for (java.util.Iterator it = sup.bcsChildren(); it.hasNext(); ) {
- * col.add(it.next()); } // Two collections have the same elements if
- * (!sup.containsAll(col)) { fail("True should be returned"); }
- *
- * sup.remove(obj); // Now they are different if (sup.containsAll(col)) {
- * fail("False should be returned"); }
- */
- }
-
- /**
- * Test method addAll() with Collection parameter.
- * <p>
- */
- public void testAddAllCollection() {
- /*
- * // Create an instance and add two children BeanContextSupport sup =
- * new BeanContextSupport(); // Create collection with two elements
- * java.util.Collection col = new java.util.ArrayList(); col.add(new
- * BeanContextChildSupport()); col.add(new Object()); // Place two
- * children into the BeanContext if (!sup.addAll(col)) { fail("True
- * should be returned"); } // Two children must be present if
- * (sup.size() != 2) { fail("The size of the collection must be 2 but is " +
- * sup.size()); }
- */
- }
-
- /**
- * Test method remove() with Object, boolean parameters.
- * <p>
- */
- public void testRemoveObjectboolean() {
- // Create an instance and add one child
- BeanContextSupport sup = new BeanContextSupport();
- BeanContextChildSupport ch = new BeanContextChildSupport();
- sup.add(ch);
-
- // Remove non-existent child
- assertFalse(sup.remove(new Object(), true));
-
- // Remove it
- assertTrue(sup.remove(ch, true));
-
- // No children must be present
- assertEquals("The size of the collection must be 0", 0, sup.size());
- }
-
- /**
- * Test method remove() with Object parameter.
- * <p>
- */
- public void testRemoveObject() {
- // Create an instance and add one child
- BeanContextSupport sup = new BeanContextSupport();
- BeanContextChildSupport ch = new BeanContextChildSupport();
- sup.add(ch);
-
- // Remove non-existent child
- assertFalse(sup.remove(new Object()));
-
- // Remove it
- assertTrue(sup.remove(ch));
-
- // No children must be present
- assertEquals("The size of the collection must be 0", 0, sup.size());
- }
-
- /**
- * Test method containsKey() with Object parameter.
- * <p>
- */
- public void testContainsKeyObject() {
-
- // Create an instance and add a child
- BeanContextSupport sup = new BeanContextSupport();
- BeanContextChildSupport ch = new BeanContextChildSupport();
- sup.add(ch);
-
- // We should find the child now
- assertTrue(sup.containsKey(ch));
- }
-
- /**
- * Test method contains() with Object parameter.
- * <p>
- */
- public void testContainsObject() {
- // Create an instance and add a child
- BeanContextSupport sup = new BeanContextSupport();
- BeanContextChildSupport ch = new BeanContextChildSupport();
- sup.add(ch);
-
- BeanContextSupport.BCSChild bcs = (BeanContextSupport.BCSChild) sup
- .bcsChildren().next();
-
- // We should find the child now
- if (!sup.contains(bcs)) {
- // fail("True should be returned");
- }
- }
-
- /**
- * Test method add() with Object parameter.
- * <p>
- */
- public void testAddObject() {
- // Create an instance and add a child
- BeanContextSupport sup = new BeanContextSupport();
- sup.add(new Object());
-
- // Just one child must be present
- assertEquals("The size of the collection must be 1", 1, sup.size());
- }
-
- /**
- * Test method toArray() with no parameters.
- * <p>
- */
- public void testToArray() {
- // Create an instance and add two children
- BeanContextSupport sup = new BeanContextSupport();
- sup.add("obj1");
- sup.add("obj2");
-
- // Convert to array
- Object[] array = sup.toArray();
-
- // Check length
- assertEquals("The size of the collection must be 2", 2, array.length);
- }
-
- /**
- * Test method copyChildren() with no parameters.
- * <p>
- */
- public void testCopyChildren() {
- // Create an instance and add two children
- BeanContextSupport sup = new BeanContextSupport();
- sup.add("obj1");
- sup.add("obj2");
-
- // Convert to array
- Object[] array = sup.copyChildren();
-
- // Check length
- assertEquals("The size of the collection must be 2", 2, array.length);
- }
-
- /**
- * Test method removeBeanContextMembershipListener() with
- * BeanContextMembershipListener parameter.
- * <p>
- */
- public void testRemoveBeanContextMembershipListenerBeanContextMembershipListener() {
- // Create BeanContext and BeanContextMembershipListener instances
- BeanContextSupport sup = new BeanContextSupport();
- BeanContextMembershipListener l = getBeanContextMembershipListener();
- sup.addBeanContextMembershipListener(l);
- sup.removeBeanContextMembershipListener(l);
-
- assertFalse("Listener should not be present", sup.bcmListeners
- .contains(l));
- }
-
- /**
- * Test method addBeanContextMembershipListener() with
- * BeanContextMembershipListener parameter.
- * <p>
- */
- public void testAddBeanContextMembershipListenerBeanContextMembershipListener() {
- // Create BeanContext and BeanContextMembershipListener instances
- BeanContextSupport sup = new BeanContextSupport();
- BeanContextMembershipListener l = getBeanContextMembershipListener();
- sup.addBeanContextMembershipListener(l);
-
- assertTrue("Listener should be present", sup.bcmListeners.contains(l));
- }
-
- /**
- * Test method getBeanContextPeer() with no parameters.
- * <p>
- */
- public void testGetBeanContextPeer() {
- // Create BeanContext instance
- BeanContextSupport sup = new BeanContextSupport();
-
- // The peer and this context should be equal
- assertEquals("The peer and the BeanContext should be equal", sup, sup
- .getBeanContextPeer());
- }
-
- /**
- * Test method vetoableChange() with PropertyChangeEvent parameter.
- * <p>
- */
- // public void testVetoableChangePropertyChangeEvent() {
- // /** @todo: not implemented yet in the class * */
- // Create BeanContext instance
- // BeanContextSupport sup = new BeanContextSupport();
- // sup.vetoableChange(null);
- // }
- /**
- * Test method propertyChange() with PropertyChangeEvent parameter.
- * <p>
- */
- // public void testPropertyChangePropertyChangeEvent() {
- // /** @todo: not implemented yet in the class * */
- // // Create BeanContext instance
- // BeanContextSupport sup = new BeanContextSupport();
- // // sup.propertyChange(null);
- // }
- /**
- * Test method isEmpty() with no parameters.
- * <p>
- */
- public void testIsEmpty() {
- // Create BeanContext instance
- BeanContextSupport sup = new BeanContextSupport();
-
- assertTrue("The collection of children should be empty", sup.isEmpty());
-
- sup.add(new Object());
-
- assertFalse("The collection of children should not be empty", sup
- .isEmpty());
- }
-
- /**
- * Test method clear() with no parameters.
- * <p>
- */
- public void testClear() {
- /*
- * // Create BeanContext instance BeanContextSupport sup = new
- * BeanContextSupport(); // Add a child and then clear sup.add(new
- * Object()); sup.clear();
- *
- * if (!sup.isEmpty()) { fail("The collection of children should be
- * empty"); }
- */
- }
-
- /**
- * Test method size() with no parameters.
- * <p>
- */
- public void testSize() {
- // Create BeanContext instance
- BeanContextSupport sup = new BeanContextSupport();
-
- assertEquals("The size of the collection should be equal to 0", 0, sup
- .size());
-
- sup.add(new Object());
-
- assertEquals("The collection of children should not be empty", 1, sup
- .size());
- }
-
- /**
- * Test method getResourceAsStream() with String, BeanContextChild=null
- * parameters.
- * <p>
- */
- 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.
- * <p>
- */
- public void test_getResourceAsStreamLlava_lang_StringLjava_beans_beancontext_BeanContextChild2() {
- BeanContextSupport obj = new BeanContextSupport();
- try {
- obj.getResourceAsStream(null, null);
- fail("NullPointerException expected");
- } catch (NullPointerException t) {
- }
- }
-
- /**
- * Test method vetoableChange() with PropertyChangeEvent=null parameter.
- * <p>
- *
- * @throws Exception
- */
- public void test_vetoableChangeLjava_beans_PropertyChangeEvent()
- throws Exception {
- BeanContextSupport obj = new BeanContextSupport();
- try {
- obj.vetoableChange(null);
- fail("NullPointerException expected");
- } catch (NullPointerException t) {
- }
- }
-
- /**
- * Test method getResource() with String!=null, BeanContextChild=null
- * parameters.
- * <p>
- */
- public void test_getResourceLjava_lang_StringLjava_beans_beancontext_BeanContextChild() {
- BeanContextSupport obj = new BeanContextSupport();
- try {
- obj.getResource("", null);
- fail("NullPointerException expected");
- } catch (NullPointerException t) {
- }
- }
-
- /**
- * Test method getResource() with String=null, BeanContextChild=null
- * parameters.
- * <p>
- */
- public void test_getResourceLjava_lang_StringLjava_beans_beancontext_BeanContextChild2() {
- BeanContextSupport obj = new BeanContextSupport();
- try {
- obj.getResource(null, null);
- fail("NullPointerException expected");
- } catch (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.
- * <p>
- */
- public static Test suite() {
- return new TestSuite(BeanContextSupportTest.class);
- }
-
-}
diff --git a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/BeanDescriptorTest.java b/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/BeanDescriptorTest.java
deleted file mode 100644
index 77685d8..0000000
--- a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/BeanDescriptorTest.java
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
- * 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.java.beans;
-
-import java.awt.Component;
-import java.beans.BeanDescriptor;
-import java.beans.Customizer;
-import java.beans.PropertyChangeListener;
-import java.util.HashSet;
-
-import junit.framework.TestCase;
-
-import org.apache.harmony.beans.tests.support.mock.MockJavaBean;
-
-/**
- * Unit test for BeanDescriptor.
- */
-public class BeanDescriptorTest extends TestCase {
-
- /*
- * @see TestCase#setUp()
- */
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- }
-
- /*
- * @see TestCase#tearDown()
- */
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-
- /*
- * Class under test for void BeanDescriptor(Class)
- */
- public void testBeanDescriptorClass() {
- String beanName = "BeanDescriptorTest.bean";
- MockJavaBean bean = new MockJavaBean(beanName);
- Class<? extends MockJavaBean> beanClass = bean.getClass();
- BeanDescriptor bd = new BeanDescriptor(beanClass);
-
- assertSame(beanClass, bd.getBeanClass());
- String displayName = beanClass.getName().substring(
- beanClass.getName().lastIndexOf('.') + 1);
- assertEquals(displayName, bd.getDisplayName());
- assertEquals(displayName, bd.getName());
- assertEquals(displayName, bd.getShortDescription());
-
- assertNotNull(bd.attributeNames());
- assertFalse(bd.isExpert());
- assertFalse(bd.isHidden());
- assertFalse(bd.isPreferred());
- }
-
- public void testBeanDescriptorClass_Null() {
- try {
- new BeanDescriptor(null);
- fail("Should throw NullPointerException.");
- } catch (NullPointerException e) {
- }
- }
-
- /*
- * Class under test for void BeanDescriptor(Class, Class)
- */
- public void testBeanDescriptorClassClass() {
- /*
- * String beanName = "BeanDescriptorTest.bean"; MockJavaBean bean = new
- * MockJavaBean(beanName); Class beanClass = bean.getClass(); Customizer
- * customizer = new MyCustomizer(); Class cusClass =
- * customizer.getClass(); BeanDescriptor bd = new
- * BeanDescriptor(beanClass, cusClass);
- *
- * assertSame(beanClass, bd.getBeanClass()); assertSame(cusClass,
- * bd.getCustomizerClass());
- *
- * String displayName = beanClass.getName().substring(
- * beanClass.getName().lastIndexOf('.') + 1); assertEquals(displayName,
- * bd.getDisplayName()); assertEquals(displayName, bd.getName());
- * assertEquals(displayName, bd.getShortDescription());
- *
- * assertNotNull(bd.attributeNames()); assertFalse(bd.isExpert());
- * assertFalse(bd.isHidden()); assertFalse(bd.isPreferred());
- */
- }
-
- public void testBeanDescriptorClassClass_BeanClassNull() {
- /*
- * Class beanClass = null; Customizer customizer = new MyCustomizer();
- * Class cusClass = customizer.getClass(); try { BeanDescriptor bd = new
- * BeanDescriptor(beanClass, cusClass); fail("Should throw
- * NullPointerException"); } catch (NullPointerException e) { }
- */
- }
-
- public void testBeanDescriptorClassClass_CustomizerClassNull() {
- String beanName = "BeanDescriptorTest.bean";
- MockJavaBean bean = new MockJavaBean(beanName);
- Class<? extends MockJavaBean> beanClass = bean.getClass();
- Class<?> cusClass = null;
- BeanDescriptor bd = new BeanDescriptor(beanClass, cusClass);
-
- assertSame(beanClass, bd.getBeanClass());
- assertNull(bd.getCustomizerClass());
-
- String displayName = beanClass.getName().substring(
- beanClass.getName().lastIndexOf('.') + 1);
- assertEquals(displayName, bd.getDisplayName());
- assertEquals(displayName, bd.getName());
- assertEquals(displayName, bd.getShortDescription());
-
- assertNotNull(bd.attributeNames());
- assertFalse(bd.isExpert());
- assertFalse(bd.isHidden());
- assertFalse(bd.isPreferred());
- }
-
- class MyCustomizer extends Component implements Customizer {
-
- private static final long serialVersionUID = 76060185562822787L;
-
- HashSet<PropertyChangeListener> listeners;
-
- Object bean;
-
- public MyCustomizer() {
- this.listeners = new HashSet<PropertyChangeListener>();
- this.bean = null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.Customizer#addPropertyChangeListener(java.beans.PropertyChangeListener)
- */
- @Override
- public void addPropertyChangeListener(PropertyChangeListener listener) {
- this.listeners.add(listener);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.Customizer#removePropertyChangeListener(java.beans.PropertyChangeListener)
- */
- @Override
- public void removePropertyChangeListener(PropertyChangeListener listener) {
- this.listeners.remove(listener);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.Customizer#setObject(java.lang.Object)
- */
- public void setObject(Object bean) {
- this.bean = bean;
- }
- }
-
- /**
- * @tests java.beans.BeanDescriptor#BeanDescriptor( java.lang.Class)
- */
- public void test_Ctor1_NullPointerException() {
- try {
- // Regression for HARMONY-225
- new BeanDescriptor(null);
- fail("No expected NullPointerException");
- } catch (NullPointerException e) {
- }
- }
-
- /**
- * @tests java.beans.BeanDescriptor#BeanDescriptor( java.lang.Class,
- * java.lang.Class)
- */
- public void test_Ctor2_NullPointerException() {
- try {
- // Regression for HARMONY-225
- new BeanDescriptor(null, String.class);
- fail("No expected NullPointerException");
- } catch (NullPointerException e) {
- }
- }
-
- /**
- * The test checks the method testNullaryConstructor()
- */
- public void testNullaryConstructor() {
- BeanDescriptor bd = new BeanDescriptor(String.class);
- assertEquals("String", bd.getName());
- }
-}
diff --git a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/BeansTest.java b/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/BeansTest.java
deleted file mode 100644
index 8db7888..0000000
--- a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/BeansTest.java
+++ /dev/null
@@ -1,598 +0,0 @@
-/*
- * 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.java.beans;
-
-import java.applet.Applet;
-import java.awt.Component;
-import java.beans.AppletInitializer;
-import java.beans.Beans;
-import java.beans.beancontext.BeanContext;
-import java.beans.beancontext.BeanContextSupport;
-import java.io.Externalizable;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.io.Serializable;
-import java.net.URL;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.apache.harmony.beans.tests.support.SampleBean;
-import org.apache.harmony.beans.tests.support.mock.CorruptedSerBean;
-import org.apache.harmony.beans.tests.support.mock.MockAppletInitializer;
-import org.apache.harmony.beans.tests.support.mock.MockJavaBean;
-import org.apache.harmony.beans.tests.support.mock.WrongSerBean;
-
-/**
- * Unit test for java.beans.Beans
- */
-public class BeansTest extends TestCase {
-
- private final String MOCK_JAVA_BEAN2 = "tests.api.java.beans.mock.MockJavaBean2";
-
- private final String MOCK_JAVA_BEAN2_FILE = "binary/java/beans/mock/MockJavaBean2.bin";
-
- private final String MOCK_JAVA_BEAN2_SFILE = "serialization/java/beans/mock/MockJavaBean2.ser";
-
- /*
- * public Beans()
- */
- public void testBeans() {
- new Beans();
- }
-
- /*
- * public static Object getInstanceOf(Object bean, Class targetType)
- */
- public void testGetInstanceOf() {
- MockJavaBean bean = new MockJavaBean();
- Class<Component> type = Component.class;
- Object obj = Beans.getInstanceOf(bean, type);
-
- assertSame(bean, obj);
- }
-
- public void testGetInstanceOf_BeanNull() {
- Class<Component> type = Component.class;
- Object obj = Beans.getInstanceOf(null, type);
-
- assertNull(obj);
- }
-
- public void testGetInstanceOf_TargetTypeNull() {
- MockJavaBean bean = new MockJavaBean();
- Object obj = Beans.getInstanceOf(bean, null);
-
- assertSame(bean, obj);
- }
-
- /*
- * Class under test for Object instantiate(ClassLoader, String)
- */
- public void testInstantiateClassLoaderString_Class() throws Exception {
-
- ClassLoader loader = new BinClassLoader();
- Object bean = Beans.instantiate(loader, MOCK_JAVA_BEAN2);
-
- assertEquals("as_class", (String) bean.getClass().getMethod(
- "getPropertyOne", (Class[]) null).invoke(bean, (Object[]) null));
- assertSame(loader, bean.getClass().getClassLoader());
- }
-
- public void testInstantiateClassLoaderString_Ser() throws Exception {
- ClassLoader loader = new SerClassLoader();
- Object bean = Beans.instantiate(loader, MOCK_JAVA_BEAN2);
-
- assertEquals("as_object", (String) bean.getClass().getMethod(
- "getPropertyOne", (Class[]) null).invoke(bean, (Object[]) null));
- assertSame(loader, bean.getClass().getClassLoader());
- }
-
- public void testInstantiateClassLoaderString_ClassLoaderNull()
- throws Exception {
- Object bean = Beans.instantiate(null, MockJavaBean.class.getName());
-
- assertEquals(bean.getClass(), MockJavaBean.class);
- assertSame(ClassLoader.getSystemClassLoader(), bean.getClass()
- .getClassLoader());
- }
-
- public void testInstantiateClassLoaderString_BeanNameNull()
- throws Exception {
- try {
- Beans.instantiate(null, null);
- fail("Should throw NullPointerException");
- } catch (NullPointerException e) {
- }
- }
-
- /*
- * Class under test for Object instantiate(ClassLoader, String, BeanContext)
- */
- public void testInstantiateClassLoaderStringBeanContext_Class()
- throws Exception {
-
- ClassLoader loader = new BinClassLoader();
- BeanContext context = new BeanContextSupport();
- Object bean = Beans.instantiate(loader, MOCK_JAVA_BEAN2, context);
-
- assertEquals("as_class", (String) bean.getClass().getMethod(
- "getPropertyOne", (Class[]) null).invoke(bean, (Object[]) null));
- assertSame(loader, bean.getClass().getClassLoader());
- assertTrue(context.contains(bean));
- }
-
- public void testInstantiateClassLoaderStringBeanContext_Ser()
- throws Exception {
- ClassLoader loader = new SerClassLoader();
- BeanContext context = new BeanContextSupport();
- Object bean = Beans.instantiate(loader, MOCK_JAVA_BEAN2, context);
-
- assertEquals("as_object", (String) bean.getClass().getMethod(
- "getPropertyOne", (Class[]) null).invoke(bean, (Object[]) null));
- assertSame(loader, bean.getClass().getClassLoader());
- assertTrue(context.contains(bean));
- }
-
- public void testInstantiateClassLoaderStringBeanContext_ClassLoaderNull()
- throws Exception {
- BeanContext context = new BeanContextSupport();
- Object bean = Beans.instantiate(null, MockJavaBean.class.getName(),
- context);
-
- assertEquals(bean.getClass(), MockJavaBean.class);
- assertSame(ClassLoader.getSystemClassLoader(), bean.getClass()
- .getClassLoader());
- assertTrue(context.contains(bean));
- }
-
- public void testInstantiateClassLoaderStringBeanContext_BeanNameNull()
- throws Exception {
- BeanContext context = new BeanContextSupport();
- ClassLoader loader = createSpecificClassLoader();
-
- try {
- Beans.instantiate(loader, null, context);
- fail("Should throw NullPointerException.");
- } catch (NullPointerException e) {
- }
- }
-
- public void testInstantiateClassLoaderStringBeanContext_ContextNull()
- throws Exception {
- ClassLoader loader = createSpecificClassLoader();
- Object bean = Beans.instantiate(loader, MockJavaBean.class.getName(),
- null);
-
- assertEquals(bean.getClass(), MockJavaBean.class);
- }
-
- /*
- * Class under test for Object instantiate(ClassLoader, String, BeanContext,
- * AppletInitializer)
- */
- public void testInstantiateClassLoaderStringBeanContextAppletInitializer_Class()
- throws Exception {
- ClassLoader loader = new BinClassLoader();
- BeanContext context = new BeanContextSupport();
- AppletInitializer appInit = new MockAppletInitializer();
- Object bean = Beans.instantiate(loader, MOCK_JAVA_BEAN2, context,
- appInit);
-
- assertEquals("as_class", (String) bean.getClass().getMethod(
- "getPropertyOne", (Class[]) null).invoke(bean, (Object[]) null));
- assertSame(loader, bean.getClass().getClassLoader());
- assertTrue(context.contains(bean));
- }
-
- public void testInstantiateClassLoaderStringBeanContextAppletInitializer_Ser()
- throws Exception {
-
- ClassLoader loader = new SerClassLoader();
- BeanContext context = new BeanContextSupport();
- AppletInitializer appInit = new MockAppletInitializer();
- Object bean = Beans.instantiate(loader, MOCK_JAVA_BEAN2, context,
- appInit);
-
- assertEquals("as_object", (String) bean.getClass().getMethod(
- "getPropertyOne", (Class[]) null).invoke(bean, (Object[]) null));
- assertSame(loader, bean.getClass().getClassLoader());
- assertTrue(context.contains(bean));
- }
-
- public void testInstantiateClassLoaderStringBeanContextAppletInitializer_LoaderNull()
- throws Exception {
- String beanName = "org.apache.harmony.beans.tests.support.mock.MockJavaBean";
- BeanContext context = new BeanContextSupport();
- AppletInitializer appInit = new MockAppletInitializer();
-
- Object bean = Beans.instantiate(null, beanName, context, appInit);
-
- assertSame(ClassLoader.getSystemClassLoader(), bean.getClass()
- .getClassLoader());
- assertEquals(beanName, bean.getClass().getName());
- assertTrue(context.contains(bean));
- }
-
- public void testInstantiateClassLoaderStringBeanContextAppletInitializer_BeanNull()
- throws Exception {
- ClassLoader loader = createSpecificClassLoader();
- BeanContext context = new BeanContextSupport();
- AppletInitializer appInit = new MockAppletInitializer();
-
- try {
- Beans.instantiate(loader, null, context, appInit);
- fail("Should throw NullPointerException.");
- } catch (NullPointerException e) {
- }
- }
-
- public void testInstantiateClassLoaderStringBeanContextAppletInitializer_ContextNull()
- throws Exception {
- ClassLoader loader = createSpecificClassLoader();
- String beanName = "org.apache.harmony.beans.tests.support.mock.MockJavaBean";
- AppletInitializer appInit = new MockAppletInitializer();
- Object bean = Beans.instantiate(loader, beanName, null, appInit);
-
- assertSame(ClassLoader.getSystemClassLoader(), bean.getClass()
- .getClassLoader());
- assertEquals(beanName, bean.getClass().getName());
- }
-
- public void testInstantiateClassLoaderStringBeanContextAppletInitializer_InitializerNull()
- throws Exception {
- ClassLoader loader = createSpecificClassLoader();
- String beanName = "org.apache.harmony.beans.tests.support.mock.MockJavaBean";
- BeanContext context = new BeanContextSupport();
- Object bean = Beans.instantiate(loader, beanName, context, null);
-
- assertSame(ClassLoader.getSystemClassLoader(), bean.getClass()
- .getClassLoader());
- assertEquals(beanName, bean.getClass().getName());
- }
-
- // public void
- // testInstantiateClassLoaderStringBeanContextAppletInitializer_AppletBean()
- // throws IOException, ClassNotFoundException {
- // String beanName = MockAppletBean.class.getName(); BeanContext context =
- // new BeanContextSupport(); MockAppletInitializer appInit = new
- // MockAppletInitializer(); MockAppletBean bean = (MockAppletBean)
- // Beans.instantiate(null, beanName, context, appInit);
- // assertSame(ClassLoader.getSystemClassLoader(), bean.getClass()
- // .getClassLoader()); assertEquals(beanName, bean.getClass().getName());
- // assertTrue(context.contains(bean));
- // assertTrue(appInit.activateHasBeenCalled());
- // assertTrue(appInit.initializeHasBeenCalled());
- // assertTrue(bean.initHasBeenCalled());
- // }
-
- // public void
- // testInstantiateClassLoaderStringBeanContextAppletInitializer_AppletBean_SER()
- // throws IOException, ClassNotFoundException {
- //
- // String beanName = MockAppletBean2.class.getName(); BeanContext context =
- // new BeanContextSupport(); MockAppletInitializer appInit = new
- // MockAppletInitializer(); MockAppletBean2 bean = (MockAppletBean2)
- // Beans.instantiate(null, beanName, context, appInit);
- // assertSame(ClassLoader.getSystemClassLoader(), bean.getClass()
- // .getClassLoader()); assertEquals(beanName, bean.getClass().getName());
- // assertTrue(context.contains(bean));
- // assertTrue(appInit.activateHasBeenCalled());
- // assertTrue(appInit.initializeHasBeenCalled());
- // assertFalse(bean.initHasBeenCalled());
- //
- // }
-
- // public void
- // testInstantiateClassLoaderStringBeanContextAppletInitializer_AppletBean_2()
- // throws IOException, ClassNotFoundException {
- //
- // String beanName = MockAppletBean.class.getName(); BeanContext context =
- // new BeanContextSupport(); MockAppletInitializer appInit = new
- // MockAppletInitializer(); MockAppletBean bean = (MockAppletBean)
- // Beans.instantiate(null, beanName, context, null);
- //
- // }
-
- /*
- * public static boolean isInstanceOf(Object bean, Class targetType)
- */
- public void testIsInstanceOf() {
- MockJavaBean bean = new MockJavaBean();
-
- assertTrue(Beans.isInstanceOf(bean, Serializable.class));
- }
-
- public void testIsInstanceOf_BeanNull() {
- try {
- Beans.isInstanceOf(null, Serializable.class);
- fail("Should throw NullPointerException.");
- } catch (NullPointerException e) {
- }
- }
-
- public void testIsInstanceOf_TypeNull() {
- MockJavaBean bean = new MockJavaBean();
- assertFalse(Beans.isInstanceOf(bean, null));
- }
-
- public void testIsInstanceOf_TypeInvalid() {
- MockJavaBean bean = new MockJavaBean();
- assertFalse(Beans.isInstanceOf(bean, String.class));
- }
-
- public void testSetDesignTime() {
- boolean value = Beans.isDesignTime();
- try {
- Beans.setDesignTime(true);
- assertTrue(Beans.isDesignTime());
-
- Beans.setDesignTime(false);
- assertFalse(Beans.isDesignTime());
- } finally {
- Beans.setDesignTime(value);
- }
- }
-
- public void testSetGuiAvailable() {
- boolean value = Beans.isGuiAvailable();
- try {
- Beans.setGuiAvailable(true);
- assertTrue(Beans.isGuiAvailable());
-
- Beans.setGuiAvailable(false);
- assertFalse(Beans.isGuiAvailable());
- } finally {
- Beans.setGuiAvailable(value);
- }
- }
-
- public void testIsGuiAvailableDefault() {
- assertTrue("GUI is available by default", Beans.isGuiAvailable());
- }
-
- /**
- * The test checks the method instantiate() using specific classloader for
- * class loading
- */
- public void testLoadBySpecificClassLoader() throws Exception {
- String beanName = "org.apache.harmony.beans.tests.support.SampleBean";
-
- ClassLoader cls = createSpecificClassLoader();
- Object bean = Beans.instantiate(cls, beanName);
- SampleBean sampleBean;
-
- assertNotNull(bean);
- assertEquals(bean.getClass(), SampleBean.class);
-
- sampleBean = (SampleBean) bean;
- assertNull(sampleBean.getText());
- }
-
- /**
- * The test checks the method instantiate() using default classloader for
- * class loading
- */
- public void testLoadByDefaultClassLoader() throws Exception {
- String beanName = "org.apache.harmony.beans.tests.support.SampleBean";
-
- Object bean = Beans.instantiate(null, beanName);
- SampleBean sampleBean;
-
- assertNotNull(bean);
- assertEquals(bean.getClass(), SampleBean.class);
-
- sampleBean = (SampleBean) bean;
- assertNull(sampleBean.getText());
- }
-
- // regression test for HARMONY-358
- public void testInstantiate() throws Exception {
- try {
- Class.forName(this.getClass().getName(), true, null);
- fail("This test is designed to run from classpath rather then from bootclasspath");
- } catch (ClassNotFoundException ok) {
- }
- assertNotNull(Beans.instantiate(null, this.getClass().getName()));
- }
-
- // regression test for HARMONY-402
- public void test_isInstanceOf_Object_Class() {
- ObjectBean bean = new ObjectBean();
- // correct non-null targetType
- Class<Externalizable> targetType = Externalizable.class;
-
- assertTrue(Beans.isInstanceOf(bean, targetType));
-
- // null targetType
- targetType = null;
- assertFalse(Beans.isInstanceOf(bean, targetType));
- }
-
- public void test_instantiate_with_empty_serialization_file()
- throws Exception {
- final String BEANS_NAME = "org/apache/harmony/beans/tests/support/mock/EmptySerBean.ser";
-
- try {
- Beans.instantiate(null, BEANS_NAME);
- fail("should throw ClassNotFoundException.");
- } catch (ClassNotFoundException e) {
- // expected
- }
- }
-
- // Regression for HARMONY-3777
- public void test_instantiate_with_applet() throws Exception {
- Applet applet = (Applet) Beans.instantiate(null, "java.applet.Applet");
- assertNotNull(applet.getAppletContext());
- assertTrue(applet.isActive());
- }
-
- /*
- * Test instantiate a bean with corrupted .ser file. First failed to create
- * an instance by deserialize from a corrupted .ser file, then successfully
- * load the class and create an instance of it.
- */
- public void test_instantiate_withCorruptedSer() throws IOException,
- ClassNotFoundException {
- Object bean = Beans.instantiate(null,
- "org.apache.harmony.beans.tests.support.mock.CorruptedSerBean");
- assertTrue(bean instanceof CorruptedSerBean);
- }
-
- /*
- * Test instantiate a bean with wrong .ser file, which means the definition
- * of the class changes after .ser file is created. First failed to create
- * an instance by deserialize from a corrupted .ser file, which will cause a
- * InvalidClassException, then successfully load the class and create an
- * instance of it.
- */
- public void test_instantiate_withWrongSer() throws IOException,
- ClassNotFoundException {
- Object bean = Beans.instantiate(null,
- "org.apache.harmony.beans.tests.support.mock.WrongSerBean");
- assertTrue(bean instanceof WrongSerBean);
- }
-
- /*
- * Test instantiate a bean with wrong but not corrupted .ser file First
- * failed to create an instance by deserialize from a wrong .ser file, which
- * will cause a ClassNotFoundException.
- */
- public void test_instantiate_ClassNotFoundExceptionThrowing()
- throws IOException {
- ClassLoader loader = new WrongSerClassLoader();
- try {
- Beans
- .instantiate(loader,
- "org.apache.harmony.beans.tests.support.mock.WrongSerBean2");
- fail("Should throw a ClassNotFoundException");
- } catch (ClassNotFoundException ex) {
- // expected
- }
- }
-
- /*
- * Test instantiate bean with corrupted .ser file and wrong class name. This
- * will cause an IOException.
- */
- public void test_instantiate_IOExceptionThrowing()
- throws ClassNotFoundException {
- ClassLoader loader = new CorruptedSerClassLoader();
- try {
- Beans.instantiate(loader, "NotExistBean2");
- fail("Should throw a IOException");
- } catch (IOException ex) {
- // expected
- }
- }
-
- public static Test suite() {
- return new TestSuite(BeansTest.class);
- }
-
- private ClassLoader createSpecificClassLoader() {
- return new ClassLoader() {
- };
- }
-
- private class ObjectBean implements Externalizable {
-
- private static final long serialVersionUID = 637071583755213744L;
-
- public void writeExternal(ObjectOutput out) {
- };
-
- public void readExternal(ObjectInput in) {
- };
- }
-
- private class BinClassLoader extends ClassLoader {
-
- @Override
- protected Class<?> findClass(String name) throws ClassNotFoundException {
- if (!MOCK_JAVA_BEAN2.equals(name)) {
- return super.findClass(name);
- }
-
- try {
- // makes sense to get actual file size?
- byte[] buf = new byte[10000];
-
- InputStream in = getResourceAsStream(MOCK_JAVA_BEAN2_FILE);
-
- int sz = 0;
-
- // read whole file
- int read;
-
- while ((read = in.read(buf, sz, buf.length - sz)) >= 0) {
- sz += read;
- }
-
- return defineClass(MOCK_JAVA_BEAN2, buf, 0, sz);
- } catch (IOException e) {
- throw (ClassNotFoundException) new ClassNotFoundException(e
- .toString()).initCause(e);
- }
- }
- }
-
- private class SerClassLoader extends BinClassLoader {
-
- private final String MOCK_JAVA_BEAN2_SNAME = MOCK_JAVA_BEAN2.replace(
- '.', '/')
- + ".ser";;
-
- @Override
- protected URL findResource(String name) {
- if (!MOCK_JAVA_BEAN2_SNAME.equals(name)) {
- return super.findResource(name);
- }
-
- return getResource(MOCK_JAVA_BEAN2_SFILE);
- }
- }
-
- /*
- * A classloader for loading NotExistBean.ser, of which coresponding
- * NotExistBean.java file is deleted.
- */
- private class WrongSerClassLoader extends ClassLoader {
- @Override
- protected URL findResource(String name) {
- return getResource("org/apache/harmony/beans/tests/support/mock/NotExistBean.ser");
- }
- }
-
- /*
- * A classloader for loading corrupted .ser file.
- */
- private class CorruptedSerClassLoader extends ClassLoader {
- @Override
- protected URL findResource(String name) {
- return getResource("org/apache/harmony/beans/tests/support/mock/CorruptedSerBean.ser");
- }
- }
-
-}
diff --git a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/CustomizedPersistenceDelegateTest.java b/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/CustomizedPersistenceDelegateTest.java
deleted file mode 100644
index 6e38ff0..0000000
--- a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/CustomizedPersistenceDelegateTest.java
+++ /dev/null
@@ -1,289 +0,0 @@
-/*
- * 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.java.beans;
-
-import java.beans.Encoder;
-import java.beans.Expression;
-import java.beans.PersistenceDelegate;
-import java.beans.Statement;
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.util.Arrays;
-
-import junit.framework.TestCase;
-
-/**
- * Test some customized persistence delegate, not including the AWT and SWING
- * ones.
- */
-public class CustomizedPersistenceDelegateTest extends TestCase {
-
- private MockEncoder enc = null;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- enc = new MockEncoder();
- }
-
- public void testStringPD() {
- enc.writeObject("");
- assertEquals("", enc.get(""));
- }
-
- public void testArrayPD() {
- Integer[] ia = new Integer[] { new Integer(1), new Integer(11100) };
- enc.writeObject(ia);
- assertTrue(Arrays.equals(ia, (Integer[]) enc.get(ia)));
- }
-
- public void testClassPD() {
- enc.writeObject(Integer.class);
- assertSame(Integer.class, enc.get(Integer.class));
- enc.writeObject(String.class);
- assertSame(String.class, enc.get(String.class));
- enc.writeObject(Class.class);
- assertSame(Class.class, enc.get(Class.class));
- }
-
- /*
- * Test the PD for proxy classes. Please note that this testcase has the
- * side effect that a PD for the system classloader is registered in the
- * encoder and may affect other testcases because the registration is
- * static.
- */
- public void testProxyPD() throws Exception {
- MyInterface o = (MyInterface) Proxy.newProxyInstance(ClassLoader
- .getSystemClassLoader(), new Class[] { MyInterface.class },
- new MyHandler(1));
- PersistenceDelegate pd = new PersistenceDelegate() {
-
- @Override
- public Expression instantiate(Object o, Encoder e) {
- return new Expression(o, ClassLoader.class,
- "getSystemClassLoader", null);
- }
- };
- enc.setPersistenceDelegate(ClassLoader.getSystemClassLoader()
- .getClass(), pd);
- enc.writeObject(o);
- MyInterface o2 = (MyInterface) enc.get(o);
- assertEquals(o.getProp(), o2.getProp());
- }
-
- public void testPrimitivePD() {
- // int
- int[] ia = new int[] { 1, 2 };
- enc.writeObject(ia);
- assertTrue(Arrays.equals(ia, (int[]) enc.get(ia)));
- ia = new int[0];
- enc.writeObject(ia);
- assertTrue(Arrays.equals(ia, (int[]) enc.get(ia)));
-
- // short
- short[] sa = new short[] { 1, 2 };
- enc.writeObject(sa);
- assertTrue(Arrays.equals(sa, (short[]) enc.get(sa)));
- sa = new short[0];
- enc.writeObject(sa);
- assertTrue(Arrays.equals(sa, (short[]) enc.get(sa)));
-
- // long
- long[] la = new long[] { 1, 2 };
- enc.writeObject(la);
- assertTrue(Arrays.equals(la, (long[]) enc.get(la)));
- la = new long[0];
- enc.writeObject(la);
- assertTrue(Arrays.equals(la, (long[]) enc.get(la)));
-
- // float
- float[] fa = new float[] { 1, 2 };
- enc.writeObject(fa);
- assertTrue(Arrays.equals(fa, (float[]) enc.get(fa)));
- fa = new float[0];
- enc.writeObject(fa);
- assertTrue(Arrays.equals(fa, (float[]) enc.get(fa)));
-
- // double
- double[] da = new double[] { -1, 2.0 };
- enc.writeObject(da);
- assertTrue(Arrays.equals(da, (double[]) enc.get(da)));
- da = new double[0];
- enc.writeObject(da);
- assertTrue(Arrays.equals(da, (double[]) enc.get(da)));
-
- // boolean
- boolean[] ba = new boolean[] { true, false };
- enc.writeObject(ba);
- assertTrue(Arrays.equals(ba, (boolean[]) enc.get(ba)));
- ba = new boolean[0];
- enc.writeObject(ba);
- assertTrue(Arrays.equals(ba, (boolean[]) enc.get(ba)));
-
- // char
- char[] ca = new char[] { 'c', 'b' };
- enc.writeObject(ca);
- assertTrue(Arrays.equals(ca, (char[]) enc.get(ca)));
- ca = new char[0];
- enc.writeObject(ca);
- assertTrue(Arrays.equals(ca, (char[]) enc.get(ca)));
-
- // byte
- byte[] bba = new byte[] { 112, 12 };
- enc.writeObject(bba);
- assertTrue(Arrays.equals(bba, (byte[]) enc.get(bba)));
- bba = new byte[0];
- enc.writeObject(bba);
- assertTrue(Arrays.equals(bba, (byte[]) enc.get(bba)));
- }
-
- public void testMethodPD() throws Exception {
- Method m = Object.class.getMethod("getClass", (Class[]) null);
- enc.writeObject(m);
- assertEquals(m, enc.get(m));
- }
-
- public void testFieldPD() throws Exception {
- Field f = MyHandler.class.getField("i");
- enc.writeObject(f);
- assertEquals(f, enc.get(f));
- }
-
- static class MockEncoder extends Encoder {
-
- @Override
- public void writeObject(Object o) {
- // System.out.println("write object: " + o);
- super.writeObject(o);
- }
-
- @Override
- public PersistenceDelegate getPersistenceDelegate(Class<?> type) {
- // System.out.println("getPersistenceDelegate for " + type);
- return super.getPersistenceDelegate(type);
- }
-
- @Override
- public void writeExpression(Expression oldExp) {
- // System.out.println("Expression: " + oldExp);
- super.writeExpression(oldExp);
- }
-
- @Override
- public void writeStatement(Statement oldStat) {
- // System.out.println("Statement: " + oldStat);
- if (oldStat.getMethodName().equals("add")) {
- new Throwable().printStackTrace();
- }
- super.writeStatement(oldStat);
- }
-
- @Override
- public Object get(Object o) {
- // StackTraceElement[] stack = new Throwable().getStackTrace();
- // new Throwable().printStackTrace();
- // System.out.println("get object: " + o);
- return super.get(o);
- }
- }
-
- /*
- * Interface for the proxy class.
- */
- public static interface MyInterface {
-
- void setProp(int i);
-
- int getProp();
- }
-
- /*
- * Handler for the proxy class.
- */
- public static class MyHandler implements InvocationHandler {
-
- public int i;
-
- public MyHandler() {
- this.i = 0;
- }
-
- public MyHandler(int i) {
- this.i = i;
- }
-
- public Object invoke(Object proxy, Method method, Object[] args)
- throws Throwable {
- if (method.getName().equals("setProp")) {
- this.i = ((Integer) args[0]).intValue();
- return null;
- } else if (method.getName().equals("getProp")) {
- return new Integer(i);
- } else if (method.getName().equals("hashCode")) {
- return Integer.valueOf(this.hashCode() + 113);
- } else if (method.getName().equals("equals") && args.length == 1) {
- return Boolean.valueOf(proxy.getClass().getName().equals(
- args[0].getClass().getName()));
- }
- return null;
- }
-
- public void setI(int i) {
- this.i = i;
- }
-
- public int getI() {
- return this.i;
- }
- }
-
- public static class MockBean {
-
- String str;
-
- public MockBean() {
- this.str = "";
- }
-
- public String getStr() {
- return str;
- }
-
- public void addStr(String s) {
- str += s;
- }
-
- public MockBean side() {
- str += "side";
- return new MockBean();
- }
-
- public MockBean side2() {
- str += "side2";
- return new MockBean();
- }
-
- @Override
- public String toString() {
- return str;
- }
- }
-
-}
diff --git a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/DefaultPersistenceDelegateTest.java b/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/DefaultPersistenceDelegateTest.java
deleted file mode 100644
index 55b4033..0000000
--- a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/DefaultPersistenceDelegateTest.java
+++ /dev/null
@@ -1,1226 +0,0 @@
-/*
- * 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.java.beans;
-
-import java.beans.DefaultPersistenceDelegate;
-import java.beans.Encoder;
-import java.beans.ExceptionListener;
-import java.beans.Expression;
-import java.beans.Introspector;
-import java.beans.PersistenceDelegate;
-import java.beans.PropertyDescriptor;
-import java.beans.SimpleBeanInfo;
-import java.beans.Statement;
-import java.util.Iterator;
-import java.util.Vector;
-
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.apache.harmony.beans.tests.support.mock.MockFoo;
-import org.apache.harmony.beans.tests.support.mock.MockFoo2;
-import org.apache.harmony.beans.tests.support.mock.MockFooLabel;
-import org.apache.harmony.beans.tests.support.mock.MockFooStop;
-
-import tests.util.CallVerificationStack;
-
-/**
- * Tests the class java.beans.DefaultPersistenceDelegate TODO refactor the class
- * and remove all references to CallVerificationStack
- */
-public class DefaultPersistenceDelegateTest extends TestCase {
-
- public DefaultPersistenceDelegateTest() {
- }
-
- public DefaultPersistenceDelegateTest(String s) {
- super(s);
- }
-
- /*
- * @see TestCase#setUp()
- */
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- Introspector.flushCaches();
- CallVerificationStack.getInstance().clear();
- }
-
- public static TestSuite suite() {
- // TestSuite suite = new TestSuite();
- TestSuite suite = new TestSuite(DefaultPersistenceDelegateTest.class);
-
- // suite.addTest(new DefaultPersistenceDelegateTest(
- // "testInitialize_NotRegularGetter"));
- return suite;
- }
-
- /*
- * Test the default constructor.
- */
- public void testConstructor_Default() {
- new DefaultPersistenceDelegate();
- }
-
- /*
- * Test the constructor with normal property names.
- */
- public void testConstructor_StringArray_Normal() {
- new DefaultPersistenceDelegate(new String[] { "prop1", "", null });
- }
-
- /*
- * Test the constructor with an empty string array.
- */
- public void testConstructor_StringArray_Empty() {
- new DefaultPersistenceDelegate(new String[0]);
- }
-
- /*
- * Test the constructor with null.
- */
- public void testConstructor_StringArray_Null() {
- new DefaultPersistenceDelegate(null);
- }
-
- /*
- * Test instantiate() under normal conditions: two properties, valid getter
- * method but no setter method and no such a constructor requiring the two
- * properties.
- */
- public void testInstantiate_Normal() throws Exception {
- MockPersistenceDelegate pd = new MockPersistenceDelegate(new String[] {
- "prop1", "prop2" });
- MockBean b = new MockBean();
- Encoder enc = new Encoder();
- b.setAll("bean1", 2);
- Expression e = pd.instantiate(b, enc);
- assertSame(b, e.getValue());
- assertSame(MockBean.class, e.getTarget());
- assertEquals("new", e.getMethodName());
- assertSame("bean1", e.getArguments()[0]);
- assertEquals(new Integer(2), e.getArguments()[1]);
- }
-
- /*
- * Test instantiate() with null instance.
- */
- public void testInstantiate_NullInstance() throws Exception {
- MockPersistenceDelegate pd = new MockPersistenceDelegate(new String[] {
- "prop1", "prop2" });
- Encoder enc = new Encoder();
- try {
- pd.instantiate(null, enc);
- fail("Should throw NullPointerException!");
- } catch (NullPointerException ex) {
- // expected
- }
- }
-
- /*
- * Test instantiate() with null encoder.
- */
- public void testInstantiate_NullEncoder() throws Exception {
- MockPersistenceDelegate pd = new MockPersistenceDelegate(new String[] {
- "prop1", "prop2" });
- MockBean b = new MockBean();
- b.setAll("bean1", 2);
- Expression e = pd.instantiate(b, null);
- assertSame(b, e.getValue());
- assertSame(MockBean.class, e.getTarget());
- assertEquals("new", e.getMethodName());
- assertSame("bean1", e.getArguments()[0]);
- assertEquals(new Integer(2), e.getArguments()[1]);
- assertEquals(2, e.getArguments().length);
- }
-
- /*
- * Test instantiate() with null property name.
- */
- public void testInstantiate_NullProperty() throws Exception {
- MockPersistenceDelegate pd = new MockPersistenceDelegate(new String[] {
- "prop1", null });
- MockBean b = new MockBean();
- b.setAll("bean1", 2);
- pd.instantiate(b, new Encoder());
-
- pd = new MockPersistenceDelegate(new String[] {
- "prop1", null, "prop2"});
- MockBean b2 = new MockBean();
- b2.setAll("bean1", 2);
- pd.instantiate(b2, new Encoder());
- }
-
- /*
- * Test instantiate() with empty property name.
- */
- public void testInstantiate_EmptyProperty() throws Exception {
- MockPersistenceDelegate pd = new MockPersistenceDelegate(new String[] {
- "prop1", "" });
- MockBean b = new MockBean();
- b.setAll("bean1", 2);
- pd.instantiate(b, null);
- }
-
- /*
- * Test instantiate() with no property.
- */
- public void testInstantiate_NoProperty() throws Exception {
- MockPersistenceDelegate pd = new MockPersistenceDelegate();
- MockBean b = new MockBean();
- b.setAll("bean1", 2);
- Expression e = pd.instantiate(b, new Encoder());
- assertSame(b, e.getValue());
- assertSame(MockBean.class, e.getTarget());
- assertEquals("new", e.getMethodName());
- assertEquals(0, e.getArguments().length);
- }
-
- /*
- * Test instantiate() with one normal property name, but non-existing getter
- * method.
- */
- public void testInstantiate_NonExistingGetter() throws Exception {
- MockPersistenceDelegate pd = new MockPersistenceDelegate(new String[] {
- "prop1", "non_existing" });
- MockBean b = new MockBean();
- b.setAll("bean1", 2);
- Encoder enc = new Encoder();
- ExceptionListener el = new ExceptionListener() {
- public void exceptionThrown(Exception e) {
- CallVerificationStack.getInstance().push(e);
- }
- };
- enc.setExceptionListener(el);
- Expression e = pd.instantiate(b, enc);
- assertSame(b, e.getValue());
- assertSame(MockBean.class, e.getTarget());
- assertEquals("new", e.getMethodName());
- assertEquals(2, e.getArguments().length);
- assertSame(b.getProp1(), e.getArguments()[0]);
- assertSame(null, e.getArguments()[1]);
- assertTrue(CallVerificationStack.getInstance().pop() instanceof Exception);
-
- enc.setExceptionListener(null);
- assertNotNull(enc.getExceptionListener());
- e = pd.instantiate(b, enc);
- assertSame(b, e.getValue());
- assertSame(MockBean.class, e.getTarget());
- assertEquals("new", e.getMethodName());
- assertEquals(2, e.getArguments().length);
- assertSame(b.getProp1(), e.getArguments()[0]);
- assertSame(null, e.getArguments()[1]);
- }
-
- /*
- * Test instantiate() with one normal property name, but non-existing getter
- * method, and null encoder.
- */
- public void testInstantiate_NonExistingGetterNulEncoder() throws Exception {
- MockPersistenceDelegate pd = new MockPersistenceDelegate(new String[] {
- "prop1", "non_existing" });
- MockBean b = new MockBean();
- b.setAll("bean1", 2);
- try {
- pd.instantiate(b, null);
- fail("Should throw NullPointerException!");
- } catch (NullPointerException ex) {
- // expected
- }
- }
-
- /*
- * Test instantiate() with one normal property name, but an invalid getter
- * method (requiring an argument, for instance).
- */
- public void testInstantiate_InvalidGetter() throws Exception {
- MockPersistenceDelegate pd = new MockPersistenceDelegate(new String[] {
- "prop1", "prop4" });
- MockBean b = new MockBean();
- b.setAll("bean1", 2);
- Expression e = pd.instantiate(b, new Encoder());
- assertSame(b, e.getValue());
- assertSame(MockBean.class, e.getTarget());
- assertEquals("new", e.getMethodName());
- assertEquals(2, e.getArguments().length);
- assertSame(b.getProp1(), e.getArguments()[0]);
- assertSame(null, e.getArguments()[1]);
- }
-
- /*
- * Test instantiate() with one normal property name, but a getter method
- * that will throw an exception.
- */
- public void testInstantiate_ExceptionalGetter() throws Exception {
- MockPersistenceDelegate pd = new MockPersistenceDelegate(new String[] {
- "prop1", "prop5" });
- MockBean b = new MockBean();
- b.setAll("bean1", 2);
- Expression e = pd.instantiate(b, new Encoder());
- assertSame(b, e.getValue());
- assertSame(MockBean.class, e.getTarget());
- assertEquals("new", e.getMethodName());
- assertEquals(2, e.getArguments().length);
- assertSame(b.getProp1(), e.getArguments()[0]);
- assertSame(null, e.getArguments()[1]);
- }
-
- /*
- * Test instantiate() with one normal property name, but a getter method
- * that will throw an error.
- */
- public void testInstantiate_ErrorGetter() throws Exception {
- MockPersistenceDelegate pd = new MockPersistenceDelegate(new String[] {
- "prop1", "prop7" });
- MockBean b = new MockBean();
- b.setAll("bean1", 2);
- Expression e = pd.instantiate(b, new Encoder());
- assertSame(b, e.getValue());
- assertSame(MockBean.class, e.getTarget());
- assertEquals("new", e.getMethodName());
- assertEquals(2, e.getArguments().length);
- assertSame(b.getProp1(), e.getArguments()[0]);
- assertSame(null, e.getArguments()[1]);
- }
-
- /*
- * Test instantiate() with one normal property name, but a private getter
- * method.
- */
- public void testInstantiate_PrivateGetter() throws Exception {
- MockPersistenceDelegate pd = new MockPersistenceDelegate(new String[] {
- "prop1", "prop6" });
- MockBean b = new MockBean();
- b.setAll("bean1", 2);
- Expression e = pd.instantiate(b, new Encoder());
- assertSame(b, e.getValue());
- assertSame(MockBean.class, e.getTarget());
- assertEquals("new", e.getMethodName());
- assertEquals(2, e.getArguments().length);
- assertSame(b.getProp1(), e.getArguments()[0]);
- assertSame(null, e.getArguments()[1]);
- }
-
- /*
- * Test instantiate() with a property name starting with initial upper case
- * letter, and a valid getter method.
- */
- public void testInstantiate_InitialUpperCasePropName() throws Exception {
- String[] props = new String[] { "Prop1", "prop2" };
- MockPersistenceDelegate pd = new MockPersistenceDelegate(props);
- MockBean b = new MockBean();
- b.setAll("bean1", 2);
- Expression e = pd.instantiate(b, new Encoder());
- assertSame(b, e.getValue());
- assertSame(MockBean.class, e.getTarget());
- assertEquals("new", e.getMethodName());
- assertEquals(2, e.getArguments().length);
- assertSame(b.getProp1(), e.getArguments()[0]);
- assertEquals(new Integer(2), e.getArguments()[1]);
- }
-
- /*
- * Test instantiate() with a bean with no getter.
- */
- public void testInstantiate_NoGetter() throws Exception {
- MockEncoder enc = new MockEncoder();
- MockPersistenceDelegate pd = new MockPersistenceDelegate(
- new String[] { "i" });
- MockNoGetterBean2 b = new MockNoGetterBean2(3);
- enc.setExceptionListener(new ExceptionListener() {
- public void exceptionThrown(Exception e) {
- CallVerificationStack.getInstance().push(e);
- }
- });
- Expression e = pd.instantiate(b, enc);
- assertSame(b, e.getValue());
- assertSame(MockNoGetterBean2.class, e.getTarget());
- assertEquals("new", e.getMethodName());
- assertEquals(1, e.getArguments().length);
- assertSame(null, e.getArguments()[0]);
- assertFalse(CallVerificationStack.getInstance().empty());
- }
-
- /*
- * Test instantiate() with a property name that has an irregular getter
- * method, defined by its beaninfo.
- */
- public void testInstantiate_NotRegularGetter() throws Exception {
- MockPersistenceDelegate pd = new MockPersistenceDelegate(
- new String[] { "prop" });
- MockFoo2 b = new MockFoo2(2);
- Expression e = pd.instantiate(b, new Encoder());
-
- assertSame(b, e.getValue());
- assertSame(MockFoo2.class, e.getTarget());
- assertEquals("new", e.getMethodName());
- assertEquals(1, e.getArguments().length);
- assertNull(e.getArguments()[0]);
- }
-
- public void testInstantiate_NPE() {
-
- try {
- testDefaultPersistenceDelegate obj = new testDefaultPersistenceDelegate();
- obj.initialize(Object.class, null, new Object(), new Encoder());
- fail("NullPointerException should be thrown");
- } catch (NullPointerException e) {
- // expected
- }
- }
-
- class testDefaultPersistenceDelegate extends DefaultPersistenceDelegate {
- testDefaultPersistenceDelegate() {
- super();
- }
-
- public void initialize(Class<?> type, Object oldInstance,
- Object newInstance, Encoder out) {
- super.initialize(type, oldInstance, newInstance, out);
- }
- }
-
- /*
- * Tests mutatesTo() under normal conditions without any properties.
- */
- public void testMutatesTo_NormalNoProperty() {
- MockPersistenceDelegate pd = new MockPersistenceDelegate();
-
- assertTrue(pd.mutatesTo("test1", "test1"));
- assertFalse(pd.mutatesTo(new Object(), new Object() {
- @Override
- public int hashCode() {
- return super.hashCode();
- }
- }));
- assertFalse(pd.mutatesTo(new MockFoo(), new MockFooStop()));
- }
-
- /*
- * Tests mutatesTo() under normal conditions with properties but no equal
- * method defined.
- */
- public void testMutatesTo_NormalWithPropertyNoEqualMethod() {
- MockPersistenceDelegate pd = new MockPersistenceDelegate(
- new String[] { "name" });
-
- assertFalse(pd.mutatesTo(new Object(), new Object() {
- @Override
- public int hashCode() {
- return super.hashCode();
- }
- }));
- }
-
- /*
- * Tests mutatesTo() under normal conditions with null properties and equal
- * method defined.
- */
- public void testMutatesTo_NormalWithNullPropertyPublicEqualMethod() {
- MockPersistenceDelegate pd = new MockPersistenceDelegate(
- new String[] { null });
-
- assertFalse(pd.mutatesTo("test1", "test2"));
- }
-
- /*
- * Tests mutatesTo() under normal conditions with empty properties and equal
- * method defined.
- */
- public void testMutatesTo_NormalWithEmptyPropertyPublicEqualMethod() {
- MockPersistenceDelegate pd = new MockPersistenceDelegate(new String[0]);
-
- assertTrue(pd.mutatesTo("test1", "test1"));
- }
-
- /*
- * Tests mutatesTo() under normal conditions with properties and equal
- * method defined.
- */
- public void testMutatesTo_NormalWithPropertyPublicEqualMethod() {
- MockPersistenceDelegate pd = new MockPersistenceDelegate(
- new String[] { "name" });
-
- assertFalse(pd.mutatesTo("test1", "test2"));
- assertTrue(pd.mutatesTo("test1", "test1"));
- }
-
- /*
- * Tests mutatesTo() under normal conditions with properties and protected
- * equal method defined.
- */
- public void testMutatesTo_NormalWithPropertyProtectedEqualMethod() {
- MockPersistenceDelegate pd = new MockPersistenceDelegate(
- new String[] { "name" });
-
- assertFalse(pd.mutatesTo(new MockPersistenceDelegate(), "test"));
- }
-
- /*
- * Tests mutatesTo() with null parameters.
- */
- public void testMutatesTo_Null() {
- MockPersistenceDelegate pd = new MockPersistenceDelegate();
-
- assertFalse(pd.mutatesTo("test", null));
- assertFalse(pd.mutatesTo(null, null));
- assertFalse(pd.mutatesTo(null, "test"));
- }
-
- //Regression for HARMONY-3782
- public void test_mutates_with_equals_true() {
- MyObjectEqualsTrue o1 = new MyObjectEqualsTrue();
- MyObjectEqualsTrue o2 = new MyObjectEqualsTrue();
- MyDefaultPersistenceDelegate myDefaultPersistenceDelegate = new MyDefaultPersistenceDelegate();
- assertTrue(myDefaultPersistenceDelegate.mutatesTo(o1, o2));
- assertFalse(o1.equalsCalled);
-
- o1 = new MyObjectEqualsTrue();
- o2 = new MyObjectEqualsTrue();
- myDefaultPersistenceDelegate = new MyDefaultPersistenceDelegate(new String[0]);
- assertTrue(myDefaultPersistenceDelegate.mutatesTo(o1, o2));
- assertFalse(o1.equalsCalled);
-
- o1 = new MyObjectEqualsTrue();
- o2 = new MyObjectEqualsTrue();
- myDefaultPersistenceDelegate = new MyDefaultPersistenceDelegate(new String[]{"TEST_ARUGMENT_NAME"});
- assertTrue(myDefaultPersistenceDelegate.mutatesTo(o1, o2));
- assertTrue(o1.equalsCalled);
- }
-
- public void test_mutatesTo_Object() {
- Object o1 = new Object();
- Object o2 = new Object();
- MockPersistenceDelegate mockPersistenceDelegate = new MockPersistenceDelegate();
- assertTrue(mockPersistenceDelegate.mutatesTo(o1, o2));
- }
-
- public void test_initialize() {
- MockBean3 bean1 = new MockBean3();
- bean1.setValue("bean1");
- MockBean3 bean2 = new MockBean3();
- bean2.setValue("bean2");
-
- // clear flags
- bean1.setValueCalled = false;
- bean2.setValueCalled = false;
-
- MockPersistenceDelegate mockPersistenceDelegate = new MockPersistenceDelegate();
- mockPersistenceDelegate.initialize(MockBean3.class, bean1, bean2,
- new Encoder());
- assertEquals("bean1", bean1.getValue());
- assertEquals("bean2", bean2.getValue());
- assertFalse(bean1.setValueCalled);
- assertFalse(bean2.setValueCalled);
- }
-
- public void test_mutates_with_equals_false() {
- MyObjectEqualsFalse o1 = new MyObjectEqualsFalse();
- MyObjectEqualsFalse o2 = new MyObjectEqualsFalse();
- MyDefaultPersistenceDelegate myDefaultPersistenceDelegate = new MyDefaultPersistenceDelegate();
- assertTrue(myDefaultPersistenceDelegate.mutatesTo(o1, o2));
- assertFalse(o1.equalsCalled);
-
- o1 = new MyObjectEqualsFalse();
- o2 = new MyObjectEqualsFalse();
- myDefaultPersistenceDelegate = new MyDefaultPersistenceDelegate(new String[0]);
- assertTrue(myDefaultPersistenceDelegate.mutatesTo(o1, o2));
- assertFalse(o1.equalsCalled);
-
- o1 = new MyObjectEqualsFalse();
- o2 = new MyObjectEqualsFalse();
- myDefaultPersistenceDelegate = new MyDefaultPersistenceDelegate(new String[]{"TEST_ARUGMENT_NAME"});
- assertFalse(myDefaultPersistenceDelegate.mutatesTo(o1, o2));
- assertTrue(o1.equalsCalled);
- }
-
- public void test_mutates_with_no_equals()
- {
- MyObjectNoExplicitEquals o1 = new MyObjectNoExplicitEquals();
- MyObjectNoExplicitEquals o2 = new MyObjectNoExplicitEquals();
- MyDefaultPersistenceDelegate myDefaultPersistenceDelegate = new MyDefaultPersistenceDelegate();
- assertTrue(myDefaultPersistenceDelegate.mutatesTo(o1, o2));
- assertFalse(o1.equalsCalled);
-
- o1 = new MyObjectNoExplicitEquals();
- o2 = new MyObjectNoExplicitEquals();
- myDefaultPersistenceDelegate = new MyDefaultPersistenceDelegate(new String[]{"TEST_ARUGMENT_NAME"});
- assertTrue(myDefaultPersistenceDelegate.mutatesTo(o1, o2));
- assertFalse(o1.equalsCalled);
- }
-
- public class MyDefaultPersistenceDelegate extends
- DefaultPersistenceDelegate {
- public MyDefaultPersistenceDelegate() {
- super();
- }
-
- public MyDefaultPersistenceDelegate(String[] constructorPropertyNames) {
- super(constructorPropertyNames);
- }
-
- public boolean mutatesTo(Object oldInstance, Object newInstance) {
- return super.mutatesTo(oldInstance, newInstance);
- }
- }
-
- public class MyObjectEqualsTrue extends Object {
- public boolean equalsCalled = false;
-
- @Override
- public boolean equals(Object object) {
- equalsCalled = true;
- return true;
- }
- }
-
- public class MyObjectEqualsFalse extends Object {
- public boolean equalsCalled = false;
-
- @Override
- public boolean equals(Object object) {
- equalsCalled = true;
- return false;
- }
- }
-
- public class MyObjectNoExplicitEquals extends MyObjectEqualsFalse {
-
- }
-
- /*
- * Test initialize() under normal conditions with a bean that does not have
- * bean info class.
- */
- public void testInitialize_Normal() throws Exception {
- CollectingEncoder enc;
- MockPersistenceDelegate pd = new MockPersistenceDelegate();
- MockFoo oldBean;
- MockFoo newBean;
-
- enc = new CollectingEncoder();
- oldBean = new MockFoo();
- oldBean.setName("myName");
- oldBean.setLabel("myLabel");
- pd.writeObject(oldBean, enc);
- enc.clearCache();
- pd.initialize(MockFoo.class, oldBean, new MockFoo(), enc);
-
- assertNotNull(findStatement(enc.statements(), oldBean, "setName",
- new Object[] { oldBean.getName() }));
- assertNotNull(findStatement(enc.statements(), oldBean, "setLabel",
- new Object[] { oldBean.getLabel() }));
-
- enc = new CollectingEncoder();
- oldBean = new MockFoo();
- oldBean.setComplexLabel(new MockFooLabel("myComplexLabel"));
- pd.writeObject(oldBean, enc);
- newBean = new MockFoo();
- newBean.setComplexLabel(new MockFooLabel("complexLabel2"));
- pd.writeObject(newBean, enc);
- enc.clearCache();
- pd.initialize(MockFoo.class, oldBean, newBean, enc);
- }
-
- /*
- * Test initialize() under normal conditions with a bean that does have bean
- * info class.
- */
- public void testInitialize_NormalBeanInfo() throws Exception {
- CollectingEncoder enc = new CollectingEncoder();
- MockPersistenceDelegate pd = new MockPersistenceDelegate();
- MockFoo2 b = new MockFoo2(2);
- MockFoo2 b2 = new MockFoo2(3);
- Iterator<Statement> iter;
-
- pd.writeObject(b, enc);
- pd.writeObject(b2, enc);
- enc.clearCache();
- pd.initialize(MockFoo2.class, b, b2, enc);
-
- // XXX RI stores much more statements to the stream
- iter = enc.statements();
- // assertNotNull("required statement not found",
- // findStatement(iter, b, "myget", null));
- assertNotNull("required statement not found", findStatement(iter, null,
- "myset", new Object[] { new Integer(2) }));
- }
-
- /*
- * Test initialize() when oldInstance == newInstance. XXX The current
- * implementation outputs nothing to the stream. And this seems to be
- * correct from the spec point of view since we need not to do any actions
- * to convert the object to itself. However, RI outputs a lot of stuff to
- * the stream here.
- */
- // public void testInitialize_SameInstance() throws Exception {
- // CollectingEncoder enc = new CollectingEncoder();
- // MockPersistenceDelegate pd = new MockPersistenceDelegate();
- // MockFoo b = new MockFoo();
- // Iterator<Statement> iter;
- //
- // b.setName("mymyName");
- // // b.setLabel("myLabel");
- //
- // pd.initialize(MockFoo.class, b, b, enc);
- //
- // }
- /*
- * Test initialize() with a bean with a transient property.
- */
- public void testInitialize_TransientProperty() throws Exception {
- CollectingEncoder enc = new CollectingEncoder();
- MockPersistenceDelegate pd = new MockPersistenceDelegate();
- MockTransientBean b = new MockTransientBean();
-
- b.setName("myName");
- pd.writeObject(b, enc);
- enc.clearCache();
- pd.initialize(MockTransientBean.class, b, new MockTransientBean(), enc);
- assertFalse("transient fields should not be affected", enc.statements()
- .hasNext());
-
- // set transient to false
- Introspector.flushCaches();
- MockTransientBeanBeanInfo.setTransient(false);
- pd.initialize(MockTransientBean.class, b, new MockTransientBean(), enc);
- assertTrue(enc.statements().hasNext());
- }
-
- /*
- * Test initialize() with a bean with no setter.
- */
- public void testInitialize_NoSetter() throws Exception {
- MockEncoder enc = new MockEncoder();
- MockPersistenceDelegate pd = new MockPersistenceDelegate();
- MockNoSetterBean b = new MockNoSetterBean();
- enc.setExceptionListener(new ExceptionListener() {
- public void exceptionThrown(Exception e) {
- CallVerificationStack.getInstance().push(e);
- }
- });
- b.setName("myName");
- pd.initialize(MockNoSetterBean.class, b, new MockNoSetterBean(), enc);
- assertTrue(CallVerificationStack.getInstance().empty());
-
- pd = new MockPersistenceDelegate(new String[] { "name" });
- enc.setExceptionListener(new ExceptionListener() {
- public void exceptionThrown(Exception e) {
- CallVerificationStack.getInstance().push(e);
- }
- });
- b.setName("myName");
- pd.initialize(MockNoSetterBean.class, b, new MockNoSetterBean(), enc);
- assertTrue(CallVerificationStack.getInstance().empty());
- }
-
- /*
- * Test initialize() with a bean with no getter.
- */
- public void testInitialize_NoGetter() throws Exception {
- MockEncoder enc = new MockEncoder();
- MockPersistenceDelegate pd = new MockPersistenceDelegate();
- MockNoGetterBean b = new MockNoGetterBean();
-
- b.setName("myName");
- enc.setExceptionListener(new ExceptionListener() {
- public void exceptionThrown(Exception e) {
- CallVerificationStack.getInstance().push(e);
- }
- });
- enc.writeObject(b);
- CallVerificationStack.getInstance().clear();
- MockNoGetterBean b2 = (MockNoGetterBean) enc.get(b);
- b2.setName("yourName");
- b2.setLabel("hehe");
- pd.initialize(MockNoGetterBean.class, b, b2, enc);
- assertTrue(CallVerificationStack.getInstance().empty());
- }
-
- /*
- * Tests initialize() with null class.
- */
- public void testInitialize_NullClass() {
- MockPersistenceDelegate pd = new MockPersistenceDelegate();
- Encoder enc = new Encoder();
- Object o1 = new Object();
- Object o2 = new Object();
- // enc.setPersistenceDelegate(MockFooStop.class,
- // new MockPersistenceDelegate());
- try {
- enc.setExceptionListener(new ExceptionListener() {
- public void exceptionThrown(Exception e) {
- CallVerificationStack.getInstance().push(e);
- }
- });
- pd.initialize(null, o1, o2, enc);
- fail("Should throw NullPointerException!");
- } catch (NullPointerException ex) {
- // expected
- }
- assertTrue(CallVerificationStack.getInstance().empty());
- }
-
- /*
- * Tests initialize() with null old and new instances.
- */
- public void testInitialize_NullInstances() {
- MockPersistenceDelegate pd = new MockPersistenceDelegate();
- Encoder enc = new Encoder();
- MockFoo b = new MockFoo();
- b.setName("myName");
- // enc.setPersistenceDelegate(MockFooStop.class,
- // new MockPersistenceDelegate());
- enc.setExceptionListener(new ExceptionListener() {
- public void exceptionThrown(Exception e) {
- CallVerificationStack.getInstance().push(e);
- }
- });
- try {
- pd.initialize(MockFoo.class, null, b, enc);
- fail("Should throw NullPointerException!");
- } catch (NullPointerException ex) {
- // expected
- }
- assertTrue(CallVerificationStack.getInstance().empty());
- pd.initialize(MockFoo.class, b, null, enc);
- assertFalse(CallVerificationStack.getInstance().empty());
- }
-
- /*
- * Tests initialize() with null encoder.
- */
- public void testInitialize_NullEncoder() {
- MockPersistenceDelegate pd = new MockPersistenceDelegate();
- Object o1 = new Object();
- Object o2 = new Object();
- try {
- pd.initialize(MockFoo.class, o1, o2, null);
- fail("Should throw NullPointerException!");
- } catch (NullPointerException ex) {
- // expected
- }
- }
-
- /*
- * Tests array persistence delegate
- */
- public void testArrayPD_Normal() {
- Encoder enc = new MockEncoder();
- int[] ia = new int[] { 1 };
- PersistenceDelegate pd = enc.getPersistenceDelegate(ia.getClass());
- pd.writeObject(ia, enc);
- }
-
- class MockDefaultPersistenceDelegate extends DefaultPersistenceDelegate {
- public MockDefaultPersistenceDelegate(String[] args) {
- super(args);
- }
-
- public boolean mockMutatesTo(Object obj1, Object obj2) {
- return mutatesTo(obj1, obj2);
- }
- }
-
- public void test_MutatesTo_scenario1() throws Exception {
- MockDefaultPersistenceDelegate mockDPD = new MockDefaultPersistenceDelegate(
- new String[1]);
- try {
- mockDPD.mockMutatesTo((Object) null, (Object) null);
- fail("should throw NPE");
- } catch (NullPointerException e) {
- // Expected
- }
-
- try {
- mockDPD.mockMutatesTo((Object) null, (Object) "");
- fail("should throw NPE");
- } catch (NullPointerException e) {
- // Expected
- }
-
- assertFalse(mockDPD.mockMutatesTo((Object) "", (Object) null));
- }
-
- public void test_MutatesTo_scenario2() throws Exception {
- MockDefaultPersistenceDelegate mockDPD = new MockDefaultPersistenceDelegate(
- new String[0]);
- assertFalse(mockDPD.mockMutatesTo((Object) null, (Object) null));
- assertFalse(mockDPD.mockMutatesTo((Object) null, (Object) ""));
- assertFalse(mockDPD.mockMutatesTo((Object) "", (Object) null));
- assertTrue(mockDPD.mockMutatesTo((Object) "", (Object) ""));
- }
-
- /*
- * BeanInfo for the MockBean below.
- */
- public static class MockNoGetterBeanBeanInfo extends SimpleBeanInfo {
-
- @Override
- public PropertyDescriptor[] getPropertyDescriptors() {
- try {
- PropertyDescriptor pd = new PropertyDescriptor("name", null,
- MockNoGetterBean.class.getMethod("setName",
- new Class[] { String.class }));
- PropertyDescriptor pd2 = new PropertyDescriptor("ii", null,
- MockNoGetterBean.class.getMethod("setII",
- new Class[] { Integer.class }));
- return new PropertyDescriptor[] { pd, pd2 };
- } catch (Exception e) {
- throw new Error(e);
- }
- }
- }
-
- /*
- * Mock bean with no getter.
- */
- public static class MockNoGetterBean extends MockFoo {
- private static final long serialVersionUID = 5528972237047564849L;
-
- public void setII(Integer i) {
- }
- }
-
- /*
- * Mock bean with no getter.
- */
- public static class MockNoGetterBean2 {
- public MockNoGetterBean2(int i) {
- }
-
- public void setI(int i) {
- }
- }
-
- /*
- * BeanInfo for the MockBean below.
- */
- public static class MockNoSetterBeanBeanInfo extends SimpleBeanInfo {
-
- @Override
- public PropertyDescriptor[] getPropertyDescriptors() {
- try {
- PropertyDescriptor pd = new PropertyDescriptor("name",
- MockNoSetterBean.class.getMethod("getName",
- (Class[]) null), null);
- return new PropertyDescriptor[] { pd };
- } catch (Exception e) {
- throw new Error(e);
- }
- }
- }
-
- /*
- * Mock bean with no setter.
- */
- public static class MockNoSetterBean {
- private String name;
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
- }
-
- /*
- * BeanInfo for the MockBean below.
- */
- public static class MockTransientBeanBeanInfo extends SimpleBeanInfo {
-
- private static boolean trans = true;
-
- public static void setTransient(boolean b) {
- trans = b;
- }
-
- @Override
- public PropertyDescriptor[] getPropertyDescriptors() {
- try {
- PropertyDescriptor pd = new PropertyDescriptor("name",
- MockTransientBean.class);
- pd.setValue("transient", new Boolean(trans));
- return new PropertyDescriptor[] { pd };
- } catch (Exception e) {
- throw new Error(e);
- }
- }
- }
-
- /*
- * Mock bean with a transient property.
- */
- public static class MockTransientBean extends MockFoo {
-
- private static final long serialVersionUID = 6924332068595493238L;
- }
-
- /*
- * Mock bean.
- */
- public static class MockBean {
- private transient String prop1;
-
- private transient int prop2;
-
- public String getProp1() {
- return this.prop1;
- }
-
- public int getProp2() {
- return this.prop2;
- }
-
- public int getProp3() {
- return this.prop2;
- }
-
- public void setProp3() {
- // empty
- }
-
- public int getProp4(int i) {
- return this.prop2;
- }
-
- public int getProp5() throws Exception {
- throw new Exception();
- }
-
- public int getProp7() {
- throw new Error();
- }
-
- public void setAll(String prop1, int prop2) {
- this.prop1 = prop1;
- this.prop2 = prop2;
- }
-
- public int get() {
- return this.prop2;
- }
-
- }
-
- /*
- * Mock DefaultPersistenceDelegate subclass.
- */
- static class MockPersistenceDelegate extends DefaultPersistenceDelegate {
-
- public MockPersistenceDelegate() {
- super();
- }
-
- public MockPersistenceDelegate(String[] props) {
- super(props);
- }
-
- @Override
- public Expression instantiate(Object oldInstance, Encoder out) {
- return super.instantiate(oldInstance, out);
- }
-
- @Override
- public void initialize(Class<?> type, Object oldInstance,
- Object newInstance, Encoder enc) {
- super.initialize(type, oldInstance, newInstance, enc);
- }
-
- @Override
- public boolean mutatesTo(Object oldInstance, Object newInstance) {
- return super.mutatesTo(oldInstance, newInstance);
- }
-
- protected boolean equals(String o) {
- return true;
- }
-
- }
-
- /*
- * Mock Encoder.
- */
- static class MockEncoder extends Encoder {
-
- @Override
- public ExceptionListener getExceptionListener() {
- return super.getExceptionListener();
- }
-
- @Override
- public PersistenceDelegate getPersistenceDelegate(Class<?> type) {
- return super.getPersistenceDelegate(type);
- }
-
- @Override
- public void setExceptionListener(ExceptionListener exceptionListener) {
- super.setExceptionListener(exceptionListener);
- }
-
- @Override
- public void setPersistenceDelegate(Class<?> type,
- PersistenceDelegate persistenceDelegate) {
- super.setPersistenceDelegate(type, persistenceDelegate);
- }
-
- private void recordCall(Object param) {
- StackTraceElement[] eles = (new Throwable()).getStackTrace();
- int i = 0;
- // skip Throwable.init()
- while (eles[i].getClassName().equals("java.lang.Throwable")) {
- i++;
- }
- // skip calls from MockEncoder
- while (eles[i].getClassName().equals(MockEncoder.class.getName())) {
- i++;
- }
- // skip calls from DefaultPersistenceDelegate & PersistenceDelegate
- while (eles[i].getClassName().equals(
- DefaultPersistenceDelegate.class.getName())
- || eles[i].getClassName().equals(
- PersistenceDelegate.class.getName())) {
- i++;
- }
- if (i > 2
- && eles[++i].getClassName().equals(
- DefaultPersistenceDelegateTest.class.getName())) {
- CallVerificationStack.getInstance().push(param);
- }
- }
-
- @Override
- public Object get(Object oldInstance) {
- recordCall(oldInstance);
- return super.get(oldInstance);
- }
-
- @Override
- public Object remove(Object oldInstance) {
- recordCall(oldInstance);
- return super.remove(oldInstance);
- }
-
- @Override
- public void writeExpression(Expression oldExp) {
- recordCall(oldExp);
- super.writeExpression(oldExp);
- }
-
- @Override
- public void writeStatement(Statement oldStm) {
- recordCall(oldStm);
- super.writeStatement(oldStm);
- }
-
- @Override
- public void writeObject(Object o) {
- recordCall(o);
- super.writeObject(o);
- }
- }
-
- /**
- * Searches for the statement with given parameters.
- *
- * @param iter
- * iterator to search through, null means ignore this parameter
- * @param target
- * @param methodName
- * @param args
- * @return found statement or null
- */
- static Statement findStatement(Iterator<Statement> iter, Object target,
- String methodName, Object[] args) {
-
- while (iter.hasNext()) {
- Statement stmt = iter.next();
-
- if (target != null && stmt.getTarget() != target) {
- continue;
- }
-
- if (methodName != null && !methodName.equals(stmt.getMethodName())) {
- continue;
- }
-
- if (args != null) {
- if ((stmt.getArguments() != null && args.length != stmt
- .getArguments().length)
- || stmt.getArguments() == null) {
- continue;
- }
-
- for (int i = 0; i < args.length; i++) {
- if ((args[i] == null && stmt.getArguments()[i] != null)
- || (args[i] != null && stmt.getArguments()[i] == null)
- || !args[i].equals(stmt.getArguments()[i])) {
- continue;
- }
- }
- }
-
- return stmt;
- }
-
- return null;
- }
-
- public static class CollectingEncoder extends Encoder {
- private Vector<Statement> statements = new Vector<Statement>();
-
- @Override
- public void writeExpression(Expression exp) {
- statements.add(exp);
- super.writeExpression(exp);
- }
-
- @Override
- public void writeStatement(Statement stm) {
- statements.add(stm);
- super.writeStatement(stm);
- }
-
- public Iterator<Statement> statements() {
- return statements.iterator();
- }
-
- public void clearCache() {
- statements = new Vector<Statement>();
- }
- }
-
- public static class MockBean3
- {
- public boolean setValueCalled = false;
-
- public String value;
-
- public String getValue() {
- return value;
- }
-
- public void setValue(String value) {
- this.value = value;
- setValueCalled = true;
- }
- }
-}
diff --git a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/EncoderTest.java b/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/EncoderTest.java
deleted file mode 100644
index 65eaf39..0000000
--- a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/EncoderTest.java
+++ /dev/null
@@ -1,493 +0,0 @@
-/*
- * 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.java.beans;
-
-import java.beans.DefaultPersistenceDelegate;
-import java.beans.Encoder;
-import java.beans.ExceptionListener;
-import java.beans.Expression;
-import java.beans.PersistenceDelegate;
-import java.beans.Statement;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.lang.reflect.Proxy;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.apache.harmony.beans.tests.support.mock.MockBean4Codec;
-import org.apache.harmony.beans.tests.support.mock.MockBean4CodecBadGetter;
-import org.apache.harmony.beans.tests.support.mock.MockExceptionListener;
-import org.apache.harmony.beans.tests.support.mock.MockFooLiYang;
-@SuppressWarnings("unchecked")
-public class EncoderTest extends TestCase {
-
- public static class VerboseEncoder extends Encoder {
-
- private PrintWriter out;
-
- private boolean ident;
-
- public VerboseEncoder() {
- this(new PrintWriter(System.out, true), true);
- }
-
- public VerboseEncoder(PrintWriter out, boolean ident) {
- this.out = out;
- this.ident = ident;
- }
-
- @Override
- public Object get(Object arg0) {
- String identStr = ident ? ident() : "";
- out.println(identStr + "get()> " + arg0);
- Object result = super.get(arg0);
- out.println(identStr + "get()< " + result);
- return result;
- }
-
- @Override
- public PersistenceDelegate getPersistenceDelegate(Class type) {
- PersistenceDelegate result = super.getPersistenceDelegate(type);
- return result;
- }
-
- @Override
- public Object remove(Object arg0) {
- String identStr = ident ? ident() : "";
- out.println(identStr + "remove()> " + arg0);
- Object result = super.remove(arg0);
- out.println(identStr + "remove()< " + result);
- return result;
- }
-
- @Override
- public void writeExpression(Expression arg0) {
- String identStr = ident ? ident() : "";
- out.println(identStr + "writeExpression()> " + string(arg0));
- super.writeExpression(arg0);
- out.println(identStr + "writeExpression()< ");
- }
-
- @Override
- public void writeStatement(Statement arg0) {
- String identStr = ident ? ident() : "";
- out.println(identStr
- + new Exception().getStackTrace()[1].getClassName()
- + ".writeStatement()> " + string(arg0));
- super.writeStatement(arg0);
- out.println(identStr + "writeStatement()< ");
- }
-
- @Override
- public void writeObject(Object arg0) {
- String identStr = ident ? ident() : "";
- out.println(identStr + "writeObject()> " + arg0);
- super.writeObject(arg0);
- out.println(identStr + "writeObject()< ");
- }
- }
-
- public static class VerbosePD extends DefaultPersistenceDelegate {
-
- @Override
- protected void initialize(Class arg0, Object arg1, Object arg2,
- Encoder arg3) {
- System.out.println(ident() + "PDinitialize()> " + arg0 + ", "
- + arg1 + ", " + arg2);
- super.initialize(arg0, arg1, arg2, arg3);
- System.out.println(ident() + "PDinitialize()< ");
- }
-
- @Override
- protected Expression instantiate(Object arg0, Encoder arg1) {
- System.out.println(ident() + "PDinstantiate()> " + arg0);
- Expression result = super.instantiate(arg0, arg1);
- System.out.println(ident() + "PDinstantiate()< " + result);
- return result;
- }
-
- @Override
- protected boolean mutatesTo(Object arg0, Object arg1) {
- System.out
- .println(ident() + "PDmutatesTo()> " + arg0 + ", " + arg1);
- boolean result = super.mutatesTo(arg0, arg1);
- System.out.println(ident() + "PDmutatesTo()< " + result);
- return result;
- }
-
- @Override
- public void writeObject(Object arg0, Encoder arg1) {
- System.out.println(ident() + "PDwriteObject()> " + arg0);
- super.writeObject(arg0, arg1);
- System.out.println(ident() + "PDwriteObject()< ");
- }
- }
-
- public static class SampleBean {
- String myid = "default ID";
-
- int i = 1;
-
- SampleBean ref;
-
- public String getMyid() {
- return myid;
- }
-
- public void setMyid(String myid) {
- this.myid = myid;
- }
-
- public int getI() {
- return i;
- }
-
- public void setI(int i) {
- this.i = i;
- }
-
- public SampleBean getRef() {
- return ref;
- }
-
- public void setRef(SampleBean ref) {
- this.ref = ref;
- }
-
- @Override
- public String toString() {
- String superResult = super.toString();
- superResult.substring(superResult.indexOf("@"));
- return "myid=" + myid;
- }
- }
-
- public static String ident() {
- Exception ex = new Exception();
- int level = ex.getStackTrace().length;
- StringBuffer buf = new StringBuffer();
- for (int i = 0; i < level; i++) {
- buf.append(" ");
- }
- return buf.toString();
- }
-
- public static String string(Statement stat) {
- String str = "(" + stat.getTarget() + ")." + stat.getMethodName() + "(";
- Object args[] = stat.getArguments();
- for (int i = 0; i < args.length; i++) {
- if (i > 0) {
- str += ", ";
- }
- str += args[i];
- }
- str = str + ")";
- return str;
- }
-
- public static String string(Expression exp) {
- String str = "";
- try {
- str += str + exp.getValue();
- } catch (Exception e) {
- e.printStackTrace();
- }
- str += "=" + string((Statement) exp);
- return str;
- }
-
- public static class MockEncoder extends Encoder {
-
- @Override
- public void writeObject(Object o) {
- super.writeObject(o);
- }
- }
-
- public void testGetExceptionListener() {
- MockEncoder enc = new MockEncoder();
- assertNotNull(enc.getExceptionListener());
-
- MockExceptionListener l = new MockExceptionListener();
- enc.setExceptionListener(l);
- assertSame(l, enc.getExceptionListener());
-
- enc.writeObject(new MockBean4CodecBadGetter());
- assertTrue(l.size() > 0);
- }
-
- public void testSetExceptionListener_Null() {
- MockEncoder enc = new MockEncoder();
- ExceptionListener l = enc.getExceptionListener();
- enc.setExceptionListener(null);
- assertSame(l, enc.getExceptionListener());
-
- ExceptionListener l2 = new MockExceptionListener();
- enc.setExceptionListener(l2);
- enc.setExceptionListener(null);
- assertSame(l.getClass(), enc.getExceptionListener().getClass());
- }
-
- public void testSetExceptionListener() {
- MockEncoder enc = new MockEncoder();
- assertNotNull(enc.getExceptionListener());
-
- MockExceptionListener l = new MockExceptionListener();
- enc.setExceptionListener(l);
- assertSame(l, enc.getExceptionListener());
-
- enc.writeObject(new MockBean4CodecBadGetter());
- assertTrue(l.size() > 0);
- }
-
- public void testWriteExpression() {
- // covered by testWriteObject()
- }
-
- public void testWriteExpression_Null() {
- Encoder enc = new Encoder();
- try {
- enc.writeExpression(null);
- fail();
- } catch (NullPointerException e) {
- // expected
- }
- }
-
- public void testWriteStatement() {
- // covered by testWriteObject()
- }
-
- public void testWriteStatement_Null() {
- Encoder enc = new Encoder();
- try {
- enc.writeStatement(null);
- fail("NPE expected");
- } catch (NullPointerException e) {
- // expected
- }
- }
-
- public void testWriteObject_Null() {
- StringWriter sbwriter = new StringWriter();
- VerboseEncoder enc = new VerboseEncoder(
- new PrintWriter(sbwriter, true), false);
- enc.writeObject(null);
- String trace = sbwriter.toString();
-
- final String LS = System.getProperty("line.separator");
- assertEquals("writeObject()> null" + LS + "writeObject()< " + LS, trace);
- }
-
- public void testWriteObject() {
- StringWriter sbwriter = new StringWriter();
- VerboseEncoder enc = new VerboseEncoder(
- new PrintWriter(sbwriter, true), false);
- SampleBean b = new SampleBean();
- b.setI(3);
- b.setMyid("new name");
- enc.writeObject(b);
- String trace = sbwriter.toString();
-
- final String LS = System.getProperty("line.separator");
- int lastIndex = 0, index = 0;
-
- index = trace
- .indexOf(
- "writeObject()> myid=new name"
- + LS
- + "get()> myid=new name"
- + LS
- + "get()< null"
- + LS
- + "remove()> myid=new name"
- + LS
- + "remove()< null"
- + LS
- + "writeExpression()> myid=new name=(class org.apache.harmony.beans.tests.java.beans.EncoderTest$SampleBean).new()"
- + LS, lastIndex);
- assertTrue(lastIndex <= index);
- lastIndex = index;
-
- index = trace
- .indexOf("writeObject()> myid=new name" + LS
- + "get()> myid=new name" + LS
- + "get()< myid=default ID" + LS
- + "writeExpression()> 3=(myid=new name).getI()" + LS,
- lastIndex);
- assertTrue(lastIndex <= index);
- lastIndex = index;
-
- index = trace.indexOf("get()> 3" + LS + "get()< 1" + LS, lastIndex);
- assertTrue(lastIndex <= index);
- lastIndex = index;
-
- index = trace.indexOf(
- "writeExpression()> new name=(myid=new name).getMyid()" + LS
- + "get()> new name" + LS + "get()< new name" + LS
- + "writeExpression()< " + LS, lastIndex);
- assertTrue(lastIndex <= index);
- lastIndex = index;
-
- index = trace.indexOf(
- "writeStatement()> (myid=new name).setMyid(new name)" + LS
- + "get()> myid=new name" + LS
- + "get()< myid=default ID" + LS + "get()> new name"
- + LS + "get()< new name" + LS + "writeStatement()< "
- + LS, lastIndex);
- assertTrue(lastIndex <= index);
- lastIndex = index;
- }
-
- public void testGetPersistenceDelegate_Null() {
- Encoder enc = new Encoder();
- PersistenceDelegate pd = enc.getPersistenceDelegate(null);
- assertNotNull(pd);
- }
-
- public void testGetPersistenceDelegate_ArrayClass() {
- Encoder enc = new Encoder();
- PersistenceDelegate pd = enc.getPersistenceDelegate(int[].class);
- assertFalse(pd instanceof DefaultPersistenceDelegate);
- }
-
- public void testGetPersistenceDelegate_ProxyClass() {
- Encoder enc = new Encoder();
- enc.getPersistenceDelegate(Proxy.getProxyClass(ClassLoader
- .getSystemClassLoader(), new Class[] { List.class }));
- }
-
- public void testGetPersistenceDelegate_BeanInfo() {
- Encoder enc = new Encoder();
- PersistenceDelegate pd = enc
- .getPersistenceDelegate(MockFooLiYang.class);
- assertTrue(pd instanceof DefaultPersistenceDelegate);
- }
-
- public void testGetPersistenceDelegate_Default() {
- Encoder enc = new Encoder();
- Encoder enc2 = new Encoder();
-
- PersistenceDelegate pd1 = enc.getPersistenceDelegate(SampleBean.class);
- assertTrue(pd1 instanceof DefaultPersistenceDelegate);
-
- PersistenceDelegate pd2 = enc.getPersistenceDelegate(SampleBean.class);
- assertTrue(pd2 instanceof DefaultPersistenceDelegate);
-
- PersistenceDelegate pd3 = enc2
- .getPersistenceDelegate(MockBean4Codec.class);
- assertTrue(pd3 instanceof DefaultPersistenceDelegate);
-
- assertSame(pd1, pd2);
- assertSame(pd1, pd3);
- }
-
- public void testSetPersistenceDelegate_Null() {
- // Regression for HARMONY-1304
- Encoder enc = new Encoder();
- PersistenceDelegate pd = enc.getPersistenceDelegate(EncoderTest.class);
-
- try {
- enc.setPersistenceDelegate(null, pd);
- fail("NPE expected");
- } catch (NullPointerException e) {
- // expected
- }
-
- try {
- enc.setPersistenceDelegate(EncoderTest.class, null);
- fail("NPE expected");
- } catch (NullPointerException e) {
- // expected
- }
- }
-
- public void testSetPersistenceDelegate() {
- Encoder enc = new Encoder();
- PersistenceDelegate pd = enc.getPersistenceDelegate(EncoderTest.class);
- assertTrue(pd instanceof DefaultPersistenceDelegate);
-
- enc.setPersistenceDelegate(EncoderTest.class, new VerbosePD());
- assertTrue(enc.getPersistenceDelegate(EncoderTest.class) instanceof VerbosePD);
-
- Encoder enc2 = new Encoder();
- assertTrue(enc2.getPersistenceDelegate(EncoderTest.class) instanceof VerbosePD);
- }
-
- public void testGet_NullParam() {
- Encoder enc = new Encoder();
-
- assertNull(enc.get(null));
- }
-
- public void testGet_String() {
- Encoder enc = new Encoder();
-
- String str = "string";
- assertSame(str, enc.get(str));
- }
-
- public void testGet_Integer() {
- MockEncoder enc = new MockEncoder();
-
- Integer integer = new Integer(8);
- assertNull(enc.get(integer));
- enc.writeObject(integer);
- assertEquals(integer, enc.get(integer));
- assertNull(enc.get(new Integer(integer.intValue())));
-
- Double d = new Double(8);
- assertNull(enc.get(d));
- enc.writeObject(d);
- assertEquals(d, enc.get(d));
- }
-
- public void testRemove_Null() {
- Encoder enc = new Encoder();
-
- assertNull(enc.remove(null));
- }
-
- public void testRemove_String() {
- MockEncoder enc = new MockEncoder();
-
- String str = "string";
- assertSame(str, enc.get(str));
- assertNull(enc.remove(str));
-
- enc.writeObject(str);
- assertSame(str, enc.get(str));
- assertNull(enc.remove(str));
- }
-
- public void testRemove_Integer() {
- MockEncoder enc = new MockEncoder();
-
- Integer integer = new Integer(8);
- assertNull(enc.remove(integer));
-
- enc.writeObject(integer);
- assertEquals(integer, enc.get(integer));
- assertEquals(integer, enc.remove(integer));
-
- assertNull(enc.get(integer));
- assertNull(enc.remove(integer));
- }
-
-}
diff --git a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/EventHandlerTest.java b/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/EventHandlerTest.java
deleted file mode 100644
index e16764c..0000000
--- a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/EventHandlerTest.java
+++ /dev/null
@@ -1,1278 +0,0 @@
-/*
- * 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.java.beans;
-
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.beans.EventHandler;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyChangeSupport;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.util.EventListener;
-import java.util.EventObject;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import org.apache.harmony.beans.tests.support.SampleEvent;
-import org.apache.harmony.beans.tests.support.SampleListener;
-import org.apache.harmony.beans.tests.support.mock.MockButton;
-
-/**
- * Unit test for EventHandler.
- */
-public class EventHandlerTest extends TestCase {
-
- private Object object;
-
- private String methodName;
-
- private Object[] params;
-
- private final String text = "something";
-
- public EventHandlerTest() {
- super();
- }
-
- public EventHandlerTest(String name) {
- super(name);
- }
-
- /**
- * The test checks event handler accessors
- */
- public void testAccessors() {
- InvocationObject invocationObject = new InvocationObject();
- EventHandler handler = new EventHandler(invocationObject, "someText",
- "source.text", "actionPerformed");
- assertEquals(invocationObject, handler.getTarget());
- assertEquals("someText", handler.getAction());
- assertEquals("source.text", handler.getEventPropertyName());
- assertEquals("actionPerformed", handler.getListenerMethodName());
- }
-
- /**
- * The test checks the method invoke() with null listener value
- */
- public void testNullListenerMethodName() throws Exception {
- InvocationObject invocationObject = new InvocationObject();
-
- EventHandler handler = new EventHandler(invocationObject, "someText",
- "source.text", null);
-
- Object proxy = EventHandler.create(ActionListener.class,
- invocationObject, "someText", "source.text");
-
- Method m = ActionListener.class.getMethod("actionPerformed",
- new Class[] { ActionEvent.class });
- handler.invoke(proxy, m, new Object[] { new ActionEvent(this, 0, "") });
-
- assertEquals(invocationObject.getSomeText(), getText());
- }
-
- /**
- * The test checks the method invoke()
- */
- public void testInvoke() throws Exception {
- InvocationObject invocationObject = new InvocationObject();
-
- EventHandler handler = new EventHandler(invocationObject, "someText",
- "source.text", "actionPerformed");
-
- Object proxy = EventHandler.create(ActionListener.class,
- invocationObject, "someText", "source.text");
-
- Method m = ActionListener.class.getMethod("actionPerformed",
- new Class[] { ActionEvent.class });
- handler.invoke(proxy, m, new Object[] { new ActionEvent(this, 0, "") });
-
- assertEquals(invocationObject, handler.getTarget());
- assertEquals(invocationObject.getSomeText(), getText());
- try {
- handler.invoke(proxy, null, new Object[] { new ActionEvent(this, 0,
- "") });
- fail("should throw NullPointerException");
- } catch (NullPointerException e) {
- // Expected
- }
- }
-
- /**
- * The test checks the method invoke() with null property name
- */
- public void testInvokeWithNullPropertyName() throws Exception {
- InvocationObject invocationObject = new InvocationObject();
-
- EventHandler handler = new EventHandler(invocationObject,
- "doSomething", null, null);
-
- Object proxy = EventHandler.create(SampleListener.class,
- invocationObject, "doSomething");
-
- Method m = SampleListener.class.getMethod("fireSampleEvent",
- new Class[] { SampleEvent.class });
- handler.invoke(proxy, m, new Object[] { new SampleEvent("") });
-
- assertEquals(invocationObject, handler.getTarget());
- assertEquals("doSomething", getMethodName());
-
- // Regression test for HARMONY-4033
- m = FredListener.class.getMethod("fireFredEvent",
- new Class[] { FredEvent.class });
- proxy = EventHandler.create(FredListener.class, invocationObject,
- "doSomething", null, "fireFredEvent");
- m.invoke(proxy, new Object[] { null });
- }
-
- /**
- * The test checks the object created with the create() method call
- */
- public void testCreateWithMethodCall() {
- Object invocationObject = new InvocationObject();
- ActionListener listener = EventHandler.create(ActionListener.class,
- invocationObject, "doSomething");
- listener.actionPerformed(new ActionEvent(this, 0, ""));
-
- assertEquals(getObject(), invocationObject);
- assertEquals("doSomething", getMethodName());
-
- Object[] params = getParams();
- if (params.length != 0) {
- fail("Number of params should be 0");
- }
- }
-
- /**
- * The test checks the setter is initialized properly
- */
- public void testCreateWithSetterCall() {
- Object invocationObject = new InvocationObject();
- ActionEvent ae = new ActionEvent(this, 0, "");
- ActionListener listener = EventHandler.create(ActionListener.class,
- invocationObject, "someObject", "source");
- listener.actionPerformed(ae);
-
- assertEquals(getObject(), invocationObject);
- assertEquals("setSomeObject", getMethodName());
-
- Object[] params = getParams();
- assertEquals("Number of params should be 1", 1, params.length);
- assertEquals(ae.getSource(), params[0]);
- }
-
- /**
- * The test checks the object created with the create() method call for
- * dot-separated property
- */
- public void testCreateWithDottedParameterCall() {
- Object invocationObject = new InvocationObject();
- ActionEvent ae = new ActionEvent(this, 0, "");
- ActionListener listener = EventHandler.create(ActionListener.class,
- invocationObject, "someText", "source.text");
- listener.actionPerformed(ae);
-
- assertEquals(getObject(), invocationObject);
- assertEquals("setSomeText", getMethodName());
-
- Object[] params = getParams();
- assertEquals("Number of params should be 1", 1, params.length);
- assertEquals(((EventHandlerTest) ae.getSource()).getText(), params[0]);
- }
-
- /**
- * The test checks the event is fired for object created with the create()
- */
- public void testCreateWithMethodCallWhichIsSetter() {
- InvocationObject invocationObject = new InvocationObject();
- SampleEvent event = new SampleEvent("bean");
-
- SampleListener listener = EventHandler.create(SampleListener.class,
- invocationObject, "doSomething", "i", null);
-
- listener.fireSampleEvent(event);
-
- assertEquals("doSomething", getMethodName());
- assertEquals(event.getI(), invocationObject.getIntValue());
- }
-
- /**
- * fireSampleEvent scenario
- */
- public void testCreateForStaticMethodAsPropertyGetter() {
- InvocationObject invocationObject = new InvocationObject();
- SampleEvent event = new SampleEvent("bean");
-
- SampleListener listener = EventHandler.create(SampleListener.class,
- invocationObject, "someValue", "j");
-
- listener.fireSampleEvent(event);
-
- assertEquals("setSomeValue", getMethodName());
- }
-
- /**
- * fileSampleEvent scenario by throwing RuntimeException
- */
- public void test_Create_WithThrowRuntimeException() {
- // Regression for Harmony-2434
- InvocationObject invocationObject = new InvocationObject();
- SampleListener listener = EventHandler.create(SampleListener.class,invocationObject, "throwRuntimeException");
- try {
- listener.fireSampleEvent(new SampleEvent("bean"));
- fail("Expected RuntimeException thrown");
- } catch (RuntimeException re) {
- // Expected
- }
- }
-
- /**
- *
- */
- public static Test suite() {
- // TestSuite suite = new TestSuite();
- //
- // suite.addTest(new
- // EventHandlerTest("testCreateClassObjectStringStringString_PropertyNull"));
- // return suite;
- return new TestSuite(EventHandlerTest.class);
- }
-
- public void logMethodCall(Object object, String methodName, Object[] params) {
- this.object = object;
- this.methodName = methodName;
- this.params = params;
- }
-
- public String getText() {
- return text;
- }
-
- private Object getObject() {
- return object;
- }
-
- private String getMethodName() {
- return methodName;
- }
-
- private Object[] getParams() {
- return params;
- }
-
- /*
- * Class under test for Object create(Class, Object, String)
- */
- public void testCreateClassObjectString() {
- MockTarget target = new MockTarget();
- MockButton button = new MockButton();
- PropertyChangeListener proxy = EventHandler.create(
- PropertyChangeListener.class, target, "setCalled");
- button.addPropertyChangeListener(proxy);
- button.setLabel("new label value");
- assertTrue(Proxy.isProxyClass(proxy.getClass()));
- assertTrue(target.isCalled());
- }
-
- /*
- * listenerInterface class is null
- */
- public void testCreateClassObjectString_ClassNull() {
- MockTarget target = new MockTarget();
- try {
- EventHandler.create(null, target, "setCalled");
- fail("Should throw NullPointerException.");
- } catch (NullPointerException e) {
- }
- }
-
- /*
- * listenerInterface is not a interface
- */
- public void testCreateClassObjectString_ClassInvalid() {
- MockTarget target = new MockTarget();
- try {
- EventHandler.create(MockButton.class, target, "setCalled");
- fail("Should throw IllegalArgumentException.");
- } catch (IllegalArgumentException e) {
- }
- }
-
- /*
- * the target object is null
- */
- public void testCreateClassObjectString_ObjectNull() {
- try {
- EventHandler
- .create(PropertyChangeListener.class, null, "setCalled");
- fail("Should throw NullPointerException.");
- } catch (NullPointerException e) {
- }
- }
-
- /*
- * the target's method is null
- */
- public void testCreateClassObjectString_MethodNull() {
- MockTarget target = new MockTarget();
- MockButton button = new MockButton();
- try {
- PropertyChangeListener proxy = EventHandler.create(
- PropertyChangeListener.class, target, null);
- fail("Should throw NullPointerException.");
- } catch (NullPointerException e) {
- }
- PropertyChangeListener proxy = EventHandler.create(
- PropertyChangeListener.class, target, "");
- button.addPropertyChangeListener(proxy);
- try {
- button.setLabel("new label value");
- fail("Should throw RuntimeException.");
- } catch (RuntimeException e) {
- }
- assertTrue(Proxy.isProxyClass(proxy.getClass()));
- }
-
- /*
- * the target's method is invalid
- */
- public void testCreateClassObjectString_MethodEmpty() {
- MockTarget target = new MockTarget();
- MockButton button = new MockButton();
- PropertyChangeListener proxy = EventHandler.create(
- PropertyChangeListener.class, target, "");
- button.addPropertyChangeListener(proxy);
- try {
- button.setLabel("new label value");
- fail("Should throw RuntimeException.");
- } catch (RuntimeException e) {
- }
- assertTrue(Proxy.isProxyClass(proxy.getClass()));
- }
-
- /*
- * Class under test for Object create(Class, Object, String, String)
- */
- public void testCreateClassObjectStringString() {
- MockTarget target = new MockTarget();
- MockButton button = new MockButton();
- PropertyChangeListener proxy = EventHandler.create(
- PropertyChangeListener.class, target, "text", "source.label");
- assertTrue(Proxy.isProxyClass(proxy.getClass()));
-
- button.addPropertyChangeListener(proxy);
- String newLabel = "New Value: set text.";
- button.setLabel(newLabel);
- assertEquals(MockButton.defaultName, target.getText());
- button.setLabel("New Value: set text2.");
- assertEquals(newLabel, target.getText());
- }
-
- /*
- * listenerInterface is null
- */
- public void testCreateClassObjectStringString_ClassNull() {
- MockTarget target = new MockTarget();
- try {
- EventHandler.create(null, target, "text", "source.label");
- fail("Should throw NullPointerException");
- } catch (NullPointerException e) {
- }
- }
-
- /*
- * the target object is null
- */
- public void testCreateClassObjectStringString_TargetNull() {
- try {
- EventHandler.create(PropertyChangeListener.class, null, "text",
- "source.label");
- fail("Should throw NullPointerException");
- } catch (NullPointerException e) {
- }
- }
-
- /*
- * the action is null
- */
- public void testCreateClassObjectStringString_ActionNull() {
- MockTarget target = new MockTarget();
- MockButton button = new MockButton();
- try {
- PropertyChangeListener proxy = EventHandler.create(
- PropertyChangeListener.class, target, null, "source.label");
- fail("should throw NPE");
- } catch (NullPointerException e) {
-
- }
- }
-
- /*
- * action is invalid
- */
- public void testCreateClassObjectStringString_ActionInvalid() {
- MockTarget target = new MockTarget();
- MockButton button = new MockButton();
- PropertyChangeListener proxy = EventHandler.create(
- PropertyChangeListener.class, target, "action_invalid",
- "source.label");
- assertTrue(Proxy.isProxyClass(proxy.getClass()));
-
- button.addPropertyChangeListener(proxy);
- String newLabel = "New Value: set text.";
- try {
- button.setLabel(newLabel);
- fail("Should throw RuntimeException.");
- } catch (RuntimeException e) {
- }
- }
-
- /*
- * propertyname is null
- */
- public void testCreateClassObjectStringString_PropertyNameNull() {
- MockTarget target = new MockTarget();
- MockButton button = new MockButton();
- PropertyChangeListener proxy = EventHandler.create(
- PropertyChangeListener.class, target, "text", null);
- assertTrue(Proxy.isProxyClass(proxy.getClass()));
-
- button.addPropertyChangeListener(proxy);
- String newLabel = "New Value: set text.";
- try {
- button.setLabel(newLabel);
- fail("Should throw NullPointerException.");
- } catch (Exception e) {
- }
- }
-
- /*
- * property name is invalid
- */
- public void testCreateClassObjectStringString_PropertyNameInvalid() {
- MockTarget target = new MockTarget();
- MockButton button = new MockButton();
- PropertyChangeListener proxy = EventHandler.create(
- PropertyChangeListener.class, target, "text",
- "source.label_invalid");
-
- assertTrue(Proxy.isProxyClass(proxy.getClass()));
-
- button.addPropertyChangeListener(proxy);
- String newLabel = "New Value: set text.";
-
- try {
- button.setLabel(newLabel);
- fail("Should throw NullPointerException.");
- } catch (RuntimeException e) {
- }
- }
-
- /*
- * Class under test for Object create(Class, Object, String, String, String)
- */
- public void testCreateClassObjectStringStringString() {
- MockTarget target = new MockTarget();
- MockButton button = new MockButton();
- PropertyChangeListener proxy = EventHandler.create(
- PropertyChangeListener.class, target, "text", "source.label",
- "propertyChange");
- assertTrue(Proxy.isProxyClass(proxy.getClass()));
-
- button.addPropertyChangeListener(proxy);
- String newLabel = "New Value: set text.";
- button.setLabel(newLabel);
- assertEquals(MockButton.defaultName, target.getText());
- button.setLabel("New Value: set text2.");
- assertEquals(newLabel, target.getText());
- }
-
- /*
- * listenerInterface is null
- */
- public void testCreateClassObjectStringStringString_ClassNull() {
- MockTarget target = new MockTarget();
- try {
- EventHandler.create(null, target, "text", "source.label",
- "propertyChange");
- fail("Should throw NullPointerException.");
- } catch (NullPointerException e) {
-
- }
- }
-
- /*
- * listenerInterface is invalid
- */
- public void testCreateClassObjectStringStringString_ClassInvalid() {
- MockTarget target = new MockTarget();
- try {
- EventHandler.create(String.class, target, "text", "source.label",
- "propertyChange");
- fail("Should throw IllegalArgumentException.");
- } catch (IllegalArgumentException e) {
- }
- }
-
- /*
- * the target object is null
- */
- public void testCreateClassObjectStringStringString_TargetNull() {
- try {
- EventHandler.create(PropertyChangeListener.class, null, "text",
- "source.label", "propertyChange");
- fail("Should throw NullPointerException.");
- } catch (NullPointerException e) {
- }
- }
-
- /*
- * action is null
- */
- public void testCreateClassObjectStringStringString_ActionNull() {
- MockTarget target = new MockTarget();
- MockButton button = new MockButton();
- try {
- PropertyChangeListener proxy = EventHandler.create(
- PropertyChangeListener.class, target, null, "source.label",
- "propertyChange");
- fail("should throw NPE");
- } catch (NullPointerException e) {
-
- }
- }
-
- /*
- * action is invalid
- */
- public void testCreateClassObjectStringStringString_ActionInvalid() {
- MockTarget target = new MockTarget();
- MockButton button = new MockButton();
- PropertyChangeListener proxy = EventHandler.create(
- PropertyChangeListener.class, target, "text_invalid",
- "source.label", "propertyChange");
- assertTrue(Proxy.isProxyClass(proxy.getClass()));
-
- button.addPropertyChangeListener(proxy);
- String newLabel = "New Value: set text.";
- try {
- button.setLabel(newLabel);
- fail("Should throw RuntimeException.");
- } catch (RuntimeException e) {
- }
- }
-
- /*
- * property name is null
- */
- public void testCreateClassObjectStringStringString_PropertyNull() {
- MockTarget target = new MockTarget();
- MockButton button = new MockButton();
- String newLabel = "New Value: set text.";
- PropertyChangeListener proxy = EventHandler.create(
- PropertyChangeListener.class, target, "text", null,
- "propertyChange");
-
- assertTrue(Proxy.isProxyClass(proxy.getClass()));
- button.addPropertyChangeListener(proxy);
-
- try {
- button.setLabel(newLabel);
- fail("Should throw RuntimeException.");
- } catch (RuntimeException e) {
- }
- }
-
- /*
- * property name is invalid
- */
- public void testCreateClassObjectStringStringString_PropertyInvalid() {
- MockTarget target = new MockTarget();
- MockButton button = new MockButton();
- PropertyChangeListener proxy = EventHandler.create(
- PropertyChangeListener.class, target, "text",
- "source.label.invalid", "propertyChange");
- assertTrue(Proxy.isProxyClass(proxy.getClass()));
-
- button.addPropertyChangeListener(proxy);
- String newLabel = "New Value: set text.";
- try {
- button.setLabel(newLabel);
- fail("Should throw RuntimeException.");
- } catch (RuntimeException e) {
- }
- }
-
- /*
- * listenerMethodName is null
- */
- public void testCreateClassObjectStringStringString_MethodNull() {
- MockTarget target = new MockTarget();
- MockButton button = new MockButton();
- PropertyChangeListener proxy = EventHandler.create(
- PropertyChangeListener.class, target, "text", "source.label",
- null);
- assertTrue(Proxy.isProxyClass(proxy.getClass()));
-
- button.addPropertyChangeListener(proxy);
- String newLabel = "New Value: set text.";
- button.setLabel(newLabel);
- assertEquals(MockButton.defaultName, target.getText());
- button.setLabel("New Value: set text2.");
- assertEquals(newLabel, target.getText());
- }
-
- /*
- * listenerMethodName is invalid
- */
- public void testCreateClassObjectStringStringString_MethodInvalid() {
- MockTarget target = new MockTarget();
- MockButton button = new MockButton();
- PropertyChangeListener proxy = EventHandler.create(
- PropertyChangeListener.class, target, "text", "source.label",
- "propertyChange_invalid");
- assertTrue(Proxy.isProxyClass(proxy.getClass()));
-
- button.addPropertyChangeListener(proxy);
- String newLabel = "New Value: set text.";
- button.setLabel(newLabel);
- assertNull(target.getText());
- }
-
- /*
- * public EventHandler(Object target, String action, String
- * eventPropertyName, String listenerMethodName)
- */
- public void testEventHandler() {
- MockTarget target = new MockTarget();
- String action = "text";
- String eventPropertyName = "source.label";
- String listenerMethodName = "propertyChange";
- EventHandler handler = new EventHandler(target, action,
- eventPropertyName, listenerMethodName);
- assertSame(target, handler.getTarget());
- assertSame(action, handler.getAction());
- assertSame(eventPropertyName, handler.getEventPropertyName());
- assertSame(listenerMethodName, handler.getListenerMethodName());
- }
-
- /*
- * target is null
- */
- public void testEventHandler_TargetNull() {
- String action = "text";
- String eventPropertyName = "source.label";
- String listenerMethodName = "propertyChange";
- try {
- EventHandler handler = new EventHandler(null, action,
- eventPropertyName, listenerMethodName);
- fail("should throw NPE");
- } catch (NullPointerException e) {
-
- }
- }
-
- /*
- * action is null
- */
- public void testEventHandler_ActionNull() {
- MockTarget target = new MockTarget();
- String eventPropertyName = "source.label";
- String listenerMethodName = "propertyChange";
- try {
- EventHandler handler = new EventHandler(target, null,
- eventPropertyName, listenerMethodName);
- fail("should throw NPE");
- } catch (NullPointerException e) {
-
- }
- EventHandler handler = new EventHandler(target, "action",
- eventPropertyName, listenerMethodName);
- assertSame(target, handler.getTarget());
- assertEquals("action", handler.getAction());
- assertSame(eventPropertyName, handler.getEventPropertyName());
- assertSame(listenerMethodName, handler.getListenerMethodName());
- }
-
- /*
- * EventProperty is null
- */
- public void testEventHandler_EventPropertyNull() {
- MockTarget target = new MockTarget();
- String action = "text";
- String listenerMethodName = "propertyChange";
- EventHandler handler = new EventHandler(target, action, null,
- listenerMethodName);
- assertSame(target, handler.getTarget());
- assertSame(action, handler.getAction());
- assertNull(handler.getEventPropertyName());
- assertSame(listenerMethodName, handler.getListenerMethodName());
- }
-
- /*
- * Method is null
- */
- public void testEventHandler_MethodNull() {
- MockTarget target = new MockTarget();
- String action = "text";
- String eventPropertyName = "source.label";
- EventHandler handler = new EventHandler(target, action,
- eventPropertyName, null);
- assertSame(target, handler.getTarget());
- assertSame(action, handler.getAction());
- assertSame(eventPropertyName, handler.getEventPropertyName());
- assertNull(handler.getListenerMethodName());
- }
-
- public void testInvoke_1() throws SecurityException, NoSuchMethodException {
- MockTarget target = new MockTarget();
- MockButton button = new MockButton();
- PropertyChangeListener proxy = EventHandler.create(
- PropertyChangeListener.class, target, "setCalled");
-
- String action = "text";
- String eventPropertyName = "source.label";
- EventHandler handler = new EventHandler(target, action,
- eventPropertyName, null);
- Method listenerMethod = PropertyChangeListener.class.getMethod(
- "propertyChange", new Class[] { PropertyChangeEvent.class });
- PropertyChangeEvent event = new PropertyChangeEvent(button, "label",
- "1", "5");
- handler.invoke(proxy, listenerMethod, new Object[] { event });
- assertEquals(button.getLabel(), target.getText());
- Method equalsMethod = Object.class.getMethod("equals",
- new Class[] { Object.class });
- assertEquals(Boolean.FALSE, handler.invoke(proxy, equalsMethod,
- new String[] { "mock" }));
- // Test null method with non-proxy Object.
- handler = new EventHandler(new Object(), "a", "a", "a");
- try {
- handler.invoke(new Object(), null, new Object[] {});
- fail("should throw NPE.");
- } catch (NullPointerException e) {
- // expected;
- }
- }
-
- public void testIncompatibleMethod() {
- MockTarget target = new MockTarget();
- MockButton button = new MockButton();
- PropertyChangeListener proxy = EventHandler.create(
- PropertyChangeListener.class, target, "Text", "source");
- assertTrue(Proxy.isProxyClass(proxy.getClass()));
-
- button.addPropertyChangeListener(proxy);
- String newLabel = "New Value: set text.";
- try {
- button.setLabel(newLabel);
- fail("Should throw RuntimeException.");
- } catch (RuntimeException e) {
-
- }
- }
-
- public void testCoverage_1() {
- MockTarget target = new MockTarget();
- MockButton button = new MockButton();
- PropertyChangeListener proxy = EventHandler.create(
- PropertyChangeListener.class, target, "Text", "");
- assertTrue(Proxy.isProxyClass(proxy.getClass()));
-
- button.addPropertyChangeListener(proxy);
- String newLabel = "New Value: set text.";
- try {
- button.setLabel(newLabel);
- fail("Should throw RuntimeException.");
- } catch (RuntimeException e) {
- }
-
- }
-
- public void testInvoke_extend1() {
- MockFish fish = new MockFish();
- MockFishTarget target = new MockFishTarget();
- PropertyChangeSupport support = new PropertyChangeSupport(fish);
- Object proxy = EventHandler.create(PropertyChangeListener.class,
- target, "action1");
- support.addPropertyChangeListener((PropertyChangeListener) proxy);
- PropertyChangeEvent event = new PropertyChangeEvent(fish, "name", "1",
- "5");
- support.firePropertyChange(event);
- assertEquals("action1", target.getActionRecord());
- }
-
- public void testInvoke_extend1_1() {
- MockFish fish = new MockFish();
- MockFishTarget target = new MockFishTarget();
- PropertyChangeSupport support = new PropertyChangeSupport(fish);
- Object proxy = EventHandler.create(PropertyChangeListener.class,
- target, "action4");
- support.addPropertyChangeListener((PropertyChangeListener) proxy);
- PropertyChangeEvent event = new PropertyChangeEvent(fish, "name", "1",
- "5");
- try {
- support.firePropertyChange(event);
- } catch (Exception e) {
-
- }
- assertEquals("action4", target.getActionRecord());
- }
-
- public void testInvoke_extend2() {
- MockFish fish = new MockFish();
- MockFishTarget target = new MockFishTarget();
- PropertyChangeSupport support = new PropertyChangeSupport(fish);
- Object proxy = EventHandler.create(PropertyChangeListener.class,
- target, "action2");
- support.addPropertyChangeListener((PropertyChangeListener) proxy);
- PropertyChangeEvent event = new PropertyChangeEvent(fish, "name", "1",
- "5");
- try {
- support.firePropertyChange(event);
- fail("Should throw exception");
- } catch (Exception e) {
- // e.printStackTrace();
- }
-
- }
-
- public void testInvoke_extend3() {
- MockFish fish = new MockFish();
- MockFishTarget target = new MockFishTarget();
- PropertyChangeSupport support = new PropertyChangeSupport(fish);
- Object proxy = EventHandler.create(PropertyChangeListener.class,
- target, "a", "source.a");
- support.addPropertyChangeListener((PropertyChangeListener) proxy);
- PropertyChangeEvent event = new PropertyChangeEvent(fish, "name", "1",
- "5");
- support.firePropertyChange(event);
- assertEquals("boolean:true", target.getActionRecord());
- }
-
- public void testInvoke_extend4() {
- MockFish fish = new MockFish();
- MockFishTarget target = new MockFishTarget();
- PropertyChangeSupport support = new PropertyChangeSupport(fish);
- Object proxy = EventHandler.create(PropertyChangeListener.class,
- target, "b", "source.a");
- support.addPropertyChangeListener((PropertyChangeListener) proxy);
- PropertyChangeEvent event = new PropertyChangeEvent(fish, "name", "1",
- "5");
- support.firePropertyChange(event);
- assertEquals("Boolean:true", target.getActionRecord());
- }
-
- public void testInvoke_extend4_BooleanObject() {
- MockFish fish = new MockFish();
- MockFishTarget target = new MockFishTarget();
- PropertyChangeSupport support = new PropertyChangeSupport(fish);
- Object proxy = EventHandler.create(PropertyChangeListener.class,
- target, "a", "source.booleanObject");
-
- support.addPropertyChangeListener((PropertyChangeListener) proxy);
- PropertyChangeEvent event = new PropertyChangeEvent(fish, "name", "1",
- "5");
- support.firePropertyChange(event);
- assertEquals("boolean:true", target.getActionRecord());
- }
-
- public void testInvoke_extend5() {
- MockFish fish = new MockFish();
- MockFishTarget target = new MockFishTarget();
- PropertyChangeSupport support = new PropertyChangeSupport(fish);
- Object proxy = EventHandler.create(PropertyChangeListener.class,
- target, "int", "source.int");
- support.addPropertyChangeListener((PropertyChangeListener) proxy);
- PropertyChangeEvent event = new PropertyChangeEvent(fish, "name", "1",
- "5");
- support.firePropertyChange(event);
- assertEquals("int:1", target.getActionRecord());
- }
-
- public void testInvoke_extend6() {
- MockFish fish = new MockFish();
- MockFishTarget target = new MockFishTarget();
- PropertyChangeSupport support = new PropertyChangeSupport(fish);
- Object proxy = EventHandler.create(PropertyChangeListener.class,
- target, "char", "source.char");
- support.addPropertyChangeListener((PropertyChangeListener) proxy);
- PropertyChangeEvent event = new PropertyChangeEvent(fish, "name", "1",
- "5");
- support.firePropertyChange(event);
- assertEquals("char:a", target.getActionRecord());
- }
-
- public void testInvoke_extend7() {
- MockFish fish = new MockFish();
- MockFishTarget target = new MockFishTarget();
- PropertyChangeSupport support = new PropertyChangeSupport(fish);
- Object proxy = EventHandler.create(PropertyChangeListener.class,
- target, "byte", "source.byte");
- support.addPropertyChangeListener((PropertyChangeListener) proxy);
- PropertyChangeEvent event = new PropertyChangeEvent(fish, "name", "1",
- "5");
- support.firePropertyChange(event);
- assertEquals("byte:10", target.getActionRecord());
- }
-
- public void testInvoke_extend8() {
- MockFish fish = new MockFish();
- MockFishTarget target = new MockFishTarget();
- PropertyChangeSupport support = new PropertyChangeSupport(fish);
- Object proxy = EventHandler.create(PropertyChangeListener.class,
- target, "short", "source.short");
- support.addPropertyChangeListener((PropertyChangeListener) proxy);
- PropertyChangeEvent event = new PropertyChangeEvent(fish, "name", "1",
- "5");
- support.firePropertyChange(event);
- assertEquals("short:100", target.getActionRecord());
- }
-
- public void testInvoke_extend9() {
- MockFish fish = new MockFish();
- MockFishTarget target = new MockFishTarget();
- PropertyChangeSupport support = new PropertyChangeSupport(fish);
- Object proxy = EventHandler.create(PropertyChangeListener.class,
- target, "long", "source.long");
- support.addPropertyChangeListener((PropertyChangeListener) proxy);
- PropertyChangeEvent event = new PropertyChangeEvent(fish, "name", "1",
- "5");
- support.firePropertyChange(event);
- assertEquals("long:1000", target.getActionRecord());
- }
-
- public void testInvoke_extend10() {
- MockFish fish = new MockFish();
- MockFishTarget target = new MockFishTarget();
- PropertyChangeSupport support = new PropertyChangeSupport(fish);
- Object proxy = EventHandler.create(PropertyChangeListener.class,
- target, "float", "source.float");
- support.addPropertyChangeListener((PropertyChangeListener) proxy);
- PropertyChangeEvent event = new PropertyChangeEvent(fish, "name", "1",
- "5");
- support.firePropertyChange(event);
- assertEquals("float:2.2", target.getActionRecord());
- }
-
- public void testInvoke_extend11() {
- MockFish fish = new MockFish();
- MockFishTarget target = new MockFishTarget();
- PropertyChangeSupport support = new PropertyChangeSupport(fish);
- Object proxy = EventHandler.create(PropertyChangeListener.class,
- target, "double", "source.double");
- support.addPropertyChangeListener((PropertyChangeListener) proxy);
- PropertyChangeEvent event = new PropertyChangeEvent(fish, "name", "1",
- "5");
- support.firePropertyChange(event);
- assertEquals("double:3.3", target.getActionRecord());
- }
-
- /**
- * @tests java.beans.EventHandler#create(java.lang.Class<T>,
- * java.lang.Object, java.lang.String))
- */
- public void testEventHandlerCreate() {
- // Regression for HARMONY-429
- EventHandler.create(FredListener.class, new Untitled1(), "i", "i")
- .fireFredEvent(new FredEvent("bean2"));
- }
-
- /**
- * Checks some invalid property cases Regression for HARMONY-1884
- *
- * Note: this test fails on RI and it is considered as Non-Bug Difference,
- * please refer HARMONY-1884 for details
- */
- public void testInvalidProperties_HY1884() {
- BeanWithInvalidProps bean = new BeanWithInvalidProps();
- Object proxy;
-
- // "prop1" and "prop2" is neither the name of valid property nor the
- // name of any public method
-
- // setter without parameter
- proxy = EventHandler
- .create(PropertyChangeListener.class, bean, "prop1");
- try {
- ((PropertyChangeListener) proxy)
- .propertyChange(new PropertyChangeEvent(bean, "prop1", "1",
- "2"));
- fail();
- } catch (Exception e) {
- // expected
- }
-
- // "is" prefix for big Boolean
- proxy = EventHandler.create(PropertyChangeListener.class, bean,
- "goodProp3", "source.prop2");
- try{
- ((PropertyChangeListener) proxy)
- .propertyChange(new PropertyChangeEvent(bean, "goodProp3",
- Boolean.TRUE, Boolean.FALSE));
- fail("Should throw NPE");
- }catch(NullPointerException e){
- }
- }
-
- public static class BeanWithInvalidProps {
- // setter should have a parameter
- public void setProp1() {
- }
-
- // Introspector doesn't support "is" prefix for big Boolean
- public Boolean isProp2() {
- return new Boolean(true);
- }
-
- // needed to test prop2
- public void setGoodProp3(boolean value) {
- }
- }
-
- public interface FredListener extends EventListener {
-
- public void fireFredEvent(FredEvent event);
- }
-
- public static class FredEvent extends EventObject {
-
- private static final long serialVersionUID = 1L;
-
- private static int i;
-
- public FredEvent(Object source) {
- super(source);
- }
-
- public static int getI() {
- return i;
- }
-
- public static void setI(int j) {
- i = j;
- }
- }
-
- public static class Untitled1 {
-
- private int i;
-
- public int getI() {
- return i;
- }
-
- public void setI(int i) {
- // System.out.println("Untitled1 : setI()");
- this.i = i;
- }
- }
-
- public static class MockFish {
-
- String name;
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public boolean isA() {
- return true;
- }
-
- public boolean isBooleanObject() {
- return true;
- }
-
- public int getInt() {
- return 1;
- }
-
- public char getChar() {
- return 'a';
- }
-
- public byte getByte() {
- return 10;
- }
-
- public short getShort() {
- return 100;
- }
-
- public long getLong() {
- return 1000;
- }
-
- public float getFloat() {
- return 2.2f;
- }
-
- public double getDouble() {
- return 3.3;
- }
- }
-
- public static class MockFishTarget {
-
- String actionRecord;
-
- public void action1() {
- this.actionRecord = "action1";
- }
-
- public void setAction2(String value) {
- this.actionRecord = "action2";
- }
-
- public void action4() {
- this.actionRecord = "action4";
- }
-
- public void action4(EventObject event) {
- this.actionRecord = "action4";
- }
-
- public String getActionRecord() {
- return actionRecord;
- }
-
- public void setA(boolean value) {
- this.actionRecord = "boolean:" + Boolean.valueOf(value).toString();
- }
-
- public void setB(Boolean value) {
- this.actionRecord = "Boolean:" + value.toString();
- }
-
- public void setInt(int value) {
- this.actionRecord = "int:" + value;
- }
-
- public void setChar(char value) {
- this.actionRecord = "char:" + value;
- }
-
- public void setShort(short value) {
- this.actionRecord = "short:" + value;
- }
-
- public void setByte(byte value) {
- this.actionRecord = "byte:" + value;
- }
-
- public void setLong(long value) {
- this.actionRecord = "long:" + value;
- }
-
- public void setFloat(float value) {
- this.actionRecord = "float:" + value;
- }
-
- public void setDouble(double value) {
- this.actionRecord = "double:" + value;
- }
-
- }
-
- public static class MockTarget {
-
- private boolean called;
-
- private String text;
-
- public MockTarget() {
- this.called = false;
- }
-
- public void setCalled() {
- this.called = true;
- }
-
- public boolean isCalled() {
- return this.called;
- }
-
- public void setText(String text) {
- this.text = text;
- }
-
- public String getText() {
- return this.text;
- }
- }
-
- public class InvocationObject {
-
- private String text;
-
- private int intValue = -1;
-
- public InvocationObject() {
- }
-
- public void doSomething() {
- logMethodCall(this, "doSomething", new Object[] {});
- }
-
- public void doSomething(int intValue) {
- this.intValue = intValue;
-
- logMethodCall(this, "doSomething", new Object[] { new Integer(
- intValue) });
- }
-
- public void setSomeObject(Object object) {
- logMethodCall(this, "setSomeObject", new Object[] { object });
- }
-
- public void setSomeText(String text) {
- this.text = text;
-
- logMethodCall(this, "setSomeText", new Object[] { text });
- }
-
- public String getSomeText() {
- return text;
- }
-
- public int getIntValue() {
- return intValue;
- }
-
- public void setIntValue(int intValue) {
- this.intValue = intValue;
-
- logMethodCall(this, "setIntValue", new Object[] { new Integer(
- intValue) });
- }
-
- public void setSomeValue(int i) {
- logMethodCall(this, "setSomeValue", new Object[] { new Integer(
- intValue) });
- }
-
- public void throwRuntimeException() {
- throw new RuntimeException("forced throw RuntimeException");
- }
- }
-}
diff --git a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/EventSetDescriptorTest.java b/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/EventSetDescriptorTest.java
deleted file mode 100644
index 51e3ef3..0000000
--- a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/EventSetDescriptorTest.java
+++ /dev/null
@@ -1,1416 +0,0 @@
-/*
- * 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.java.beans;
-
-import java.awt.event.ActionListener;
-import java.beans.EventSetDescriptor;
-import java.beans.IntrospectionException;
-import java.beans.MethodDescriptor;
-import java.io.IOException;
-import java.io.Serializable;
-import java.lang.reflect.Method;
-
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-
-import org.apache.harmony.beans.tests.support.OtherBean;
-import org.apache.harmony.beans.tests.support.SampleListener;
-import org.apache.harmony.beans.tests.support.mock.MockFakeListener;
-import org.apache.harmony.beans.tests.support.mock.MockPropertyChangeEvent;
-import org.apache.harmony.beans.tests.support.mock.MockPropertyChangeListener;
-import org.apache.harmony.beans.tests.support.mock.MockPropertyChangeValidListener;
-
-
-/**
- * Unit test for EventSetDescriptor
- */
-public class EventSetDescriptorTest extends TestCase {
-
- public EventSetDescriptorTest() {}
-
- public EventSetDescriptorTest(String s) {
- super(s);
- }
-
- public static TestSuite suite() {
-// TestSuite suite = new TestSuite();
- TestSuite suite = new TestSuite(EventSetDescriptorTest.class);
-
-// suite.addTest(new EventSetDescriptorTest(
-// "testEventSetDescriptorClassStringClassString"));
- return suite;
- }
-
- /*
- * Class under test for void EventSetDescriptor(Class, String, Class,
- * String)
- */
- public void testEventSetDescriptorClassStringClassString()
- throws IntrospectionException, ClassNotFoundException, IOException,
- SecurityException, NoSuchMethodException {
- String eventSetName = "mockPropertyChange";
- String listenerMethodName = eventSetName;
- Class<MockSourceClass> sourceClass = MockSourceClass.class;
- Class<?> listenerType = MockPropertyChangeListener.class;
- EventSetDescriptor esd = null;
- esd = new EventSetDescriptor(sourceClass, eventSetName, listenerType,
- listenerMethodName);
- String listenerName = getUnQualifiedClassName(listenerType);
- Method addMethod = sourceClass.getMethod("add" + listenerName,
- new Class[] { listenerType });
- Method removeMethod = sourceClass.getMethod("remove" + listenerName,
- new Class[] { listenerType });
-
- assertEquals(addMethod, esd.getAddListenerMethod());
- assertEquals(removeMethod, esd.getRemoveListenerMethod());
- assertNull(esd.getGetListenerMethod());
- assertEquals(1, esd.getListenerMethods().length);
- assertEquals(listenerMethodName, esd.getListenerMethods()[0].getName());
- assertEquals(1, esd.getListenerMethodDescriptors().length);
- assertEquals(listenerMethodName, esd.getListenerMethodDescriptors()[0]
- .getMethod().getName());
-
- assertEquals(listenerType, esd.getListenerType());
- assertTrue(esd.isInDefaultEventSet());
- assertFalse(esd.isUnicast());
-
- esd = new EventSetDescriptor(AnObject.class, "something",
- AnObjectListener.class, "aMethod");
- }
-
- public void testEventSetDescriptorClassStringClassString2()
- throws IntrospectionException, ClassNotFoundException, IOException,
- SecurityException, NoSuchMethodException {
- String eventSetName = "mockPropertyChange";
- String listenerMethodName = eventSetName;
- Class<MockSourceClass> sourceClass = MockSourceClass.class;
- Class<?> listenerType = MockPropertyChangeListener.class;
-
- try {
- new EventSetDescriptor(sourceClass, "FFF", listenerType,
- listenerMethodName);
- fail("Should throw IntrospectionException.");
- } catch (IntrospectionException e) {
- // valid
- }
- }
-
- /*
- * Sourceclass==null
- */
- public void testEventSetDescriptorClassStringClassString_sourceClassNull()
- throws IntrospectionException {
- String eventSetName = "mockPropertyChange";
- String listenerMethodName = eventSetName;
- Class<?> sourceClass = null;
- Class<?> listenerType = MockPropertyChangeListener.class;
- try {
- new EventSetDescriptor(sourceClass, eventSetName, listenerType,
- listenerMethodName);
- fail("Should throw NullPointerException.");
- } catch (NullPointerException e) {
- }
- }
-
- /*
- * Event is null
- */
- public void testEventSetDescriptorClassStringClassString_EventNull()
- throws IntrospectionException {
- String eventSetName = "mockPropertyChange";
- String listenerMethodName = eventSetName;
- Class<MockSourceClass> sourceClass = MockSourceClass.class;
- Class<?> listenerType = MockPropertyChangeListener.class;
- try {
- new EventSetDescriptor(sourceClass, null, listenerType,
- listenerMethodName);
- fail("Should throw NullPointerException.");
- } catch (NullPointerException e) {
- }
- }
-
- /*
- * Eventsetname=""
- */
- public void testEventSetDescriptorClassStringClassString_EventEmpty()
- throws IntrospectionException {
- String eventSetName = "mockPropertyChange";
- String listenerMethodName = eventSetName;
- Class<MockSourceClass> sourceClass = MockSourceClass.class;
- Class<?> listenerType = MockPropertyChangeListener.class;
-
- try {
- // RI doesn't throw exception here but this doesn't really make
- // much sense. Moreover, it is against the java.beans
- // package description: null values or empty Strings are not
- // valid parameters unless explicitly stated
- new EventSetDescriptor(sourceClass, "", listenerType,
- listenerMethodName);
- } catch (IntrospectionException e) {
- // valid
- }
- }
-
- /*
- * Event is not a subclass of java.util.EventObject.
- */
- public void testEventSetDescriptorClassStringClassString_EventInvalid()
- throws IntrospectionException {
- String eventSetName = "MockFake";
- String listenerMethodName = "mockNotAEventObject";
- Class<MockSourceClass> sourceClass = MockSourceClass.class;
- Class<?> listenerType = MockPropertyChangeListener.class;
- EventSetDescriptor esd = new EventSetDescriptor(sourceClass,
- eventSetName, listenerType, listenerMethodName);
-
- assertEquals(listenerMethodName, esd.getListenerMethods()[0].getName());
- }
-
- public void testEventSetDescriptorClassStringClassString_AmbiguousEvent()
- throws IntrospectionException, ClassNotFoundException, IOException,
- SecurityException, NoSuchMethodException {
- String eventSetName = "mockPropertyChange";
- String listenerMethodName = eventSetName;
- Class<MockSourceClass> sourceClass = MockSourceClass.class;
- Class<?> listenerType = org.apache.harmony.beans.tests.support.mock.MockPropertyChangeListener2.class;
- EventSetDescriptor esd = new EventSetDescriptor(sourceClass,
- eventSetName, listenerType, listenerMethodName);
-
- String listenerName = getUnQualifiedClassName(listenerType);
- Method addMethod = sourceClass.getMethod("add" + listenerName,
- new Class[] { listenerType });
- Method removeMethod = sourceClass.getMethod("remove" + listenerName,
- new Class[] { listenerType });
-
- assertEquals(addMethod, esd.getAddListenerMethod());
- assertEquals(removeMethod, esd.getRemoveListenerMethod());
- assertNull(esd.getGetListenerMethod());
- assertEquals(1, esd.getListenerMethods().length);
- assertEquals(listenerMethodName, esd.getListenerMethods()[0].getName());
- assertEquals(1, esd.getListenerMethodDescriptors().length);
- assertEquals(listenerMethodName, esd.getListenerMethodDescriptors()[0]
- .getMethod().getName());
-
- assertEquals(listenerType, esd.getListenerType());
- assertTrue(esd.isInDefaultEventSet());
- assertFalse(esd.isUnicast());
- }
-
- /*
- * ListenerType=null
- */
- public void testEventSetDescriptorClassStringClassString_ListenerNull()
- throws IntrospectionException {
- String eventSetName = "mockPropertyChange";
- String listenerMethodName = eventSetName;
- Class<MockSourceClass> sourceClass = MockSourceClass.class;
- Class<?> listenerType = null;
- try {
- new EventSetDescriptor(sourceClass, eventSetName, listenerType,
- listenerMethodName);
- fail("Should throw NullPointerException.");
- } catch (NullPointerException e) {
- }
- }
-
- /*
- * ListenerType does not implement any EventListener
- */
- public void testEventSetDescriptorClassStringClassString_ListenerInvalid()
- throws IntrospectionException, SecurityException,
- NoSuchMethodException {
- String eventSetName = "MockPropertyChange";
- String listenerMethodName = "mockPropertyChange";
- Class<MockSourceClass> sourceClass = MockSourceClass.class;
- Class<?> listenerType = MockFakeListener.class;
- EventSetDescriptor esd = new EventSetDescriptor(sourceClass,
- eventSetName, listenerType, listenerMethodName);
- String listenerName = getUnQualifiedClassName(listenerType);
- Method addMethod = sourceClass.getMethod("add" + listenerName,
- new Class[] { listenerType });
- Method removeMethod = sourceClass.getMethod("remove" + listenerName,
- new Class[] { listenerType });
-
- assertEquals(addMethod, esd.getAddListenerMethod());
- assertEquals(removeMethod, esd.getRemoveListenerMethod());
- assertNull(esd.getGetListenerMethod());
- assertEquals(1, esd.getListenerMethods().length);
- assertEquals(listenerMethodName, esd.getListenerMethods()[0].getName());
- assertEquals(1, esd.getListenerMethodDescriptors().length);
- assertEquals(listenerMethodName, esd.getListenerMethodDescriptors()[0]
- .getMethod().getName());
-
- assertEquals(listenerType, esd.getListenerType());
- assertTrue(esd.isInDefaultEventSet());
- assertFalse(esd.isUnicast());
- }
-
- /*
- * listenerMethodName is null
- */
- public void testEventSetDescriptorClassStringClassString_listenerMethodNameNull()
- throws IntrospectionException {
- String eventSetName = "mockPropertyChange";
- String listenerMethodName = null;
- Class<MockSourceClass> sourceClass = MockSourceClass.class;
- Class<?> listenerType = MockPropertyChangeListener.class;
- try {
- new EventSetDescriptor(sourceClass, eventSetName, listenerType,
- listenerMethodName);
- fail("Should throw NullPointerException.");
- } catch (NullPointerException e) {
- // expected
- }
- }
-
- /*
- * No this method specified by listenerMethodName
- */
- public void testEventSetDescriptorClassStringClassString_listenerMethodNameInvalid() {
- String eventSetName = "mockPropertyChange";
- String listenerMethodName = "";
- Class<MockSourceClass> sourceClass = MockSourceClass.class;
- Class<?> listenerType = MockPropertyChangeListener.class;
- try {
- new EventSetDescriptor(sourceClass, eventSetName, listenerType,
- listenerMethodName);
- fail("Should throw IntrospectionException.");
- } catch (IntrospectionException e) {
- }
- }
-
- /*
- * Class under test for void EventSetDescriptor(Class, String, Class,
- * String[], String, String)
- */
- public void testEventSetDescriptorClassStringClassStringArrayStringString()
- throws IntrospectionException {
- Class<MockSourceClass> sourceClass = MockSourceClass.class;
- String eventSetName = "MockPropertyChange";
- Class<?> listenerType = MockPropertyChangeListener.class;
- String[] listenerMethodNames = { "mockPropertyChange",
- "mockPropertyChange2", };
- String addMethod = "addMockPropertyChangeListener";
- String removeMethod = "removeMockPropertyChangeListener";
-
- EventSetDescriptor esd = new EventSetDescriptor(sourceClass,
- eventSetName, listenerType, listenerMethodNames, addMethod,
- removeMethod);
-
- assertEquals(addMethod, esd.getAddListenerMethod().getName());
- assertEquals(removeMethod, esd.getRemoveListenerMethod().getName());
- assertNull(esd.getGetListenerMethod());
- assertEquals(2, esd.getListenerMethods().length);
- assertEquals(listenerMethodNames[0], esd.getListenerMethods()[0]
- .getName());
- assertEquals(listenerMethodNames[1], esd.getListenerMethods()[1]
- .getName());
- assertEquals(MockPropertyChangeEvent.class, esd.getListenerMethods()[1]
- .getParameterTypes()[0]);
- assertEquals(2, esd.getListenerMethodDescriptors().length);
- assertEquals(listenerMethodNames[0],
- esd.getListenerMethodDescriptors()[0].getMethod().getName());
- assertEquals(listenerMethodNames[1],
- esd.getListenerMethodDescriptors()[1].getMethod().getName());
-
- assertEquals(listenerType, esd.getListenerType());
- assertTrue(esd.isInDefaultEventSet());
- assertFalse(esd.isUnicast());
- }
-
- /*
- * sourceClass is null
- */
- public void testEventSetDescriptorClassStringClassStringArrayStringString_sourceClassNull()
- throws IntrospectionException {
- Class<?> sourceClass = null;
- String eventSetName = "MockPropertyChange";
- Class<?> listenerType = MockPropertyChangeListener.class;
- String[] listenerMethodNames = { "mockPropertyChange",
- "mockPropertyChange2", };
- String addMethod = "addMockPropertyChangeListener";
- String removeMethod = "removeMockPropertyChangeListener";
-
- try {
- new EventSetDescriptor(sourceClass, eventSetName, listenerType,
- listenerMethodNames, addMethod, removeMethod);
- fail("Should throw NullPointerException.");
- } catch (NullPointerException e) {
- }
- }
-
- /*
- * Event is null
- */
- public void testEventSetDescriptorClassStringClassStringArrayStringString_eventNull()
- throws IntrospectionException {
- Class<MockSourceClass> sourceClass = MockSourceClass.class;
- String eventSetName = "MockPropertyChange";
- Class<?> listenerType = MockPropertyChangeListener.class;
- String[] listenerMethodNames = { "mockPropertyChange",
- "mockPropertyChange2", };
- String addMethod = "addMockPropertyChangeListener";
- String removeMethod = "removeMockPropertyChangeListener";
-
- EventSetDescriptor esd = new EventSetDescriptor(sourceClass,
- eventSetName, listenerType, listenerMethodNames, addMethod,
- removeMethod);
- assertEquals(addMethod, esd.getAddListenerMethod().getName());
- assertEquals(removeMethod, esd.getRemoveListenerMethod().getName());
- assertNull(esd.getGetListenerMethod());
- assertEquals(2, esd.getListenerMethods().length);
- assertEquals(listenerMethodNames[0], esd.getListenerMethods()[0]
- .getName());
- assertEquals(listenerMethodNames[1], esd.getListenerMethods()[1]
- .getName());
- assertEquals(2, esd.getListenerMethodDescriptors().length);
- assertEquals(listenerMethodNames[0],
- esd.getListenerMethodDescriptors()[0].getMethod().getName());
- assertEquals(listenerMethodNames[1],
- esd.getListenerMethodDescriptors()[1].getMethod().getName());
-
- assertEquals(listenerType, esd.getListenerType());
- assertTrue(esd.isInDefaultEventSet());
- assertFalse(esd.isUnicast());
- //Regression for HARMONY-1504
- try {
- new EventSetDescriptor(sourceClass,
- null, listenerType, listenerMethodNames, addMethod,
- removeMethod);
- fail("NullPointerException expected");
- } catch (NullPointerException e) {
- //expected
- }
-
- }
-
- /*
- * Eventsetname=""
- */
- public void testEventSetDescriptorClassStringClassStringArrayStringString_eventEmpty()
- throws IntrospectionException {
- Class<MockSourceClass> sourceClass = MockSourceClass.class;
- String eventSetName = "";
- Class<?> listenerType = MockPropertyChangeListener.class;
- String[] listenerMethodNames = { "mockPropertyChange",
- "mockPropertyChange2", };
- String addMethod = "addMockPropertyChangeListener";
- String removeMethod = "removeMockPropertyChangeListener";
-
- try {
- // RI doesn't throw exception here but this
- // is against the java.beans package description:
- // null values or empty Strings are not
- // valid parameters unless explicitly stated
- EventSetDescriptor esd = new EventSetDescriptor(sourceClass,
- eventSetName, listenerType, listenerMethodNames, addMethod,
- removeMethod);
- } catch (IntrospectionException e) {
- // valid
- }
- }
-
- /*
- * listenerType=null
- */
- public void testEventSetDescriptorClassStringClassStringArrayStringString_ListenerNull()
- throws IntrospectionException {
- Class<MockSourceClass> sourceClass = MockSourceClass.class;
- String eventSetName = "MockPropertyChange";
- Class<?> listenerType = null;
- String[] listenerMethodNames = { "mockPropertyChange",
- "mockPropertyChange2", };
- String addMethod = "addMockPropertyChangeListener";
- String removeMethod = "removeMockPropertyChangeListener";
- try {
- new EventSetDescriptor(sourceClass, eventSetName, listenerType,
- listenerMethodNames, addMethod, removeMethod);
- fail("Should throw NullPointerException.");
- } catch (NullPointerException e) {
- }
-
- }
-
- /*
- * listenerMethodNames=null
- */
- public void testEventSetDescriptorClassStringClassStringArrayStringString_listenerMethodNamesNull()
- throws IntrospectionException {
- Class<MockSourceClass> sourceClass = MockSourceClass.class;
- String eventSetName = "MockPropertyChange";
- Class<?> listenerType = MockPropertyChangeListener.class;
- String[] listenerMethodNames = null;
- String addMethod = "addMockPropertyChangeListener";
- String removeMethod = "removeMockPropertyChangeListener";
- try {
- new EventSetDescriptor(sourceClass, eventSetName, listenerType,
- listenerMethodNames, addMethod, removeMethod);
- fail("Should throw NullPointerException.");
- } catch (NullPointerException e) {
- // expected
- }
-
- try {
- new EventSetDescriptor(sourceClass, eventSetName, listenerType,
- new String[] { null }, addMethod, removeMethod);
- fail("Should throw NullPointerException.");
- } catch (NullPointerException e) {
- // expected
- }
- }
-
- /*
- * contain invalid method.
- */
- public void testEventSetDescriptorClassStringClassStringArrayStringString_listenerMethodNamesInvalid() {
- Class<MockSourceClass> sourceClass = MockSourceClass.class;
- String eventSetName = "MockPropertyChange";
- Class<?> listenerType = MockPropertyChangeListener.class;
- String[] listenerMethodNames = { "mockPropertyChange_Invalid",
- "mockPropertyChange2", };
- String addMethod = "addMockPropertyChangeListener";
- String removeMethod = "removeMockPropertyChangeListener";
- try {
- new EventSetDescriptor(sourceClass, eventSetName, listenerType,
- listenerMethodNames, addMethod, removeMethod);
- fail("Should throw IntrospectionException.");
- } catch (IntrospectionException e) {
- }
- }
-
- public void testEventSetDescriptorClassStringClassStringArrayStringString_listenerMethodNamesValid()
- throws Exception {
- Class<MockSourceClass> sourceClass = MockSourceClass.class;
- String eventSetName = "MockPropertyChange";
- Class<?> listenerType = MockPropertyChangeValidListener.class;
- String[] listenerMethodNames = { "mockPropertyChange_Valid",
- "mockPropertyChange2", };
- String addMethod = "addMockPropertyChangeListener";
- String removeMethod = "removeMockPropertyChangeListener";
- EventSetDescriptor eventSetDescriptor = new EventSetDescriptor(
- sourceClass, eventSetName, listenerType, listenerMethodNames,
- addMethod, removeMethod);
- assertEquals(2, eventSetDescriptor.getListenerMethods().length);
- }
-
- public void testEventSetDescriptorClassStringClassStringArrayStringString_listenerMethodNamesEmpty()
- throws IntrospectionException {
- Class<MockSourceClass> sourceClass = MockSourceClass.class;
- String eventSetName = "MockPropertyChange";
- Class<?> listenerType = MockPropertyChangeListener.class;
- String[] listenerMethodNames = {};
- String addMethod = "addMockPropertyChangeListener";
- String removeMethod = "removeMockPropertyChangeListener";
- EventSetDescriptor esd = new EventSetDescriptor(sourceClass,
- eventSetName, listenerType, listenerMethodNames, addMethod,
- removeMethod);
- assertEquals(0, esd.getListenerMethods().length);
- }
-
- /*
- * addListenerMethodName==null
- */
- public void testEventSetDescriptorClassStringClassStringArrayStringString_addListenerMethodNameNull()
- throws IntrospectionException {
- Class<MockSourceClass> sourceClass = MockSourceClass.class;
- String eventSetName = "MockPropertyChange";
- Class<?> listenerType = MockPropertyChangeListener.class;
- String[] listenerMethodNames = { "mockPropertyChange",
- "mockPropertyChange2", };
- String addMethod = null;
- String removeMethod = "removeMockPropertyChangeListener";
- EventSetDescriptor esd = new EventSetDescriptor(sourceClass,
- eventSetName, listenerType, listenerMethodNames, addMethod,
- removeMethod);
- assertNull(esd.getAddListenerMethod());
- }
-
- /*
- * addListenerMethodName is invalid (args)
- */
- public void testEventSetDescriptorClassStringClassStringArrayStringString_addListenerMethodNameInvalid()
- throws IntrospectionException {
- Class<MockSourceClass> sourceClass = MockSourceClass.class;
- String eventSetName = "MockPropertyChange";
- Class<?> listenerType = MockPropertyChangeListener.class;
- String[] listenerMethodNames = { "mockPropertyChange",
- "mockPropertyChange2", };
- String addMethod = "addMockPropertyChangeListener_Invalid";
- String removeMethod = "removeMockPropertyChangeListener";
- try {
- new EventSetDescriptor(sourceClass, eventSetName, listenerType,
- listenerMethodNames, addMethod, removeMethod);
- fail("Should throw IntrospectionException.");
- } catch (IntrospectionException e) {
- }
- }
-
- /*
- * removeListenerMethodName==null
- */
- public void testEventSetDescriptorClassStringClassStringArrayStringString_removeListenerMethodNameNull()
- throws IntrospectionException {
- Class<MockSourceClass> sourceClass = MockSourceClass.class;
- String eventSetName = "MockPropertyChange";
- Class<?> listenerType = MockPropertyChangeListener.class;
- String[] listenerMethodNames = { "mockPropertyChange",
- "mockPropertyChange2", };
- String addMethod = "removeMockPropertyChangeListener";
- String removeMethod = null;
- EventSetDescriptor esd = new EventSetDescriptor(sourceClass,
- eventSetName, listenerType, listenerMethodNames, addMethod,
- removeMethod);
- assertNull(esd.getRemoveListenerMethod());
- }
-
- /*
- * removeListenerMethodName is invalid
- */
- public void testEventSetDescriptorClassStringClassStringArrayStringString_removeListenerMethodNameInvalid()
- throws IntrospectionException {
- Class<MockSourceClass> sourceClass = MockSourceClass.class;
- String eventSetName = "MockPropertyChange";
- Class<?> listenerType = MockPropertyChangeListener.class;
- String[] listenerMethodNames = { "mockPropertyChange",
- "mockPropertyChange2", };
- String addMethod = "removeMockPropertyChangeListener";
- String removeMethod = "addMockPropertyChangeListener_Invalid";
- try {
- new EventSetDescriptor(sourceClass, eventSetName, listenerType,
- listenerMethodNames, addMethod, removeMethod);
- fail("Should throw IntrospectionException.");
- } catch (IntrospectionException e) {
- }
-
- }
-
- /*
- * Class under test for void EventSetDescriptor(Class, String, Class,
- * String[], String, String, String)
- */
- public void testEventSetDescriptorClassStringClassStringArrayStringStringString()
- throws IntrospectionException {
- Class<MockSourceClass> sourceClass = MockSourceClass.class;
- String eventSetName = "MockPropertyChange";
- Class<?> listenerType = MockPropertyChangeListener.class;
- String[] listenerMethodNames = { "mockPropertyChange",
- "mockPropertyChange2", };
- String addMethod = "addMockPropertyChangeListener";
- String removeMethod = "removeMockPropertyChangeListener";
- String getMethod = "getMockPropertyChangeListener";
- EventSetDescriptor esd = new EventSetDescriptor(sourceClass,
- eventSetName, listenerType, listenerMethodNames, addMethod,
- removeMethod, getMethod);
-
- assertEquals(addMethod, esd.getAddListenerMethod().getName());
- assertEquals(removeMethod, esd.getRemoveListenerMethod().getName());
- assertNull(esd.getGetListenerMethod());
-
- assertEquals(2, esd.getListenerMethods().length);
- assertEquals(listenerMethodNames[0], esd.getListenerMethods()[0]
- .getName());
- assertEquals(listenerMethodNames[1], esd.getListenerMethods()[1]
- .getName());
- assertEquals(2, esd.getListenerMethodDescriptors().length);
- assertEquals(listenerMethodNames[0],
- esd.getListenerMethodDescriptors()[0].getMethod().getName());
- assertEquals(listenerMethodNames[1],
- esd.getListenerMethodDescriptors()[1].getMethod().getName());
-
- assertEquals(listenerType, esd.getListenerType());
- assertTrue(esd.isInDefaultEventSet());
- assertFalse(esd.isUnicast());
- // Regression for HARMONY-1237
- try {
- new EventSetDescriptor(Thread.class, "0xABCD", Thread.class,
- new String[] {}, "aaa", null, "bbb");
- fail("IntrospectionException expected");
- } catch (IntrospectionException e) {
- // expected
- }
- }
-
- /*
- * getListenerMethodName is null
- */
- public void testEventSetDescriptorClassStringClassStringArrayStringStringString_getListenerMethodNameNull()
- throws IntrospectionException {
- Class<MockSourceClass> sourceClass = MockSourceClass.class;
- String eventSetName = "MockPropertyChange";
- Class<?> listenerType = MockPropertyChangeListener.class;
- String[] listenerMethodNames = { "mockPropertyChange",
- "mockPropertyChange2", };
- String addMethod = "addMockPropertyChangeListener";
- String removeMethod = "removeMockPropertyChangeListener";
- String getMethod = null;
-
- EventSetDescriptor esd = new EventSetDescriptor(sourceClass,
- eventSetName, listenerType, listenerMethodNames, addMethod,
- removeMethod, getMethod);
- assertNull(esd.getGetListenerMethod());
-
- //Regression for Harmony-1504
- try {
- new EventSetDescriptor(sourceClass,
- eventSetName, listenerType, null, addMethod,
- removeMethod, getMethod);
- fail("NullPointerException expected");
- } catch (NullPointerException e) {
- //expected
- }
- }
-
- /*
- * getListenerMethodName is invalid (return void)
- */
- public void testEventSetDescriptorClassStringClassStringArrayStringStringString_getListenerMethodNameInvalid()
- throws IntrospectionException {
- Class<MockSourceClass> sourceClass = MockSourceClass.class;
- String eventSetName = "MockPropertyChange";
- Class<?> listenerType = MockPropertyChangeListener.class;
- String[] listenerMethodNames = { "mockPropertyChange",
- "mockPropertyChange2", };
- String addMethod = "addMockPropertyChangeListener";
- String removeMethod = "removeMockPropertyChangeListener";
- String getMethod = addMethod;
- EventSetDescriptor esd = new EventSetDescriptor(sourceClass,
- eventSetName, listenerType, listenerMethodNames, addMethod,
- removeMethod, getMethod);
- assertNull(esd.getGetListenerMethod());
- }
-
- /*
- * Class under test for void EventSetDescriptor(String, Class, Method[],
- * Method, Method)
- */
- public void testEventSetDescriptorStringClassMethodArrayMethodMethod()
- throws SecurityException, NoSuchMethodException,
- IntrospectionException {
- String eventSetName = "MockPropertyChange";
- Class<?> listenerType = MockPropertyChangeListener.class;
- Method[] listenerMethods = new Method[] {
- listenerType.getMethod("mockPropertyChange",
- new Class[] { MockPropertyChangeEvent.class }),
- listenerType.getMethod("mockPropertyChange2",
- new Class[] { MockPropertyChangeEvent.class }), };
- Class<MockSourceClass> sourceClass = MockSourceClass.class;
- Method addMethod = sourceClass.getMethod(
- "addMockPropertyChangeListener", new Class[] { listenerType });
- Method removeMethod = sourceClass.getMethod(
- "removeMockPropertyChangeListener",
- new Class[] { listenerType });
- EventSetDescriptor esd = new EventSetDescriptor(eventSetName,
- listenerType, listenerMethods, addMethod, removeMethod);
-
- assertEquals(addMethod, esd.getAddListenerMethod());
- assertEquals(removeMethod, esd.getRemoveListenerMethod());
- assertNull(esd.getGetListenerMethod());
-
- // RI reports true in the following assertion, so it returns exactly
- // the same array as it was specified in the EventSetDescriptor
- // constructor.
- assertEquals(listenerMethods, esd.getListenerMethods());
-
- assertEquals(2, esd.getListenerMethodDescriptors().length);
- assertEquals(listenerMethods[0], esd.getListenerMethodDescriptors()[0]
- .getMethod());
- assertEquals(listenerMethods[1], esd.getListenerMethodDescriptors()[1]
- .getMethod());
-
- assertEquals(listenerType, esd.getListenerType());
- assertTrue(esd.isInDefaultEventSet());
- assertFalse(esd.isUnicast());
- }
-
- /*
- * eventSetName=null
- */
- public void testEventSetDescriptorStringClassMethodArrayMethodMethod_EventNull()
- throws SecurityException, NoSuchMethodException,
- IntrospectionException {
- String eventSetName = null;
- Class<?> listenerType = MockPropertyChangeListener.class;
- Method[] listenerMethods = new Method[] {
- listenerType.getMethod("mockPropertyChange",
- new Class[] { MockPropertyChangeEvent.class }),
- listenerType.getMethod("mockPropertyChange2",
- new Class[] { MockPropertyChangeEvent.class }), };
- Class<MockSourceClass> sourceClass = MockSourceClass.class;
- Method addMethod = sourceClass.getMethod(
- "addMockPropertyChangeListener", new Class[] { listenerType });
- Method removeMethod = sourceClass.getMethod(
- "removeMockPropertyChangeListener",
- new Class[] { listenerType });
- EventSetDescriptor esd = new EventSetDescriptor(eventSetName,
- listenerType, listenerMethods, addMethod, removeMethod);
-
- assertEquals(addMethod, esd.getAddListenerMethod());
- assertEquals(removeMethod, esd.getRemoveListenerMethod());
- assertNull(esd.getGetListenerMethod());
-
- assertEquals(2, esd.getListenerMethodDescriptors().length);
- assertEquals(listenerMethods[0], esd.getListenerMethodDescriptors()[0]
- .getMethod());
- assertEquals(listenerMethods[1], esd.getListenerMethodDescriptors()[1]
- .getMethod());
-
- assertEquals(listenerType, esd.getListenerType());
- assertTrue(esd.isInDefaultEventSet());
- assertFalse(esd.isUnicast());
- }
-
- /*
- * eventSetName=""
- */
- public void testEventSetDescriptorStringClassMethodArrayMethodMethod_EventEmpty()
- throws SecurityException, NoSuchMethodException,
- IntrospectionException {
- String eventSetName = "";
- Class<?> listenerType = MockPropertyChangeListener.class;
- Method[] listenerMethods = new Method[] {
- listenerType.getMethod("mockPropertyChange",
- MockPropertyChangeEvent.class),
- listenerType.getMethod("mockPropertyChange2",
- MockPropertyChangeEvent.class) };
- Class<MockSourceClass> sourceClass = MockSourceClass.class;
- Method addMethod = sourceClass.getMethod(
- "addMockPropertyChangeListener", listenerType);
- Method removeMethod = sourceClass.getMethod(
- "removeMockPropertyChangeListener", listenerType);
- EventSetDescriptor esd = new EventSetDescriptor(eventSetName,
- listenerType, listenerMethods, addMethod, removeMethod);
-
- assertEquals(addMethod, esd.getAddListenerMethod());
- assertEquals(removeMethod, esd.getRemoveListenerMethod());
- assertNull(esd.getGetListenerMethod());
-
- //RI asserts to true here
- assertEquals(listenerMethods, esd.getListenerMethods());
-
- assertEquals(2, esd.getListenerMethodDescriptors().length);
- assertEquals(listenerMethods[0], esd.getListenerMethodDescriptors()[0]
- .getMethod());
- assertEquals(listenerMethods[1], esd.getListenerMethodDescriptors()[1]
- .getMethod());
-
- assertEquals(listenerType, esd.getListenerType());
- assertTrue(esd.isInDefaultEventSet());
- assertFalse(esd.isUnicast());
- }
-
- /*
- * listenerType=null
- */
- public void testEventSetDescriptorStringClassMethodArrayMethodMethod_ListenerTypeNull()
- throws SecurityException, NoSuchMethodException,
- IntrospectionException {
- String eventSetName = "MockPropertyChange";
- Class<?> listenerType = MockPropertyChangeListener.class;
- Method[] listenerMethods = new Method[] {
- listenerType.getMethod("mockPropertyChange",
- MockPropertyChangeEvent.class),
- listenerType.getMethod("mockPropertyChange2",
- MockPropertyChangeEvent.class) };
- Class<MockSourceClass> sourceClass = MockSourceClass.class;
- Method addMethod = sourceClass.getMethod(
- "addMockPropertyChangeListener", listenerType);
- Method removeMethod = sourceClass.getMethod(
- "removeMockPropertyChangeListener", listenerType);
- EventSetDescriptor esd = new EventSetDescriptor(eventSetName, null,
- listenerMethods, addMethod, removeMethod);
-
- assertEquals(addMethod, esd.getAddListenerMethod());
- assertEquals(removeMethod, esd.getRemoveListenerMethod());
- assertNull(esd.getGetListenerMethod());
- assertEquals(listenerMethods, esd.getListenerMethods());
-
- assertEquals(2, esd.getListenerMethodDescriptors().length);
- assertEquals(listenerMethods[0], esd.getListenerMethodDescriptors()[0]
- .getMethod());
- assertEquals(listenerMethods[1], esd.getListenerMethodDescriptors()[1]
- .getMethod());
-
- assertNull(esd.getListenerType());
- assertTrue(esd.isInDefaultEventSet());
- assertFalse(esd.isUnicast());
- }
-
- /*
- * listenerMethods=null
- */
- public void testEventSetDescriptorStringClassMethodArrayMethodMethod_listenerMethodsNull()
- throws IntrospectionException, NoSuchMethodException {
- String eventSetName = "MockPropertyChange";
- Class<?> listenerType = MockPropertyChangeListener.class;
- Class<MockSourceClass> sourceClass = MockSourceClass.class;
- Method addMethod = sourceClass.getMethod(
- "addMockPropertyChangeListener", listenerType);
- Method removeMethod = sourceClass.getMethod(
- "removeMockPropertyChangeListener", listenerType);
- EventSetDescriptor esd = new EventSetDescriptor(eventSetName,
- listenerType, (Method[]) null, addMethod, removeMethod);
-
- assertEquals(addMethod, esd.getAddListenerMethod());
- assertEquals(removeMethod, esd.getRemoveListenerMethod());
- assertNull(esd.getGetListenerMethod());
-
- assertNull(esd.getListenerMethods());
- assertNull(esd.getListenerMethodDescriptors());
-
- assertEquals(listenerType, esd.getListenerType());
- assertTrue(esd.isInDefaultEventSet());
- assertFalse(esd.isUnicast());
- }
-
- /*
- * listenerMethods is invalid
- */
- public void testEventSetDescriptorStringClassMethodArrayMethodMethod_listenerMethodsInvalid()
- throws SecurityException, NoSuchMethodException,
- IntrospectionException {
- String eventSetName = "MockPropertyChange";
- Class<?> listenerType = MockPropertyChangeListener.class;
- Method[] listenerMethods = new Method[] {
- listenerType.getMethod("mockPropertyChange",
- new Class[] { MockPropertyChangeEvent.class }),
- listenerType.getMethod("mockPropertyChange_Invalid",
- (Class[]) null), };
- Class<MockSourceClass> sourceClass = MockSourceClass.class;
- Method addMethod = sourceClass.getMethod(
- "addMockPropertyChangeListener", new Class[] { listenerType });
- Method removeMethod = sourceClass.getMethod(
- "removeMockPropertyChangeListener",
- new Class[] { listenerType });
- EventSetDescriptor esd = new EventSetDescriptor(eventSetName,
- listenerType, listenerMethods, addMethod, removeMethod);
- assertEquals(listenerMethods, esd.getListenerMethods());
- }
-
- /*
- * addListenerMethod = null
- */
- public void testEventSetDescriptorStringClassMethodArrayMethodMethod_addListenerMethodNull()
- throws IntrospectionException, NoSuchMethodException {
- String eventSetName = "MockPropertyChange";
- Class<?> listenerType = MockPropertyChangeListener.class;
- Method[] listenerMethods = new Method[] {
- listenerType.getMethod("mockPropertyChange",
- new Class[] { MockPropertyChangeEvent.class }),
- listenerType.getMethod("mockPropertyChange2",
- new Class[] { MockPropertyChangeEvent.class }), };
- Class<MockSourceClass> sourceClass = MockSourceClass.class;
- Method removeMethod = sourceClass.getMethod(
- "removeMockPropertyChangeListener",
- new Class[] { listenerType });
- EventSetDescriptor esd = new EventSetDescriptor(eventSetName,
- listenerType, listenerMethods, null, removeMethod);
-
- assertNull(esd.getAddListenerMethod());
- }
-
- /*
- * addListenerMethod is invalid
- */
- public void testEventSetDescriptorStringClassMethodArrayMethodMethod_addListenerMethodInvalid()
- throws IntrospectionException, NoSuchMethodException {
- String eventSetName = "MockPropertyChange";
- Class<?> listenerType = MockPropertyChangeListener.class;
- Method[] listenerMethods = new Method[] {
- listenerType.getMethod("mockPropertyChange",
- new Class[] { MockPropertyChangeEvent.class }),
- listenerType.getMethod("mockPropertyChange2",
- new Class[] { MockPropertyChangeEvent.class }), };
- Class<MockSourceClass> sourceClass = MockSourceClass.class;
- Method addMethod = sourceClass.getMethod(
- "addMockPropertyChangeListener_Invalid", (Class[]) null);
- Method removeMethod = sourceClass.getMethod(
- "removeMockPropertyChangeListener",
- new Class[] { listenerType });
- EventSetDescriptor esd = new EventSetDescriptor(eventSetName,
- listenerType, listenerMethods, addMethod, removeMethod);
- assertEquals(addMethod, esd.getAddListenerMethod());
- }
-
- /*
- * removeListenerMethod = null
- */
- public void testEventSetDescriptorStringClassMethodArrayMethodMethod_remveListenerMethodNull()
- throws IntrospectionException, NoSuchMethodException {
- String eventSetName = "MockPropertyChange";
- Class<?> listenerType = MockPropertyChangeListener.class;
- Method[] listenerMethods = new Method[] {
- listenerType.getMethod("mockPropertyChange",
- new Class[] { MockPropertyChangeEvent.class }),
- listenerType.getMethod("mockPropertyChange2",
- new Class[] { MockPropertyChangeEvent.class }), };
-
- EventSetDescriptor esd = new EventSetDescriptor(eventSetName,
- listenerType, listenerMethods, null, null);
- assertNull(esd.getRemoveListenerMethod());
- }
-
- /*
- * removeListenerMethod is invalid
- */
- public void testEventSetDescriptorStringClassMethodArrayMethodMethod_removeListenerMethodInvalid()
- throws IntrospectionException, NoSuchMethodException {
- String eventSetName = "MockPropertyChange";
- Class<?> listenerType = MockPropertyChangeListener.class;
- Method[] listenerMethods = new Method[] {
- listenerType.getMethod("mockPropertyChange",
- new Class[] { MockPropertyChangeEvent.class }),
- listenerType.getMethod("mockPropertyChange2",
- new Class[] { MockPropertyChangeEvent.class }), };
- Class<MockSourceClass> sourceClass = MockSourceClass.class;
- Method addMethod = sourceClass.getMethod(
- "addMockPropertyChangeListener", new Class[] { listenerType });
- Method removeMethod = sourceClass.getMethod(
- "addMockPropertyChangeListener_Invalid", (Class[]) null);
- EventSetDescriptor esd = new EventSetDescriptor(eventSetName,
- listenerType, listenerMethods, addMethod, removeMethod);
- assertEquals(removeMethod, esd.getRemoveListenerMethod());
- }
-
- /*
- * Class under test for void EventSetDescriptor(String, Class, Method[],
- * Method, Method, Method)
- */
- public void testEventSetDescriptorStringClassMethodArrayMethodMethodMethod()
- throws SecurityException, NoSuchMethodException,
- IntrospectionException {
- String eventSetName = "MockPropertyChange";
- Class<?> listenerType = MockPropertyChangeListener.class;
- Method[] listenerMethods = new Method[] {
- listenerType.getMethod("mockPropertyChange",
- new Class[] { MockPropertyChangeEvent.class }),
- listenerType.getMethod("mockPropertyChange2",
- new Class[] { MockPropertyChangeEvent.class }), };
- Class<MockSourceClass> sourceClass = MockSourceClass.class;
- Method addMethod = sourceClass.getMethod(
- "addMockPropertyChangeListener", new Class[] { listenerType });
- Method removeMethod = sourceClass.getMethod(
- "removeMockPropertyChangeListener",
- new Class[] { listenerType });
- Method getMethod = sourceClass.getMethod(
- "getMockPropertyChangeListener", new Class[] { listenerType });
-
- EventSetDescriptor esd = new EventSetDescriptor(eventSetName,
- listenerType, listenerMethods, addMethod, removeMethod,
- getMethod);
-
- assertEquals(getMethod, esd.getGetListenerMethod());
- }
-
- /*
- * getListenerMethod is null
- */
- public void testEventSetDescriptorStringClassMethodArrayMethodMethodMethod_getListenerMethodNull()
- throws IntrospectionException, NoSuchMethodException {
- String eventSetName = "MockPropertyChange";
- Class<?> listenerType = MockPropertyChangeListener.class;
- Method[] listenerMethods = new Method[] {
- listenerType.getMethod("mockPropertyChange",
- new Class[] { MockPropertyChangeEvent.class }),
- listenerType.getMethod("mockPropertyChange2",
- new Class[] { MockPropertyChangeEvent.class }), };
- Class<MockSourceClass> sourceClass = MockSourceClass.class;
- Method addMethod = sourceClass.getMethod(
- "addMockPropertyChangeListener", new Class[] { listenerType });
- Method removeMethod = sourceClass.getMethod(
- "removeMockPropertyChangeListener",
- new Class[] { listenerType });
-
- EventSetDescriptor esd = new EventSetDescriptor(eventSetName,
- listenerType, listenerMethods, addMethod, removeMethod, null);
- assertNull(esd.getGetListenerMethod());
- }
-
- /*
- * getListenerMethod is invalid
- */
- public void testEventSetDescriptorStringClassMethodArrayMethodMethodMethod_getListenerMethodInvalid()
- throws IntrospectionException, NoSuchMethodException {
- String eventSetName = "MockPropertyChange";
- Class<?> listenerType = MockPropertyChangeListener.class;
- Method[] listenerMethods = new Method[] {
- listenerType.getMethod("mockPropertyChange",
- new Class[] { MockPropertyChangeEvent.class }),
- listenerType.getMethod("mockPropertyChange2",
- new Class[] { MockPropertyChangeEvent.class }), };
- Class<MockSourceClass> sourceClass = MockSourceClass.class;
- Method addMethod = sourceClass.getMethod(
- "addMockPropertyChangeListener", new Class[] { listenerType });
- Method removeMethod = sourceClass.getMethod(
- "removeMockPropertyChangeListener",
- new Class[] { listenerType });
- Method getMethod = sourceClass.getMethod(
- "addMockPropertyChangeListener_Invalid", (Class[]) null);
-
- EventSetDescriptor esd = new EventSetDescriptor(eventSetName,
- listenerType, listenerMethods, addMethod, removeMethod,
- getMethod);
- assertEquals(getMethod, esd.getGetListenerMethod());
- }
-
- /*
- * Class under test for void EventSetDescriptor(String, Class,
- * MethodDescriptor[], Method, Method)
- */
- public void testEventSetDescriptorStringClassMethodDescriptorArrayMethodMethod()
- throws SecurityException, NoSuchMethodException,
- IntrospectionException {
- String eventSetName = "MockPropertyChange";
- Class<?> listenerType = MockPropertyChangeListener.class;
- Method[] listenerMethods = {
- listenerType.getMethod("mockPropertyChange",
- MockPropertyChangeEvent.class),
- listenerType.getMethod("mockPropertyChange2",
- MockPropertyChangeEvent.class)};
- MethodDescriptor[] listenerMethodDescriptors = {
- new MethodDescriptor(listenerMethods[0]),
- new MethodDescriptor(listenerMethods[1]), };
- Class<MockSourceClass> sourceClass = MockSourceClass.class;
- Method addMethod = sourceClass.getMethod(
- "addMockPropertyChangeListener", listenerType);
- Method removeMethod = sourceClass.getMethod(
- "removeMockPropertyChangeListener", listenerType);
-
- EventSetDescriptor esd = new EventSetDescriptor(eventSetName,
- listenerType, listenerMethodDescriptors, addMethod,
- removeMethod);
-
- assertEquals(addMethod, esd.getAddListenerMethod());
- assertEquals(removeMethod, esd.getRemoveListenerMethod());
- assertNull(esd.getGetListenerMethod());
- assertEquals(listenerMethods[0], esd.getListenerMethods()[0]);
- assertEquals(listenerMethods[1], esd.getListenerMethods()[1]);
-
- assertEquals(2, esd.getListenerMethodDescriptors().length);
- assertEquals(listenerMethods[0], esd.getListenerMethodDescriptors()[0]
- .getMethod());
- assertEquals(listenerMethods[1], esd.getListenerMethodDescriptors()[1]
- .getMethod());
-
- assertEquals(listenerType, esd.getListenerType());
- assertTrue(esd.isInDefaultEventSet());
- assertFalse(esd.isUnicast());
- }
-
- /*
- * listenerMethodDescriptors is null
- */
- public void testEventSetDescriptorStringClassMethodDescriptorArrayMethodMethod_ListenerMDNull()
- throws IntrospectionException, NoSuchMethodException {
- String eventSetName = "MockPropertyChange";
- Class<?> listenerType = MockPropertyChangeListener.class;
-
- Class<MockSourceClass> sourceClass = MockSourceClass.class;
- Method addMethod = sourceClass.getMethod(
- "addMockPropertyChangeListener", listenerType);
- Method removeMethod = sourceClass.getMethod(
- "removeMockPropertyChangeListener", listenerType);
-
- EventSetDescriptor esd = new EventSetDescriptor(eventSetName,
- listenerType, (MethodDescriptor[]) null, addMethod,
- removeMethod);
-
- assertNull(esd.getListenerMethodDescriptors());
- assertNull(esd.getListenerMethods());
- }
-
- /*
- * listenerMethodDescriptors is invalid
- */
- public void testEventSetDescriptorStringClassMethodDescriptorArrayMethodMethod_ListenerMDInvalid()
- throws SecurityException, NoSuchMethodException,
- IntrospectionException {
- String eventSetName = "MockPropertyChange";
- Class<?> listenerType = MockPropertyChangeListener.class;
- Method[] listenerMethods = {
- listenerType.getMethod("mockPropertyChange",
- MockPropertyChangeEvent.class),
- listenerType.getMethod("mockPropertyChange_Invalid") };
- MethodDescriptor[] listenerMethodDescriptors = {
- new MethodDescriptor(listenerMethods[0]),
- new MethodDescriptor(listenerMethods[1]) };
- Class<MockSourceClass> sourceClass = MockSourceClass.class;
- Method addMethod = sourceClass.getMethod(
- "addMockPropertyChangeListener", listenerType);
- Method removeMethod = sourceClass.getMethod(
- "removeMockPropertyChangeListener", listenerType);
-
- // RI doesn't check parameters of listener methods
- EventSetDescriptor esd = new EventSetDescriptor(eventSetName,
- listenerType, listenerMethodDescriptors, addMethod,
- removeMethod);
-
- assertEquals(0, esd.getListenerMethods()[1].getParameterTypes().length);
- assertEquals(listenerMethodDescriptors[1], esd
- .getListenerMethodDescriptors()[1]);
- }
-
- public void testSetInDefaultEventSet() throws SecurityException,
- NoSuchMethodException, IntrospectionException {
- String eventSetName = "MockPropertyChange";
- Class<?> listenerType = MockPropertyChangeListener.class;
- Method[] listenerMethods = {
- listenerType.getMethod("mockPropertyChange",
- MockPropertyChangeEvent.class),
- listenerType.getMethod("mockPropertyChange2",
- MockPropertyChangeEvent.class) };
- MethodDescriptor[] listenerMethodDescriptors = {
- new MethodDescriptor(listenerMethods[0]),
- new MethodDescriptor(listenerMethods[1]), };
- Class<MockSourceClass> sourceClass = MockSourceClass.class;
- Method addMethod = sourceClass.getMethod(
- "addMockPropertyChangeListener", listenerType);
- Method removeMethod = sourceClass.getMethod(
- "removeMockPropertyChangeListener", listenerType);
-
- EventSetDescriptor esd = new EventSetDescriptor(eventSetName,
- listenerType, listenerMethodDescriptors, addMethod,
- removeMethod);
- esd.setInDefaultEventSet(true);
- assertTrue(esd.isInDefaultEventSet());
- }
-
- public void testSetInDefaultEventSet_false() throws SecurityException,
- NoSuchMethodException, IntrospectionException {
- String eventSetName = "MockPropertyChange";
- Class<?> listenerType = MockPropertyChangeListener.class;
- Method[] listenerMethods = {
- listenerType.getMethod("mockPropertyChange",
- new Class[] { MockPropertyChangeEvent.class }),
- listenerType.getMethod("mockPropertyChange2",
- new Class[] { MockPropertyChangeEvent.class }), };
- MethodDescriptor[] listenerMethodDescriptors = {
- new MethodDescriptor(listenerMethods[0]),
- new MethodDescriptor(listenerMethods[1]), };
- Class<MockSourceClass> sourceClass = MockSourceClass.class;
- Method addMethod = sourceClass.getMethod(
- "addMockPropertyChangeListener", new Class[] { listenerType });
- Method removeMethod = sourceClass.getMethod(
- "removeMockPropertyChangeListener",
- new Class[] { listenerType });
-
- EventSetDescriptor esd = new EventSetDescriptor(eventSetName,
- listenerType, listenerMethodDescriptors, addMethod,
- removeMethod);
- assertTrue(esd.isInDefaultEventSet());
- esd.setInDefaultEventSet(false);
- assertFalse(esd.isInDefaultEventSet());
- }
-
- public void testSetUnicast() throws SecurityException,
- NoSuchMethodException, IntrospectionException {
- String eventSetName = "MockPropertyChange";
- Class<?> listenerType = MockPropertyChangeListener.class;
- Method[] listenerMethods = {
- listenerType.getMethod("mockPropertyChange",
- new Class[] { MockPropertyChangeEvent.class }),
- listenerType.getMethod("mockPropertyChange2",
- new Class[] { MockPropertyChangeEvent.class }), };
- MethodDescriptor[] listenerMethodDescriptors = {
- new MethodDescriptor(listenerMethods[0]),
- new MethodDescriptor(listenerMethods[1]), };
- Class<MockSourceClass> sourceClass = MockSourceClass.class;
- Method addMethod = sourceClass.getMethod(
- "addMockPropertyChangeListener", new Class[] { listenerType });
- Method removeMethod = sourceClass.getMethod(
- "removeMockPropertyChangeListener",
- new Class[] { listenerType });
-
- EventSetDescriptor esd = new EventSetDescriptor(eventSetName,
- listenerType, listenerMethodDescriptors, addMethod,
- removeMethod);
- assertFalse(esd.isUnicast());
- esd.setInDefaultEventSet(true);
- assertTrue(esd.isInDefaultEventSet());
- }
-
- public void testSetUnicast_false() throws SecurityException,
- NoSuchMethodException, IntrospectionException {
- String eventSetName = "MockPropertyChange";
- Class<?> listenerType = MockPropertyChangeListener.class;
- Method[] listenerMethods = {
- listenerType.getMethod("mockPropertyChange",
- MockPropertyChangeEvent.class),
- listenerType.getMethod("mockPropertyChange2",
- MockPropertyChangeEvent.class) };
- MethodDescriptor[] listenerMethodDescriptors = {
- new MethodDescriptor(listenerMethods[0]),
- new MethodDescriptor(listenerMethods[1]), };
- Class<MockSourceClass> sourceClass = MockSourceClass.class;
- Method addMethod = sourceClass.getMethod(
- "addMockPropertyChangeListener",listenerType);
- Method removeMethod = sourceClass.getMethod(
- "removeMockPropertyChangeListener", listenerType);
-
- EventSetDescriptor esd = new EventSetDescriptor(eventSetName,
- listenerType, listenerMethodDescriptors, addMethod,
- removeMethod);
- assertFalse(esd.isUnicast());
- esd.setInDefaultEventSet(false);
- assertFalse(esd.isInDefaultEventSet());
- }
-
- /**
- * The test checks the constructor
- */
- public void testEventSetDescriptorConstructor() throws Exception {
- new EventSetDescriptor(OtherBean.class, "sample",
- SampleListener.class, "fireSampleEvent");
- }
-
- public void test_EventSetDescriptor_Constructor() throws Exception {
- EventSetDescriptor eventSetDescriptor = new EventSetDescriptor(
- (String) null, (Class<?>) null, new MethodDescriptor[] { null,
- null }, (Method) null, (Method) null);
- assertNull(eventSetDescriptor.getName());
- assertNull(eventSetDescriptor.getListenerType());
- assertNull(eventSetDescriptor.getAddListenerMethod());
- assertNull(eventSetDescriptor.getRemoveListenerMethod());
-
- try {
- eventSetDescriptor.getListenerMethods();
- fail("should throw NullPointerException");
- } catch (NullPointerException e) {
- // Expected
- }
- }
-
- //Regression Test
- public void testConstructor_withLackRemoveActionBean() throws Exception {
- try {
- new EventSetDescriptor(LackRemoveActionBean.class, "action",
- ActionListener.class, "actionPerformed");
- fail("should throw IntrospectionException");
- } catch (IntrospectionException e) {
- // expected
- }
- }
-
- public void testConstructor_withAnotherListener() throws Exception {
- Method[] listenermethods = AnotherObjectListener.class
- .getDeclaredMethods();
-
- Method add = AnObject.class.getDeclaredMethod(
- "addEventSetDescriptorTest$AnObjectListener",
- AnObjectListener.class);
- Method remove = AnObject.class.getDeclaredMethod(
- "removeEventSetDescriptorTest$AnObjectListener",
- AnObjectListener.class);
-
- EventSetDescriptor esd = new EventSetDescriptor("something",
- AnObjectListener.class, listenermethods, add, remove);
- assertNotNull(esd);
- }
-
- protected String getUnQualifiedClassName(Class<?> classType) {
- String qName = classType.getName();
- return qName.substring(qName.lastIndexOf('.') + 1);
- }
-
- class MockSourceClass implements Serializable {
-
- /**
- * Comment for <code>serialVersionUID</code>
- */
- private static final long serialVersionUID = 1L;
-
- public void addMockPropertyChangeListener(
- MockPropertyChangeListener listener) {
- }
-
- public void addMockPropertyChangeListener_Invalid() {
- }
-
- public void removeMockPropertyChangeListener(
- MockPropertyChangeListener listener) {
- }
-
- public MockPropertyChangeListener[] getMockPropertyChangeListener(
- MockPropertyChangeListener listeners) {
- return null;
- }
-
- public void addMockPropertyChangeListener2(
- org.apache.harmony.beans.tests.support.mock.MockPropertyChangeListener2 listener) {
- }
-
- public void removeMockPropertyChangeListener2(
- org.apache.harmony.beans.tests.support.mock.MockPropertyChangeListener2 listener) {
- }
-
- public void addMockFakeListener(MockFakeListener listener) {
-
- }
-
- public void removeMockFakeListener(MockFakeListener listener) {
-
- }
- }
-
- public class LackRemoveActionBean {
- public void addActionListener(ActionListener al) {
- }
- // No removeActionListener() method
- }
-
- private interface AnObjectListener {
- public void aMethod( SomethingEvent s );
- }
-
- private static class AnObject {
- public void addEventSetDescriptorTest$AnObjectListener( AnObjectListener l ) {}
- public void removeEventSetDescriptorTest$AnObjectListener( AnObjectListener l ) {}
- }
-
- private static class SomethingEvent {
-
- }
-
- public static void main(String[] args) throws Exception {
-
- try {
- // No need to do anything clever, there's only one method and it's
- // the one we want.
- // Swap these two lines to make Harmony pass.
- //Method[] listenermethods = AnObjectListener.class.getDeclaredMethods();
- Method[] listenermethods = AnotherObjectListener.class.getDeclaredMethods();
-
- Method add = AnObject.class.getDeclaredMethod( "addEventSetDescriptorTest3$AnObjectListener",
- AnObjectListener.class );
- Method remove = AnObject.class.getDeclaredMethod( "removeEventSetDescriptorTest3$AnObjectListener",
- AnObjectListener.class );
-
- EventSetDescriptor esd = new EventSetDescriptor("something",
- AnObjectListener.class, listenermethods, add, remove);
- System.out.println("Test passed.");
- } catch (Exception e) {
- e.printStackTrace();
- System.out.println("Test failed.");
- }
- }
-
- private interface AnotherObjectListener {
- public void anotherMethod(SomethingEvent s);
- }
-
-}
diff --git a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/ExpressionTest.java b/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/ExpressionTest.java
deleted file mode 100644
index 3d9b5e8..0000000
--- a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/ExpressionTest.java
+++ /dev/null
@@ -1,1377 +0,0 @@
-/*
- * 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.java.beans;
-
-import java.beans.DefaultPersistenceDelegate;
-import java.beans.Expression;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Vector;
-
-import junit.framework.TestCase;
-
-import org.apache.harmony.beans.tests.support.SampleBean;
-
-/**
- * Test the class java.beans.Expression.
- */
-public class ExpressionTest extends TestCase {
-
- /**
- * The test checks the correct constructor is initialized
- */
- public void testConstructor() throws Exception {
- Expression expr = new Expression(SampleBean.class, "new",
- new Object[] { "hello" });
- Object result = expr.getValue();
- if (result != null && result instanceof SampleBean) {
- SampleBean bean = (SampleBean) result;
- assertEquals("hello", bean.getText());
- } else {
- fail("Cannot instantiate an instance of Bean class.");
- }
- }
-
- /**
- * The test checks the correct static method is initialized
- */
- public void testStatic() throws Exception {
- SampleBean theBean = new SampleBean();
- Expression expr = new Expression(SampleBean.class, "create",
- new Object[] { "hello", theBean });
-
- Object result = expr.getValue();
- if (result != null && result instanceof SampleBean) {
- SampleBean bean = (SampleBean) result;
- assertEquals("hello", bean.getText());
- assertEquals(theBean, bean.getObject());
- } else {
- fail("Cannot instantiate an instance of Bean class by "
- + "static method.");
- }
- }
-
- /**
- * The test checks the correct getter is initialized
- */
- public void testGetter() throws Exception {
- Expression expr = new Expression(new SampleBean("hello"), "getText",
- new Object[] {});
-
- Object result = expr.getValue();
- if (result != null && result instanceof String) {
- assertEquals("hello", result);
- } else {
- fail("Result of SampleBean.getText() call is not "
- + "of String type.");
- }
- }
-
- /**
- * The test checks the correct array getter is initialized
- */
- public void testArrayGetter() throws Exception {
- int[] a = { 1, 2, 3 };
- Expression expr = new Expression(a, "get",
- new Object[] { new Integer(1) });
-
- Object result = expr.getValue();
- if (result != null && result instanceof Integer) {
- assertEquals(new Integer(2), result);
- } else {
- fail("Result of array getter is not of Integer type.");
- }
- }
-
- /*
- * Test the constructor under normal conditions.
- */
- public void testConstructor_Normal() {
- Object target = new MockParent();
- Object arg1 = "string1";
- Object arg2 = new Object();
- Object arg3 = "string3";
- Object arg4 = new Integer(117);
- Object[] oa = new Object[] { arg1, arg2, arg3, arg4 };
- Expression t = new Expression(target, "method", oa);
-
- assertSame(target, t.getTarget());
- assertSame("method", t.getMethodName());
- assertSame(oa, t.getArguments());
- assertSame(arg1, t.getArguments()[0]);
- assertSame(arg2, t.getArguments()[1]);
- assertSame(arg3, t.getArguments()[2]);
- assertSame(arg4, t.getArguments()[3]);
-
- assertEquals("<unbound>=ExpressionTest$MockParent.method("
- + "\"string1\", Object, \"string3\", Integer);", t.toString());
- }
-
- /*
- * Test the constructor with null target.
- */
- public void testConstructor_NullTarget() {
- Object arg = new Object();
- Object[] oa = new Object[] { arg };
- Expression t = new Expression(null, "method", oa);
-
- assertSame(null, t.getTarget());
- assertSame("method", t.getMethodName());
- assertSame(oa, t.getArguments());
- assertSame(arg, t.getArguments()[0]);
- }
-
- /*
- * Test the constructor with an array target.
- */
- public void testConstructor_ArrayTarget() {
- Object target = new MockParent();
- Object arg = new Object();
- Object[] oa = new Object[] { arg };
- Expression t = new Expression(target, "method", oa);
-
- assertSame(target, t.getTarget());
- assertSame("method", t.getMethodName());
- assertSame(oa, t.getArguments());
- assertSame(arg, t.getArguments()[0]);
-
- assertEquals("<unbound>=ExpressionTest$MockParent.method(Object);", t
- .toString());
- }
-
- /*
- * Test the constructor with null method name.
- */
- public void testConstructor_NullMethodName() {
- Object target = new Object();
- Object[] oa = new Object[] { new Object() };
- Expression t = new Expression(target, null, oa);
-
- assertSame(target, t.getTarget());
- assertSame(null, t.getMethodName());
- assertSame(oa, t.getArguments());
- }
-
- /*
- * Test the constructor with the method name "new".
- */
- public void testConstructor_NewMethodName() {
- Object target = MockObject.class;
- Object[] oa = new Object[] { new Object() };
- Expression t = new Expression(target, "new", oa);
-
- assertSame(target, t.getTarget());
- assertSame("new", t.getMethodName());
- assertSame(oa, t.getArguments());
-
- assertEquals("<unbound>=Class.new(Object);", t.toString());
- }
-
- /*
- * Test the constructor with empty method name.
- */
- public void testConstructor_EmptyMethodName() {
- Object target = new Object();
- Object[] oa = new Object[] { new Object() };
- Expression t = new Expression(target, "", oa);
-
- assertSame(target, t.getTarget());
- assertSame("", t.getMethodName());
- assertSame(oa, t.getArguments());
- }
-
- /*
- * Test the constructor with null arguments.
- */
- public void testConstructor_NullArguments() {
- Object target = new MockParent();
- Expression t = new Expression(target, "method", null);
-
- assertSame(target, t.getTarget());
- assertSame("method", t.getMethodName());
- assertEquals(0, t.getArguments().length);
-
- assertEquals("<unbound>=ExpressionTest$MockParent.method();", t
- .toString());
- }
-
- /*
- * Test the constructor with a null argument.
- */
- public void testConstructor_NullArgument() {
- Object target = new MockParent();
- Object[] oa = new Object[] { null };
- Expression t = new Expression(target, "method", oa);
-
- assertSame(target, t.getTarget());
- assertSame("method", t.getMethodName());
- assertSame(oa, t.getArguments());
- assertNull(t.getArguments()[0]);
-
- assertEquals("<unbound>=ExpressionTest$MockParent.method(null);", t
- .toString());
- }
-
- /*
- * Test the constructor(value, ...) under normal conditions.
- */
- public void testConstructor_Value_Normal() throws Exception {
- Object val = new Object();
- Object target = new MockParent();
- Object arg1 = "mama";
- Object arg2 = new Object();
- Object arg3 = new Object();
- Object arg4 = new Long(7);
- Object[] oa = new Object[] { arg1, arg2, arg3, arg4 };
- Expression t = new Expression(val, target, "method", oa);
-
- assertSame(val, t.getValue());
- assertSame(target, t.getTarget());
- assertSame("method", t.getMethodName());
- assertSame(oa, t.getArguments());
- assertSame(arg1, t.getArguments()[0]);
- assertSame(arg2, t.getArguments()[1]);
- assertSame(arg3, t.getArguments()[2]);
- assertSame(arg4, t.getArguments()[3]);
-
- assertEquals("Object=ExpressionTest$MockParent.method("
- + "\"mama\", Object, Object, Long);", t.toString());
- }
-
- /*
- * Test the constructor(value, ...) with null target.
- */
- public void testConstructor_Value_NullTarget() throws Exception {
- Object val = new Object();
- Object arg = new Object();
- Object[] oa = new Object[] { arg };
- Expression t = new Expression(val, null, "method", oa);
-
- assertSame(val, t.getValue());
- assertSame(null, t.getTarget());
- assertSame("method", t.getMethodName());
- assertSame(oa, t.getArguments());
- assertSame(arg, t.getArguments()[0]);
-
- assertEquals("Object=null.method(Object);", t.toString());
- }
-
- /*
- * Test the constructor(value, ...) with an array target.
- */
- public void testConstructor_Value_ArrayTarget() throws Exception {
- Integer val = new Integer(69);
- Object target = new Integer[] { val };
- Object arg = new Integer(0);
- Object[] oa = new Object[] { arg };
- Expression t = new Expression(val, target, "get", oa);
-
- assertSame(val, t.getValue());
- assertSame(target, t.getTarget());
- assertSame("get", t.getMethodName());
- assertSame(oa, t.getArguments());
- assertSame(arg, t.getArguments()[0]);
-
- assertEquals("Integer=IntegerArray.get(Integer);", t.toString());
- }
-
- /*
- * Test the constructor(value, ...) with null method name.
- */
- public void testConstructor_Value_NullMethodName() throws Exception {
- Object val = new Object();
- Object target = new Object();
- Object[] oa = new Object[] { new Object() };
- Expression t = new Expression(val, target, null, oa);
-
- assertSame(val, t.getValue());
- assertSame(target, t.getTarget());
- assertSame(null, t.getMethodName());
- assertSame(oa, t.getArguments());
-
- assertEquals("Object=Object.null(Object);", t.toString());
- }
-
- /*
- * Test the constructor(value, ...) with the method name "new".
- */
- public void testConstructor_Value_NewMethodName() throws Exception {
- Object val = new Object();
- Object target = new Object();
- Object[] oa = new Object[] { new Object() };
- Expression t = new Expression(val, target, "new", oa);
-
- assertSame(val, t.getValue());
- assertSame(target, t.getTarget());
- assertSame("new", t.getMethodName());
- assertSame(oa, t.getArguments());
-
- assertEquals("Object=Object.new(Object);", t.toString());
- }
-
- /*
- * Test the constructor(value, ...) with empty method name.
- */
- public void testConstructor_Value_EmptyMethodName() throws Exception {
- Object val = new Object();
- Object target = new Object();
- Object[] oa = new Object[] { new Object() };
- Expression t = new Expression(val, target, "", oa);
-
- assertSame(val, t.getValue());
- assertSame(target, t.getTarget());
- assertSame("", t.getMethodName());
- assertSame(oa, t.getArguments());
-
- assertEquals("Object=Object.(Object);", t.toString());
- }
-
- /*
- * Test the constructor(value, ...) with null arguments.
- */
- public void testConstructor_Value_NullArguments() throws Exception {
- Object val = new Object();
- Object target = new Object();
- Expression t = new Expression(val, target, "method", null);
-
- assertSame(val, t.getValue());
- assertSame(target, t.getTarget());
- assertSame("method", t.getMethodName());
- assertEquals(0, t.getArguments().length);
-
- assertEquals("Object=Object.method();", t.toString());
- }
-
- /*
- * Test the constructor(value, ...) with a null argument.
- */
- public void testConstructor_Value_NullArgument() throws Exception {
- Object val = new Object();
- Object target = new Object();
- Object[] oa = new Object[] { null };
- Expression t = new Expression(val, target, "method", oa);
-
- assertSame(val, t.getValue());
- assertSame(target, t.getTarget());
- assertSame("method", t.getMethodName());
- assertSame(oa, t.getArguments());
- assertNull(t.getArguments()[0]);
-
- assertEquals("Object=Object.method(null);", t.toString());
- }
-
- /*
- * Test the constructor(value, ...) with a null value.
- */
- public void testConstructor_Value_NullValue() throws Exception {
- Object target = new Object();
- Object[] oa = new Object[] { null };
- Expression t = new Expression(null, target, "method", oa);
-
- assertSame(null, t.getValue());
- assertSame(target, t.getTarget());
- assertSame("method", t.getMethodName());
- assertSame(oa, t.getArguments());
- assertNull(t.getArguments()[0]);
-
- assertEquals("null=Object.method(null);", t.toString());
- }
-
- /*
- * Test the constructor(value, ...) with a expression value.
- */
- public void testConstructor_EmptyTarget_EmptyMethod_ExpressionArguments() {
- Object[] objectArray = new Object[] { new Expression((Object) null,
- (String) null, (Object[]) null) };
- Expression expression = new Expression(objectArray, new String(),
- new String(), objectArray);
- assertEquals("ObjectArray=\"\".(Expression);", expression.toString());
- }
-
- /*
- * Test the setValue() method with a non-null value when the value of the
- * expression is still unbounded.
- */
- public void testSetValue_UnboundNormal() throws Exception {
- MockObject mo = new MockObject(false);
- Expression t = new Expression(mo, "method", new Object[0]);
- t.setValue(mo);
- assertSame(mo, t.getValue());
- MockObject.assertNotCalled();
- }
-
- /*
- * Test the setValue() method with a null value when the value of the
- * expression is still unbounded.
- */
- public void testSetValue_UnboundNull() throws Exception {
- MockObject mo = new MockObject(false);
- Expression t = new Expression(mo, "method", new Object[0]);
- t.setValue(null);
- assertSame(null, t.getValue());
- MockObject.assertNotCalled();
- }
-
- /*
- * Test the setValue() method when the value of the expression is set by the
- * constructor.
- */
- public void testSetValue_Constructor() throws Exception {
- MockObject mo = new MockObject(false);
- Expression t = new Expression(mo, mo, "method", new Object[0]);
- assertSame(mo, t.getValue());
- MockObject.assertNotCalled();
- t.setValue(null);
- assertSame(null, t.getValue());
- MockObject.assertNotCalled();
- }
-
- /*
- * Test the setValue() method when the value of the expression is set by a
- * previous call to setValue().
- */
- public void testSetValue_Set() throws Exception {
- MockObject mo = new MockObject(false);
- Expression t = new Expression(mo, "method", new Object[0]);
- t.setValue(mo);
- assertSame(mo, t.getValue());
- MockObject.assertNotCalled();
- t.setValue(null);
- assertSame(null, t.getValue());
- MockObject.assertNotCalled();
- }
-
- /*
- * Test the setValue() method when the value of the expression is set by a
- * previous call to getValue().
- */
- public void testSetValue_Evaluated() throws Exception {
- MockObject mo = new MockObject(false);
- Expression t = new Expression(mo, "method", new Object[0]);
- assertEquals("method1", t.getValue());
- MockObject.assertCalled("method1", new Object[0]);
- t.setValue(mo);
- assertSame(mo, t.getValue());
- MockObject.assertNotCalled();
- }
-
- /*
- * Test the getValue() method when the value of the expression is evaluated
- * by a previous call to getValue().
- */
- public void testGetValue_Evaluated() throws Exception {
- MockObject mo = new MockObject(false);
- Expression t = new Expression(mo, "method", new Object[0]);
- assertEquals("method1", t.getValue());
- MockObject.assertCalled("method1", new Object[0]);
- assertEquals("method1", t.getValue());
- MockObject.assertNotCalled();
- }
-
- /*
- * Test the getValue() method when the value of expression is set by the
- * constructor.
- */
- public void testGetValue_Constructor() throws Exception {
- MockObject mo = new MockObject(false);
- Expression t = new Expression(mo, mo, "method", new Object[0]);
- assertSame(mo, t.getValue());
- MockObject.assertNotCalled();
- }
-
- /*
- * Test the getValue() method when the value of expression is set by a
- * previous call to setValue().
- */
- public void testGetValue_Set() throws Exception {
- MockObject mo = new MockObject(false);
- Expression t = new Expression(mo, "method", new Object[0]);
- t.setValue(mo);
- assertSame(mo, t.getValue());
- MockObject.assertNotCalled();
- }
-
- /*
- * Test the method getValue() with a normal object, a valid method name and
- * valid arguments.
- */
- public void testGetValue_UnboundedNormalInstanceMethod() throws Exception {
- MockObject mo = new MockObject(false);
- Expression t = new Expression(mo, "method", new Object[0]);
- assertEquals("method1", t.getValue());
- MockObject.assertCalled("method1", new Object[0]);
- t = new Expression(mo, "method", null);
- assertEquals("method1", t.getValue());
- MockObject.assertCalled("method1", new Object[0]);
- }
-
- /*
- * Test the method getValue() with a normal object, a valid method that
- * throws an exception and valid arguments.
- */
- public void testGetValue_UnboundedExceptionalMethod() throws Exception {
- MockObject mo = new MockObject(false);
- Expression t = new Expression(mo, "method", new Object[] { null, null });
- try {
- t.getValue();
- fail("Should throw NullPointerException!");
- } catch (NullPointerException ex) {
- // expected
- }
- MockObject.assertCalled("method4", new Object[] { null, null });
- }
-
- /*
- * Test the method getValue() with a normal object and a non-existing method
- * name.
- */
- public void testGetValue_UnboundedNonExistingMethod() throws Exception {
- MockObject mo = new MockObject(false);
- Expression t = new Expression(mo, "method_not_existing", new Object[] {
- null, null });
- try {
- t.getValue();
- fail("Should throw NoSuchMethodException!");
- } catch (NoSuchMethodException ex) {
- // expected
- }
- }
-
- /*
- * Test the method getValue() with a null object.
- */
- public void testGetValue_UnboundedNullTarget() throws Exception {
- Expression t = new Expression(null, "method_not_existing",
- new Object[] { null, null });
- try {
- t.getValue();
- fail("Should throw NullPointerException!");
- } catch (NullPointerException ex) {
- // expected
- }
- }
-
- /*
- * Test the method getValue() with a null method name.
- */
- public void testGetValue_UnboundedNullMethodName() throws Exception {
- MockObject mo = new MockObject(false);
- Expression t = new Expression(mo, null, new Object[] { null, null });
- try {
- t.getValue();
- fail("Should throw NullPointerException!");
- } catch (NullPointerException ex) {
- // expected
- }
- }
-
- /*
- * Test the method getValue() with a normal object, a valid method and
- * invalid arguments (in terms of type, numbers, etc.).
- */
- public void testGetValue_UnboundedInvalidArguments() throws Exception {
- MockObject mo = new MockObject(false);
- Expression t = new Expression(mo, "method", new Object[] {
- new Object(), new Object(), new Object() });
- try {
- t.getValue();
- fail("Should throw NoSuchMethodException!");
- } catch (NoSuchMethodException ex) {
- // expected
- }
- }
-
- /*
- * Test the method getValue() with a normal object, an overloaded method and
- * valid arguments.
- */
- public void testGetValue_UnboundedOverloadedMethods() throws Exception {
- MockObject mo = new MockObject(false);
- Object[] arguments = new Object[] { new Object() };
- Expression t = new Expression(mo, "method", arguments);
- assertEquals("method2", t.getValue());
- MockObject.assertCalled("method2", arguments);
-
- arguments = new Object[] { "test" };
- t = new Expression(mo, "method", arguments);
- assertEquals("method3", t.getValue());
- MockObject.assertCalled("method3", arguments);
- }
-
- /*
- * Test the method getValue() with a normal object, the method name "new"
- * and valid arguments.
- */
- public void testGetValue_UnboundedNormalConstructor() throws Exception {
- Expression t = new Expression(MockObject.class, "new", new Object[0]);
- t.getValue();
- MockObject.assertCalled("new0", new Object[0]);
- t = new Expression(MockObject.class, "new", null);
- assertTrue(t.getValue() instanceof MockObject);
- MockObject.assertCalled("new0", new Object[0]);
- }
-
- /*
- * Test the method getValue() with a normal object, the method name "new"
- * that throws an exception and valid arguments.
- */
- public void testGetValue_UnboundedExceptionalConstructor() throws Exception {
- Expression t = new Expression(MockObject.class, "new", new Object[] {
- null, null });
- try {
- t.getValue();
- fail("Should throw NullPointerException!");
- } catch (NullPointerException ex) {
- // expected
- }
- MockObject.assertCalled("new4", new Object[] { null, null });
- }
-
- /*
- * Test the method getValue() with a normal object, the method name "new"
- * and invalid arguments (in terms of type, numbers, etc.).
- */
- public void testGetValue_UnboundedNonExistingConstructor() throws Exception {
- Expression t = new Expression(MockObject.class, "new", new Object[] {
- null, null, null });
- try {
- t.getValue();
- fail("Should throw NoSuchMethodException!");
- } catch (NoSuchMethodException ex) {
- // expected
- }
- }
-
- /*
- * Test the method getValue() with a normal object with overloaded
- * constructors, the method name "new" and valid arguments. See Java
- * Language Specification (15.11) for reference.
- *
- * Note: decided by definition position.
- */
- public void testGetValue_UnboundedOverloadedConstructors() throws Exception {
- Object[] arguments = new Object[] { new Object() };
- Expression t = new Expression(MockObject.class, "new", arguments);
- t.getValue();
- MockObject.assertCalled("new2", arguments);
-
- //FIXME: the following 2 commented assert cannot pass neither in RI nor in Harmony (HARMONY-4392),
- // waiting for dev-list approval to fix Harmony implementation following spec
- arguments = new Object[] { "test" };
- t = new Expression(MockObject.class, "new", arguments);
- assertTrue(t.getValue() instanceof MockObject);
-// MockObject.assertCalled("new3", arguments);
-
- arguments = new Object[] { new Integer(1) };
- t = new Expression(MockObject.class, "new", arguments);
- assertTrue(t.getValue() instanceof MockObject);
-// MockObject.assertCalled("new1-2", arguments);
- }
-
- /*
- * Test the method getValue() with the Class object, a static method name
- * and valid arguments.
- */
- public void testGetValue_UnboundedNormalStaticMethodViaClass()
- throws Exception {
- Object[] arguments = new Object[] { new Object() };
- Expression t = new Expression(MockObject.class, "staticMethod",
- arguments);
- assertEquals("staticMethod", t.getValue());
- MockObject.assertCalled("staticMethod", arguments);
- }
-
- /*
- * Test the method getValue() with an object, a static method name and valid
- * arguments.
- */
- public void testGetValue_UnboundedNormalStaticMethodViaObject()
- throws Exception {
- MockObject mo = new MockObject(false);
- Object[] arguments = new Object[] { new Object() };
- Expression t = new Expression(mo, "staticMethod", arguments);
- assertEquals("staticMethod", t.getValue());
- MockObject.assertCalled("staticMethod", arguments);
- }
-
- /*
- * Test the method getValue() with a Class object of a normal class that has
- * a method of the same signature as Class.forName(String), a static method
- * name "forName" and valid argument "string".
- */
- public void testGetValue_UnboundedAmbitiousStaticMethod() throws Exception {
- Object[] arguments = new Object[] { "test" };
- Expression t = new Expression(MockObject.class, "forName", arguments);
- assertNull(t.getValue());
- MockObject.assertCalled("forName", arguments);
-
- t = new Expression(String.class, "forName",
- new Object[] { "java.lang.String" });
- assertSame(String.class, t.getValue());
- }
-
- /*
- * Test the method getValue() with the special method Class.forName().
- */
- public void testGetValue_UnboundedClassForName() throws Exception {
- Object[] arguments = new String[] { Expression.class.getName() };
- Expression t = new Expression(Class.class, "forName", arguments);
- assertSame(Expression.class, t.getValue());
-
- // t = new Expression(String.class, "forName", arguments);
- // assertSame(this.getClass(), t.getValue());
- }
-
- /*
- * Test the method getValue() with a normal array object, the method name
- * "get" and valid arguments.
- */
- public void testGetValue_UnboundedArrayGet() throws Exception {
- Object[] array = new Object[] { "test" };
- Expression t = new Expression(array, "get", new Object[] { new Integer(
- 0) });
- assertEquals("test", t.getValue());
- }
-
- /*
- * Test the method getValue() with a normal array object, the method name
- * "getInt" and invalid arguments.
- */
- public void testGetValue_UnboundedArrayInvalidSetInt() throws Exception {
- int[] array = new int[] { 1 };
- Expression t = new Expression(array, "getInt",
- new Object[] { new Integer(0) });
- try {
- t.getValue();
- fail("Should throw NoSuchMethodException!");
- } catch (NoSuchMethodException ex) {
- // expected
- }
- }
-
- /*
- * Test the method getValue() with a normal array object, the method name
- * "gets".
- */
- public void testGetValue_UnboundedArrayInvalidName() throws Exception {
- Object[] array = new Object[] { "test" };
- Expression t = new Expression(array, "gets", new Object[] {
- new Integer(0), new Object() });
- try {
- t.getValue();
- fail("Should throw NoSuchMethodException!");
- } catch (NoSuchMethodException ex) {
- // expected
- }
- }
-
- /*
- * Test the method getValue() with a normal object with overloaded methods
- * (primitive type VS wrapper class), a valid method name and valid
- * arguments.
- *
- * Note: decided by definition position!
- */
- public void testGetValue_UnboundedPrimitiveVSWrapper() throws Exception {
- MockObject mo = new MockObject(false);
- Object[] arguments = new Object[] { new Integer(1) };
- Expression t = new Expression(mo, "methodB", arguments);
- assertEquals("methodB2", t.getValue());
- MockObject.assertCalled("methodB2", arguments);
-
- arguments = new Object[] { Boolean.FALSE };
- t = new Expression(mo, "methodB", arguments);
- assertEquals("methodB3", t.getValue());
- MockObject.assertCalled("methodB3", arguments);
- }
-
- /*
- * Test the method getValue() with a normal object with void method name and
- * valid arguments.
- */
- public void testGetValue_UnboundedVoidMethod() throws Exception {
- MockObject mo = new MockObject(false);
- Object[] arguments = new Object[] { new Integer(1) };
- Expression t = new Expression(mo, "voidMethod", arguments);
- assertNull(t.getValue());
- MockObject.assertCalled("voidMethod2", arguments);
- }
-
- /*
- * Test the method getValue() with a protected method but within java.beans
- * package.
- */
- public void testGetValue_ProtectedMethodWithPackage() throws Exception {
- DefaultPersistenceDelegate dpd = new DefaultPersistenceDelegate();
- Object[] arguments = new Object[] { "test", "test" };
- Expression t = new Expression(dpd, "mutatesTo", arguments);
- try {
- t.getValue();
- fail("Should throw NoSuchMethodException!");
- } catch (NoSuchMethodException e) {
- // expected
- }
- }
-
- /*
- * Test the method getValue() with a method that is applicable via type
- * conversion.
- */
- public void testGetValue_ApplicableViaTypeConversion() throws Exception {
- MockObject mo = new MockObject(false);
- // mo.methodB('c');
- Object[] arguments = new Object[] { new Character((char) 1) };
- Expression t = new Expression(mo, "methodB", arguments);
- try {
- t.getValue();
- fail("Should throw NoSuchMethodException!");
- } catch (NoSuchMethodException e) {
- // expected
- }
- }
-
- public void testGetValue_returnNull() throws Exception {
- MockTarget target = new MockTarget();
- Expression e = new Expression(target, "aMethod", new Object[] {});
- Object got = e.getValue();
- assertTrue(MockTarget.isCalled());
- got = e.getValue();
- assertFalse(MockTarget.isCalled());
- }
-
- public void testGetValue_newInstanceNormalMethod() throws Exception {
- Expression expression = new Expression(new NormalTarget(),
- "newInstance", new Object[0]);
- assertEquals("Normal-Called", expression.getValue());
- }
-
- public void testGetValue_newInstanceStaticMethod() throws Exception {
- Expression expression = new Expression(new StaticTarget(),
- "newInstance", new Object[0]);
- assertEquals("Static-Called", expression.getValue());
- }
-
- public class NormalTarget {
-
- public String newInstance() {
- return "Normal-Called";
- }
- }
-
- public static class StaticTarget {
-
- public static String newInstance() {
- return "Static-Called";
- }
- }
-
- /*
- * Test the method getValue() with two equal specific methods.
- *
- * Note: decided by definition position! should be ambiguous.
- */
- // public void testGetValue_EqualSpecificMethods() throws Exception {
- // MockObject mo = new MockObject(false);
- // Object[] arguments = new Object[] { new MockObject(false),
- // new MockObject(false) };
- // Expression t = new Expression(mo, "equalSpecificMethod", arguments);
- // assertEquals("equalSpecificMethod1", t.getValue());
- // MockObject.assertCalled("equalSpecificMethod1", arguments);
- // }
- /*
- * Test the method getValue() with two equal specific methods but one
- * declaring thrown exception.
- *
- * Note: decided by definition position! should call the one with exception.
- */
- // public void testGetValue_EqualSpecificMethodsException() throws Exception
- // {
- // MockObject mo = new MockObject(false);
- // Object[] arguments = new Object[] { new MockObject(false),
- // new MockObject(false), new Object() };
- // Expression t = new Expression(mo, "equalSpecificMethod", arguments);
- // assertEquals("equalSpecificMethod3", t.getValue());
- // MockObject.assertCalled("equalSpecificMethod3", arguments);
- // }
- /*
- * Super class of MockObject.
- */
- public static class MockParent {
-
- protected static String calledMethod = null;
-
- protected static Vector<Object> receivedArguments = new Vector<Object>();
-
- public Object method() {
- reset();
- calledMethod = "method1";
- return calledMethod;
- }
-
- protected Object method(Boolean o) {
- reset();
- calledMethod = "method1-1";
- receivedArguments.add(o);
- return calledMethod;
- }
-
- public Object method(Integer o) {
- reset();
- calledMethod = "method1-2";
- receivedArguments.add(o);
- return calledMethod;
- }
-
- public Object method(Object o) {
- reset();
- calledMethod = "method2";
- receivedArguments.add(o);
- return calledMethod;
- }
-
- public Object method(String o) {
- reset();
- calledMethod = "method3";
- receivedArguments.add(o);
- return calledMethod;
- }
-
- public Object method(Object o, Object o2) {
- reset();
- calledMethod = "method4";
- receivedArguments.add(o);
- receivedArguments.add(o2);
- throw new NullPointerException();
- }
-
- public Object method(Object o, Object o2, Object o3, Object o4) {
- reset();
- calledMethod = "method5";
- receivedArguments.add(o);
- receivedArguments.add(o2);
- receivedArguments.add(o3);
- receivedArguments.add(o4);
- return calledMethod;
- }
-
- public static void reset() {
- receivedArguments.clear();
- calledMethod = null;
- }
- }
-
- public static class MockTarget {
- static int called = 0;
-
- static int base = 0;
-
- public Object aMethod() { // should return null on first call
- called++;
- return null;
- }
-
- public static boolean isCalled() {
- boolean result = !(base == called);
- base = called;
- return result;
- }
-
- }
-
- /*
- * Mock object.
- */
- public static class MockObject extends MockParent {
-
- public MockObject() {
- reset();
- calledMethod = "new0";
- }
-
- public MockObject(boolean testingConstructor) {
- reset();
- if (testingConstructor) {
- calledMethod = "new1";
- }
- }
-
- public MockObject(String o) {
- reset();
- calledMethod = "new3";
- receivedArguments.add(o);
- }
-
- public MockObject(Object o) {
- reset();
- calledMethod = "new2";
- receivedArguments.add(o);
- }
-
- public MockObject(Integer o) {
- reset();
- calledMethod = "new1-2";
- receivedArguments.add(o);
- }
-
-
- public MockObject(Object o, Object o2) {
- reset();
- calledMethod = "new4";
- receivedArguments.add(o);
- receivedArguments.add(o2);
- throw new NullPointerException();
- }
-
- // public Object methodB(Integer i) {
- // reset();
- // calledMethod = "methodB1";
- // receivedArguments.add(i);
- // return calledMethod;
- // }
-
- public Object methodB(int i) {
- reset();
- calledMethod = "methodB2";
- receivedArguments.add(new Integer(i));
- return calledMethod;
- }
-
- public Object methodB(boolean b) {
- reset();
- calledMethod = "methodB3";
- receivedArguments.add(new Boolean(b));
- return calledMethod;
- }
-
- // public Object methodB(Boolean b) {
- // reset();
- // calledMethod = "methodB4";
- // receivedArguments.add(b);
- // return calledMethod;
- // }
-
- public Object voidMethod(Object o) {
- reset();
- calledMethod = "voidMethod";
- receivedArguments.add(o);
- return "voidMethod";
- }
-
- public void voidMethod(Integer o) {
- reset();
- calledMethod = "voidMethod2";
- receivedArguments.add(o);
- }
-
- public static Object staticMethod(Object o) {
- reset();
- calledMethod = "staticMethod";
- receivedArguments.add(o);
- return calledMethod;
- }
-
- // public Object equalSpecificMethod(MockObject o, MockParent p) {
- // reset();
- // calledMethod = "equalSpecificMethod1";
- // receivedArguments.add(o);
- // receivedArguments.add(p);
- // return calledMethod;
- // }
-
- // public Object equalSpecificMethod(MockParent p, MockObject o) {
- // reset();
- // calledMethod = "equalSpecificMethod2";
- // receivedArguments.add(p);
- // receivedArguments.add(o);
- // return calledMethod;
- // }
-
- // public Object equalSpecificMethod(MockObject o, MockParent p, Object
- // o2) {
- // reset();
- // calledMethod = "equalSpecificMethod3";
- // receivedArguments.add(o);
- // receivedArguments.add(p);
- // receivedArguments.add(o2);
- // return calledMethod;
- // }
-
- // public Object equalSpecificMethod(MockParent p, MockObject o, Object
- // o2)
- // throws Exception {
- // reset();
- // calledMethod = "equalSpecificMethod4";
- // receivedArguments.add(p);
- // receivedArguments.add(o);
- // receivedArguments.add(o2);
- // return calledMethod;
- // }
-
- public static Class<?> forName(String o) {
- reset();
- calledMethod = "forName";
- receivedArguments.add(o);
- return null;
- }
-
- public static void assertCalled(String methodName, Object[] arguments) {
- assertEquals(methodName, calledMethod);
- assertTrue(Arrays.equals(arguments, receivedArguments.toArray()));
- reset();
- }
-
- public static void assertNotCalled() {
- assertNull(calledMethod);
- assertTrue(receivedArguments.isEmpty());
- }
- }
-
- public void testSubExpression() throws Exception {
- MyExpression my_e = new MyExpression();
- my_e.setTarget(new Target());
- my_e.setArguments(new Object[] {});
- my_e.setMethodName("aMethod");
- my_e.execute();
- assertEquals("haha", my_e.getValue());
- }
-
- private static class MyExpression extends java.beans.Expression {
-
- private Object target = null;
-
- private Object args[] = new Object[] { new Object() };
-
- private String name = "";
-
- public MyExpression() {
- super(null, null, null);
- }
-
- public void setTarget(Object t) {
- target = t;
- }
-
- public Object getTarget() {
- return target;
- }
-
- public void setArguments(Object[] a) {
- args = a;
- }
-
- public Object[] getArguments() {
- return args;
- }
-
- public void setMethodName(String n) {
- name = n;
- }
-
- public String getMethodName() {
- return name;
- }
-
- public void setValue(Object value) {
- super.setValue(value);
- }
-
- public Object getValue() {
- return "haha";
- }
-
- }
-
- public static class Target {
-
- public Object aMethod() {
- return "haha";
- }
- }
-
- public void test_Expression_Constructor_OneArgument_senario1()
- throws Exception {
- Object[] arguments = new Object[] { "test" };
- Expression expression = new Expression(SampleObject.class, "new",
- arguments);
- assertTrue(expression.getValue() instanceof SampleObject);
- SampleObject.assertCalled("string", arguments);
- }
-
- public void test_Expression_Constructor_OneArgument_senario2()
- throws Exception {
- Object[] arguments = new Object[] { new Integer(1) };
- Expression expression = new Expression(SampleObject.class, "new",
- arguments);
- assertTrue(expression.getValue() instanceof SampleObject);
- SampleObject.assertCalled("integer", arguments);
- }
-
- public void test_Expression_Constructor_OneArgument_senario3()
- throws Exception {
- Object[] arguments = new Object[] { new Object() };
- Expression expression = new Expression(SampleObject.class, "new",
- arguments);
- assertTrue(expression.getValue() instanceof SampleObject);
- SampleObject.assertCalled("object", arguments);
- }
-
- public void test_Expression_Constructor_OneArgument_senario4()
- throws Exception {
- Object[] arguments = new Object[] { null };
- Expression expression = new Expression(SampleObject.class, "new",
- arguments);
- assertTrue(expression.getValue() instanceof SampleObject);
- SampleObject.assertCalled("object", arguments);
- }
-
- public void test_Expression_Constructor_twoArguments_senario1()
- throws Exception {
- Object[] arguments = new Object[] { null, null };
- Expression expression = new Expression(SampleObject.class, "new",
- arguments);
- assertTrue(expression.getValue() instanceof SampleObject);
- SampleObject.assertCalled("object_object", arguments);
- }
-
- public void test_Expression_Constructor_twoArguments_senario2()
- throws Exception {
- Object[] arguments = new Object[] { null, "test" };
- Expression expression = new Expression(SampleObject.class, "new",
- arguments);
- assertTrue(expression.getValue() instanceof SampleObject);
- SampleObject.assertCalled("object_string", arguments);
- }
-
- public void test_Expression_Constructor_twoArguments_senario3()
- throws Exception {
- Object[] arguments = new Object[] { new Object(), "test" };
- Expression expression = new Expression(SampleObject.class, "new",
- arguments);
- assertTrue(expression.getValue() instanceof SampleObject);
- SampleObject.assertCalled("object_string", arguments);
- }
-
- public void test_Expression_Constructor_twoArguments_senario4()
- throws Exception {
- Object[] arguments = new Object[] { "test1", "test2" };
- Expression expression = new Expression(SampleObject.class, "new",
- arguments);
- assertTrue(expression.getValue() instanceof SampleObject);
- SampleObject.assertCalled("string_string", arguments);
- }
-
- public void test_Expression_Constructor_twoArguments_senario5()
- throws Exception {
- Object[] arguments = new Object[] { "test", new Integer(1) };
- Expression expression = new Expression(SampleObject.class, "new",
- arguments);
- assertTrue(expression.getValue() instanceof SampleObject);
- SampleObject.assertCalled("string_integer", arguments);
- }
-
- public void test_Expression_Constructor_twoArguments_senario6()
- throws Exception {
- Object[] arguments = new Object[] { "test", (String) null };
- Expression expression = new Expression(SampleObject.class, "new",
- arguments);
- assertTrue(expression.getValue() instanceof SampleObject);
- SampleObject.assertCalled("object_object", arguments);
- }
-
- public void test_Expression_Constructor_twoArguments_senario7()
- throws Exception {
- Object[] arguments = new Object[] { new Integer(1), "test" };
- Expression expression = new Expression(SampleObject.class, "new",
- arguments);
- assertTrue(expression.getValue() instanceof SampleObject);
- SampleObject.assertCalled("object_string", arguments);
- }
-
- public void test_Expression_Constructor_twoArguments_senario8()
- throws Exception {
- Object[] arguments = new Object[] { new Integer(1), new Integer(2) };
- Expression expression = new Expression(SampleObject.class, "new",
- arguments);
- assertTrue(expression.getValue() instanceof SampleObject);
- SampleObject.assertCalled("object_object", arguments);
- }
-
- public static class SampleObject {
-
- public static String calledMethod = null;
-
- public static ArrayList<Object> receivedArguments = new ArrayList<Object>();
-
- public SampleObject(String o) {
- reset();
- calledMethod = "string";
- receivedArguments.add(o);
- }
-
- public SampleObject(Object o) {
- reset();
- calledMethod = "object";
- receivedArguments.add(o);
- }
-
- public SampleObject(Integer o) {
- reset();
- calledMethod = "integer";
- receivedArguments.add(o);
- }
-
- public SampleObject(Object arg1, Object arg2) {
- reset();
- calledMethod = "object_object";
- receivedArguments.add(arg1);
- receivedArguments.add(arg2);
- }
-
- public SampleObject(Object arg1, String arg2) {
- reset();
- calledMethod = "object_string";
- receivedArguments.add(arg1);
- receivedArguments.add(arg2);
- }
-
- public SampleObject(String arg1, String arg2) {
- reset();
- calledMethod = "string_string";
- receivedArguments.add(arg1);
- receivedArguments.add(arg2);
- }
-
- public SampleObject(String arg1, Integer arg2) {
- reset();
- calledMethod = "string_integer";
- receivedArguments.add(arg1);
- receivedArguments.add(arg2);
- }
-
- public static void assertCalled(String methodName, Object[] arguments) {
- assertEquals(methodName, calledMethod);
- assertTrue(Arrays.equals(arguments, receivedArguments.toArray()));
- reset();
- }
-
- public static void reset() {
- receivedArguments.clear();
- calledMethod = null;
- }
- }
-}
diff --git a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/FeatureDescriptorTest.java b/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/FeatureDescriptorTest.java
deleted file mode 100644
index 4a8e34c..0000000
--- a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/FeatureDescriptorTest.java
+++ /dev/null
@@ -1,296 +0,0 @@
-/*
- * 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.java.beans;
-
-import java.beans.FeatureDescriptor;
-import java.util.Enumeration;
-import java.util.Hashtable;
-
-import junit.framework.TestCase;
-
-/**
- * Unit test for FeatureDescriptor.
- */
-public class FeatureDescriptorTest extends TestCase {
-
- private FeatureDescriptor fd;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- fd = new FeatureDescriptor();
- }
-
- public void testFeatureDescriptor() {
- assertNull(fd.getDisplayName());
- assertNull(fd.getName());
- assertNull(fd.getShortDescription());
-
- assertNotNull(fd.attributeNames());
-
- assertFalse(fd.isExpert());
- assertFalse(fd.isHidden());
- assertFalse(fd.isPreferred());
- }
-
- public void testSetDisplayName() {
- String displayName = "FeatureDescriptor.displayName";
- fd.setDisplayName(displayName);
- assertSame(displayName, fd.getDisplayName());
- assertNull(fd.getName());
- assertSame(displayName, fd.getShortDescription());
-
- assertNotNull(fd.attributeNames());
-
- assertFalse(fd.isExpert());
- assertFalse(fd.isHidden());
- assertFalse(fd.isPreferred());
- }
-
- public void testSetDisplayName_DisplayNameNull() {
- String displayName = null;
- fd.setDisplayName(displayName);
- assertNull(fd.getDisplayName());
- assertNull(fd.getName());
- assertNull(fd.getShortDescription());
-
- assertNotNull(fd.attributeNames());
-
- assertFalse(fd.isExpert());
- assertFalse(fd.isHidden());
- assertFalse(fd.isPreferred());
- }
-
- public void testSetExpert_False() {
- fd.setExpert(false);
- assertFalse(fd.isExpert());
-
- assertNull(fd.getDisplayName());
- assertNull(fd.getName());
- assertNull(fd.getShortDescription());
-
- assertNotNull(fd.attributeNames());
-
- assertFalse(fd.isHidden());
- assertFalse(fd.isPreferred());
- }
-
- public void testSetExpert_True() {
- fd.setExpert(true);
- assertTrue(fd.isExpert());
-
- assertNull(fd.getDisplayName());
- assertNull(fd.getName());
- assertNull(fd.getShortDescription());
-
- assertNotNull(fd.attributeNames());
-
- assertFalse(fd.isHidden());
- assertFalse(fd.isPreferred());
- }
-
- public void testSetHidden_False() {
- fd.setHidden(false);
- assertFalse(fd.isHidden());
-
- assertNull(fd.getDisplayName());
- assertNull(fd.getName());
- assertNull(fd.getShortDescription());
-
- assertNotNull(fd.attributeNames());
-
- assertFalse(fd.isExpert());
- assertFalse(fd.isPreferred());
- }
-
- public void testSetHidden_True() {
- fd.setHidden(true);
- assertTrue(fd.isHidden());
-
- assertNull(fd.getDisplayName());
- assertNull(fd.getName());
- assertNull(fd.getShortDescription());
-
- assertNotNull(fd.attributeNames());
-
- assertFalse(fd.isExpert());
- assertFalse(fd.isPreferred());
- }
-
- public void testSetName() {
- String name = "FeatureDescriptor.name";
- fd.setName(name);
- assertSame(name, fd.getName());
-
- assertSame(name, fd.getDisplayName());
- assertSame(name, fd.getShortDescription());
-
- assertNotNull(fd.attributeNames());
-
- assertFalse(fd.isExpert());
- assertFalse(fd.isHidden());
- assertFalse(fd.isPreferred());
- }
-
- public void testSetName_null() {
- fd.setName("FeatureDescriptor.name");
- fd.setName(null);
- assertNull(fd.getName());
-
- assertNull(fd.getDisplayName());
- assertNull(fd.getShortDescription());
-
- assertNotNull(fd.attributeNames());
-
- assertFalse(fd.isExpert());
- assertFalse(fd.isHidden());
- assertFalse(fd.isPreferred());
- }
-
- public void testSetPreferred_False() {
- fd.setPreferred(false);
- assertFalse(fd.isPreferred());
-
- assertNull(fd.getDisplayName());
- assertNull(fd.getName());
- assertNull(fd.getShortDescription());
-
- assertNotNull(fd.attributeNames());
-
- assertFalse(fd.isExpert());
- assertFalse(fd.isHidden());
- }
-
- public void testSetPreferred_True() {
- fd.setPreferred(true);
- assertTrue(fd.isPreferred());
-
- assertNull(fd.getDisplayName());
- assertNull(fd.getName());
- assertNull(fd.getShortDescription());
-
- assertNotNull(fd.attributeNames());
-
- assertFalse(fd.isExpert());
- assertFalse(fd.isHidden());
- }
-
- public void testSetShortDescription() {
- String shortDesc = "FeatureDescriptor.ShortDescription";
- fd.setShortDescription(shortDesc);
- assertSame(shortDesc, fd.getShortDescription());
-
- assertNull(fd.getDisplayName());
- assertNull(fd.getName());
-
- assertNotNull(fd.attributeNames());
-
- assertFalse(fd.isExpert());
- assertFalse(fd.isHidden());
- assertFalse(fd.isPreferred());
- }
-
- public void testSetShortDescription_ShortDescNull() {
- String shortDesc = "FeatureDescriptor.ShortDescription";
- fd.setShortDescription(shortDesc);
- assertSame(shortDesc, fd.getShortDescription());
- fd.setShortDescription(null);
- assertNull(fd.getShortDescription());
-
- assertNull(fd.getDisplayName());
- assertNull(fd.getName());
-
- assertNotNull(fd.attributeNames());
-
- assertFalse(fd.isExpert());
- assertFalse(fd.isHidden());
- assertFalse(fd.isPreferred());
- }
-
- public void testSetValue() {
- String[] attributeNames = { "Blue", "Yellow", "Red", };
- Object[] values = { "Blue.value", "Yellow.value", "Red.value", };
- for (int i = 0; i < attributeNames.length; i++) {
- fd.setValue(attributeNames[i], values[i]);
- }
-
- for (int i = 0; i < attributeNames.length; i++) {
- assertSame(values[i], fd.getValue(attributeNames[i]));
- }
- }
-
- public void testSetValue_ExistAttribute() {
- String attributeName = "blue";
- Object value = "Anyone";
- fd.setValue(attributeName, value);
- assertSame(value, fd.getValue(attributeName));
-
- Object newValue = "Another";
- fd.setValue(attributeName, newValue);
- assertSame(newValue, fd.getValue(attributeName));
- }
-
- public void testSetValue_ValueNull() {
- String attributeName = "blue";
- Object value = "Anyone";
- fd.setValue(attributeName, value);
- assertSame(value, fd.getValue(attributeName));
-
- try {
- fd.setValue(null, value);
- fail("Should throw NullPointerException");
- } catch (NullPointerException e) {
- // Expected
- }
-
- try {
- fd.setValue(attributeName, null);
- fail("Should throw NullPointerException");
- } catch (NullPointerException e) {
- // Expected
- }
-
- try {
- fd.setValue(null, null);
- fail("Should throw NullPointerException");
- } catch (NullPointerException e) {
- // Expected
- }
- }
-
- public void testattributeNames() {
- assertFalse(fd.attributeNames().hasMoreElements());
-
- String[] attributeNames = { "Blue", "Yellow", "Red", };
- Object[] values = { "Blue.value", "Yellow.value", "Red.value", };
- for (int i = 0; i < attributeNames.length; i++) {
- fd.setValue(attributeNames[i], values[i]);
- }
- Enumeration<String> names = fd.attributeNames();
- Hashtable<String, Object> table = new Hashtable<String, Object>();
- while (names.hasMoreElements()) {
- String name = names.nextElement();
- table.put(name, fd.getValue(name));
- }
-
- assertEquals(attributeNames.length, table.size());
- for (String element : attributeNames) {
- assertTrue(table.containsKey(element));
- }
- }
-}
diff --git a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/FozzzEditor.java b/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/FozzzEditor.java
deleted file mode 100644
index d859145..0000000
--- a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/FozzzEditor.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * 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.java.beans;
-
-import java.awt.Component;
-import java.awt.Graphics;
-import java.awt.Rectangle;
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyEditor;
-
-/**
- * Test PropertyEditorManager
- */
-public class FozzzEditor implements PropertyEditor {
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.PropertyEditor#addPropertyChangeListener(java.beans.PropertyChangeListener)
- */
- public void addPropertyChangeListener(PropertyChangeListener listener) {
- // TO DO Auto-generated method stub
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.PropertyEditor#getAsText()
- */
- public String getAsText() {
- // TO DO Auto-generated method stub
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.PropertyEditor#getCustomEditor()
- */
- public Component getCustomEditor() {
- // TO DO Auto-generated method stub
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.PropertyEditor#getJavaInitializationString()
- */
- public String getJavaInitializationString() {
- // TO DO Auto-generated method stub
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.PropertyEditor#getTags()
- */
- public String[] getTags() {
- // TO DO Auto-generated method stub
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.PropertyEditor#getValue()
- */
- public Object getValue() {
- // TO DO Auto-generated method stub
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.PropertyEditor#isPaintable()
- */
- public boolean isPaintable() {
- // TO DO Auto-generated method stub
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.PropertyEditor#paintValue(java.awt.Graphics,
- * java.awt.Rectangle)
- */
- public void paintValue(Graphics graphics, Rectangle box) {
- // TO DO Auto-generated method stub
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.PropertyEditor#removePropertyChangeListener(java.beans.PropertyChangeListener)
- */
- public void removePropertyChangeListener(PropertyChangeListener listener) {
- // TO DO Auto-generated method stub
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.PropertyEditor#setAsText(java.lang.String)
- */
- public void setAsText(String text) throws IllegalArgumentException {
- // TO DO Auto-generated method stub
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.PropertyEditor#setValue(java.lang.Object)
- */
- public void setValue(Object value) {
- // TO DO Auto-generated method stub
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.PropertyEditor#supportsCustomEditor()
- */
- public boolean supportsCustomEditor() {
- // TO DO Auto-generated method stub
- return false;
- }
-
-}
diff --git a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/IndexedPropertyDescriptorTest.java b/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/IndexedPropertyDescriptorTest.java
deleted file mode 100644
index 289627e..0000000
--- a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/IndexedPropertyDescriptorTest.java
+++ /dev/null
@@ -1,1611 +0,0 @@
-/*
- * 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.java.beans;
-
-import java.beans.IndexedPropertyDescriptor;
-import java.beans.IntrospectionException;
-import java.beans.PropertyDescriptor;
-import java.lang.reflect.Method;
-
-import junit.framework.TestCase;
-
-import org.apache.harmony.beans.tests.support.mock.MockJavaBean;
-
-/**
- * Unit test for IndexedPropertyDescriptor.
- */
-public class IndexedPropertyDescriptorTest extends TestCase {
-
- public void testEquals() throws SecurityException, NoSuchMethodException,
- IntrospectionException {
- String propertyName = "PropertyFour";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
-
- Method readMethod = beanClass.getMethod("get" + propertyName,
- (Class[]) null);
- Method writeMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { String[].class });
- Method indexedReadMethod = beanClass.getMethod("get" + propertyName,
- new Class[] { Integer.TYPE });
- Method indexedWriteMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { Integer.TYPE, String.class });
-
- IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor(
- propertyName, readMethod, writeMethod, indexedReadMethod,
- indexedWriteMethod);
-
- IndexedPropertyDescriptor ipd2 = new IndexedPropertyDescriptor(
- propertyName, beanClass);
-
- assertTrue(ipd.equals(ipd2));
- assertTrue(ipd.equals(ipd));
- assertTrue(ipd2.equals(ipd));
- assertFalse(ipd.equals(null));
- }
-
- /*
- * Read method
- */
- public void testEquals_ReadMethod() throws SecurityException,
- NoSuchMethodException, IntrospectionException {
- String propertyName = "PropertyFour";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
-
- Method readMethod = beanClass.getMethod("getPropertyFive",
- (Class[]) null);
- Method writeMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { String[].class });
- Method indexedReadMethod = beanClass.getMethod("get" + propertyName,
- new Class[] { Integer.TYPE });
- Method indexedWriteMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { Integer.TYPE, String.class });
-
- IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor(
- propertyName, readMethod, writeMethod, indexedReadMethod,
- indexedWriteMethod);
-
- IndexedPropertyDescriptor ipd2 = new IndexedPropertyDescriptor(
- propertyName, beanClass);
-
- assertFalse(ipd.equals(ipd2));
- }
-
- /*
- * read method null.
- */
- public void testEquals_ReadMethodNull() throws SecurityException,
- NoSuchMethodException, IntrospectionException {
- String propertyName = "PropertyFour";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
-
- Method readMethod = null;
- Method writeMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { String[].class });
- Method indexedReadMethod = beanClass.getMethod("get" + propertyName,
- new Class[] { Integer.TYPE });
- Method indexedWriteMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { Integer.TYPE, String.class });
-
- IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor(
- propertyName, readMethod, writeMethod, indexedReadMethod,
- indexedWriteMethod);
-
- IndexedPropertyDescriptor ipd2 = new IndexedPropertyDescriptor(
- propertyName, beanClass);
-
- assertFalse(ipd.equals(ipd2));
- }
-
- public void testEquals_WriteMethod() throws SecurityException,
- NoSuchMethodException, IntrospectionException {
- String propertyName = "PropertyFour";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
-
- Method readMethod = beanClass.getMethod("get" + propertyName,
- (Class[]) null);
- Method writeMethod = beanClass.getMethod("setPropertyFive",
- new Class[] { String[].class });
- Method indexedReadMethod = beanClass.getMethod("get" + propertyName,
- new Class[] { Integer.TYPE });
- Method indexedWriteMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { Integer.TYPE, String.class });
-
- IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor(
- propertyName, readMethod, writeMethod, indexedReadMethod,
- indexedWriteMethod);
-
- IndexedPropertyDescriptor ipd2 = new IndexedPropertyDescriptor(
- propertyName, beanClass);
-
- assertFalse(ipd.equals(ipd2));
- }
-
- /*
- * write method null.
- */
- public void testEquals_WriteMethodNull() throws SecurityException,
- NoSuchMethodException, IntrospectionException {
- String propertyName = "PropertyFour";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
-
- Method readMethod = beanClass.getMethod("get" + propertyName,
- (Class[]) null);
- Method writeMethod = null;
- Method indexedReadMethod = beanClass.getMethod("get" + propertyName,
- new Class[] { Integer.TYPE });
- Method indexedWriteMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { Integer.TYPE, String.class });
-
- IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor(
- propertyName, readMethod, writeMethod, indexedReadMethod,
- indexedWriteMethod);
-
- IndexedPropertyDescriptor ipd2 = new IndexedPropertyDescriptor(
- propertyName, beanClass);
-
- assertFalse(ipd.equals(ipd2));
- }
-
- /*
- * Indexed read method.
- */
- public void testEquals_IndexedR() throws SecurityException,
- NoSuchMethodException, IntrospectionException {
- String propertyName = "PropertyFour";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
-
- Method readMethod = beanClass.getMethod("get" + propertyName,
- (Class[]) null);
- Method writeMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { String[].class });
- Method indexedReadMethod = beanClass.getMethod("getPropertyFive",
- new Class[] { Integer.TYPE });
- Method indexedWriteMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { Integer.TYPE, String.class });
-
- IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor(
- propertyName, readMethod, writeMethod, indexedReadMethod,
- indexedWriteMethod);
-
- IndexedPropertyDescriptor ipd2 = new IndexedPropertyDescriptor(
- propertyName, beanClass);
-
- assertFalse(ipd.equals(ipd2));
- }
-
- /*
- * Indexed read method null.
- */
- public void testEquals_IndexedRNull() throws SecurityException,
- NoSuchMethodException, IntrospectionException {
- String propertyName = "PropertyFour";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
-
- Method readMethod = beanClass.getMethod("get" + propertyName,
- (Class[]) null);
- Method writeMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { String[].class });
- Method indexedReadMethod = null;
- Method indexedWriteMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { Integer.TYPE, String.class });
-
- IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor(
- propertyName, readMethod, writeMethod, indexedReadMethod,
- indexedWriteMethod);
-
- IndexedPropertyDescriptor ipd2 = new IndexedPropertyDescriptor(
- propertyName, beanClass);
-
- assertFalse(ipd.equals(ipd2));
- }
-
- /*
- * indexed write method.
- */
- public void testEquals_IndexedW() throws SecurityException,
- NoSuchMethodException, IntrospectionException {
- String propertyName = "PropertyFour";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
-
- Method readMethod = beanClass.getMethod("get" + propertyName,
- (Class[]) null);
- Method writeMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { String[].class });
- Method indexedReadMethod = beanClass.getMethod("get" + propertyName,
- new Class[] { Integer.TYPE });
- Method indexedWriteMethod = beanClass.getMethod("setPropertyFive",
- new Class[] { Integer.TYPE, String.class });
-
- IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor(
- propertyName, readMethod, writeMethod, indexedReadMethod,
- indexedWriteMethod);
-
- IndexedPropertyDescriptor ipd2 = new IndexedPropertyDescriptor(
- propertyName, beanClass);
-
- assertFalse(ipd.equals(ipd2));
- }
-
- /*
- * Indexed write method null.
- */
- public void testEquals_IndexWNull() throws SecurityException,
- NoSuchMethodException, IntrospectionException {
- String propertyName = "PropertyFour";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
-
- Method readMethod = beanClass.getMethod("get" + propertyName,
- (Class[]) null);
- Method writeMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { String[].class });
- Method indexedReadMethod = beanClass.getMethod("get" + propertyName,
- new Class[] { Integer.TYPE });
- Method indexedWriteMethod = null;
-
- IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor(
- propertyName, readMethod, writeMethod, indexedReadMethod,
- indexedWriteMethod);
-
- IndexedPropertyDescriptor ipd2 = new IndexedPropertyDescriptor(
- propertyName, beanClass);
-
- assertFalse(ipd.equals(ipd2));
- }
-
- /*
- * Property Type.
- */
- public void testEquals_PropertyType() throws SecurityException,
- NoSuchMethodException, IntrospectionException {
- String propertyName = "PropertyFour";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
-
- Method readMethod = beanClass.getMethod("get" + propertyName,
- (Class[]) null);
- Method writeMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { String[].class });
- Method indexedReadMethod = beanClass.getMethod("get" + propertyName,
- new Class[] { Integer.TYPE });
- Method indexedWriteMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { Integer.TYPE, String.class });
-
- IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor(
- propertyName, readMethod, writeMethod, indexedReadMethod,
- indexedWriteMethod);
-
- IndexedPropertyDescriptor ipd2 = new IndexedPropertyDescriptor(
- "PropertySix", beanClass);
- assertFalse(ipd.getPropertyType().equals(ipd2.getPropertyType()));
- assertFalse(ipd.equals(ipd2));
- }
-
- /*
- * Class under test for void IndexedPropertyDescriptor(String, Class)
- */
- public void testIndexedPropertyDescriptorStringClass()
- throws IntrospectionException, SecurityException,
- NoSuchMethodException {
- String propertyName = "propertyFour";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
- IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor(
- propertyName, beanClass);
-
- String capitalName = propertyName.substring(0, 1).toUpperCase()
- + propertyName.substring(1);
- Method readMethod = beanClass.getMethod("get" + capitalName,
- (Class[]) null);
- Method writeMethod = beanClass.getMethod("set" + capitalName,
- new Class[] { String[].class });
- Method indexedReadMethod = beanClass.getMethod("get" + capitalName,
- new Class[] { Integer.TYPE });
- Method indexedWriteMethod = beanClass.getMethod("set" + capitalName,
- new Class[] { Integer.TYPE, String.class });
-
- assertEquals(readMethod, ipd.getReadMethod());
- assertEquals(writeMethod, ipd.getWriteMethod());
- assertEquals(indexedReadMethod, ipd.getIndexedReadMethod());
- assertEquals(indexedWriteMethod, ipd.getIndexedWriteMethod());
-
- assertEquals(String[].class, ipd.getPropertyType());
- assertEquals(String.class, ipd.getIndexedPropertyType());
-
- assertFalse(ipd.isBound());
- assertFalse(ipd.isConstrained());
- assertNull(ipd.getPropertyEditorClass());
-
- assertEquals(propertyName, ipd.getDisplayName());
- assertEquals(propertyName, ipd.getName());
- assertEquals(propertyName, ipd.getShortDescription());
-
- assertNotNull(ipd.attributeNames());
-
- assertFalse(ipd.isExpert());
- assertFalse(ipd.isHidden());
- assertFalse(ipd.isPreferred());
-
- // Regression for HARMONY-1236
- try {
- new IndexedPropertyDescriptor("0xDFRF", Float.TYPE);
- fail("IntrospectionException expected");
- } catch (IntrospectionException e) {
- // expected
- }
- }
-
- public void testIndexedPropertyDescriptorStringClass_PropertyNameNull()
- throws IntrospectionException {
- String propertyName = null;
- Class<MockJavaBean> beanClass = MockJavaBean.class;
- try {
- new IndexedPropertyDescriptor(propertyName, beanClass);
- fail("Should throw IntrospectionException");
- } catch (IntrospectionException e) {
- }
- }
-
- public void testIndexedPropertyDescriptorStringClass_PropertyNameEmpty()
- throws IntrospectionException {
- String propertyName = "";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
- try {
- new IndexedPropertyDescriptor(propertyName, beanClass);
- fail("Should throw IntrospectionException");
- } catch (IntrospectionException e) {
- }
- }
-
- public void testIndexedPropertyDescriptorStringClass_PropertyNameInvalid()
- throws IntrospectionException {
- String propertyName = "Not a property";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
- try {
- new IndexedPropertyDescriptor(propertyName, beanClass);
- fail("Should throw IntrospectionException");
- } catch (IntrospectionException e) {
- }
- }
-
- public void testIndexedPropertyDescriptorStringClass_NotIndexedProperty()
- throws IntrospectionException {
- String propertyName = "propertyOne";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
- try {
- new IndexedPropertyDescriptor(propertyName, beanClass);
- fail("Should throw IntrospectionException");
- } catch (IntrospectionException e) {
- }
- }
-
- public void testIndexedPropertyDescriptorStringClass_ClassNull()
- throws IntrospectionException {
- String propertyName = "propertyFour";
- Class<?> beanClass = null;
- try {
- new IndexedPropertyDescriptor(propertyName, beanClass);
- fail("Should throw IntrospectionException");
- } catch (IntrospectionException e) {
- }
- }
-
- /*
- * bean class does not implements java.io.Serializable
- */
- public void testIndexedPropertyDescriptorStringClass_NotBeanClass()
- throws IntrospectionException {
- String propertyName = "propertyOne";
- Class<NotJavaBean> beanClass = NotJavaBean.class;
- IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor(
- propertyName, beanClass);
- assertEquals(String.class, ipd.getIndexedPropertyType());
- }
-
- private class MyClass {
- private int[] a;
-
- public void setA(int v, int i) {
- a[i] = v;
- }
-
- public void setA(int[] a) {
- this.a = a;
- }
-
- public int[] getA() {
- return a;
- }
- }
-
- /*
- * Class under test for void IndexedPropertyDescriptor(String, Class,
- * String, String, String, String)
- */
- public void testIndexedPropertyDescriptorStringClassStringStringStringString()
- throws IntrospectionException, SecurityException,
- NoSuchMethodException {
- String propertyName = "PropertyFour";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
- IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor(
- propertyName, beanClass, "get" + propertyName, "set"
- + propertyName, "get" + propertyName, "set"
- + propertyName);
-
- Method readMethod = beanClass.getMethod("get" + propertyName,
- (Class[]) null);
- Method writeMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { String[].class });
- Method indexedReadMethod = beanClass.getMethod("get" + propertyName,
- new Class[] { Integer.TYPE });
- Method indexedWriteMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { Integer.TYPE, String.class });
-
- assertEquals(readMethod, ipd.getReadMethod());
- assertEquals(writeMethod, ipd.getWriteMethod());
- assertEquals(indexedReadMethod, ipd.getIndexedReadMethod());
- assertEquals(indexedWriteMethod, ipd.getIndexedWriteMethod());
-
- assertEquals(String[].class, ipd.getPropertyType());
- assertEquals(String.class, ipd.getIndexedPropertyType());
-
- assertFalse(ipd.isBound());
- assertFalse(ipd.isConstrained());
- assertNull(ipd.getPropertyEditorClass());
-
- assertEquals(propertyName, ipd.getDisplayName());
- assertEquals(propertyName, ipd.getName());
- assertEquals(propertyName, ipd.getShortDescription());
-
- assertNotNull(ipd.attributeNames());
-
- assertFalse(ipd.isExpert());
- assertFalse(ipd.isHidden());
- assertFalse(ipd.isPreferred());
-
- //empty method name
- new IndexedPropertyDescriptor(
- propertyName, beanClass, "get" + propertyName, "set"
- + propertyName, "", "set"
- + propertyName);
-
- try {
- new IndexedPropertyDescriptor("a", MyClass.class, "getA", "setA",
- "", "setA");
- fail("Shoule throw exception");
- } catch (IntrospectionException e) {
- // expected
- }
-
- try {
- new IndexedPropertyDescriptor(propertyName, beanClass, "",
- "set" + propertyName, "get" + propertyName, "set"
- + propertyName);
- fail("Shoule throw exception");
- } catch (IntrospectionException e) {
- // expected
- }
- try {
- new IndexedPropertyDescriptor(propertyName, beanClass, "get"
- + propertyName, "", "get" + propertyName, "set"
- + propertyName);
- fail("Shoule throw exception");
- } catch (IntrospectionException e) {
- // expected
- }
- try {
- new IndexedPropertyDescriptor(propertyName, beanClass, "get"
- + propertyName, "set" + propertyName, "get" + propertyName,
- "");
- fail("Shoule throw exception");
- } catch (IntrospectionException e) {
- // expected
- }
-
- //null method name
- new IndexedPropertyDescriptor(
- propertyName, beanClass, "get" + propertyName, "set"
- + propertyName, null, "set" + propertyName);
- new IndexedPropertyDescriptor(
- propertyName, beanClass, null, "set" + propertyName, "get"
- + propertyName, "set" + propertyName);
- new IndexedPropertyDescriptor(
- propertyName, beanClass, "get" + propertyName, null, "get"
- + propertyName, "set" + propertyName);
- new IndexedPropertyDescriptor(
- propertyName, beanClass, "get" + propertyName, "set"
- + propertyName, "get" + propertyName, null);
- }
-
- public void testIndexedPropertyDescriptorStringClassStringStringStringString_propNull()
- throws IntrospectionException {
- String propertyName = "PropertyFour";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
- try {
- new IndexedPropertyDescriptor(null, beanClass,
- "get" + propertyName, "set" + propertyName, "get"
- + propertyName, "set" + propertyName);
- fail("Should throw IntrospectionException.");
- } catch (IntrospectionException e) {
- }
- }
-
- public void testIndexedPropertyDescriptorStringClassStringStringStringString_propEmpty() {
- String propertyName = "PropertyFour";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
- try {
- new IndexedPropertyDescriptor("", beanClass, "get" + propertyName,
- "set" + propertyName, "get" + propertyName, "set"
- + propertyName);
- fail("Should throw IntrospectionException.");
- } catch (IntrospectionException e) {
- }
- }
-
- public void testIndexedPropertyDescriptorStringClassStringStringStringString_propInvalid()
- throws IntrospectionException {
- String propertyName = "PropertyFour";
- String invalidProp = "Not a prop";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
- IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor(
- invalidProp, beanClass, "get" + propertyName, "set"
- + propertyName, "get" + propertyName, "set"
- + propertyName);
- assertEquals(String[].class, ipd.getPropertyType());
- assertEquals(String.class, ipd.getIndexedPropertyType());
- assertEquals(invalidProp, ipd.getName());
- }
-
- public void testIndexedPropertyDescriptorStringClassStringStringStringString_BeanClassNull()
- throws IntrospectionException {
- String propertyName = "PropertyFour";
- Class<?> beanClass = null;
- try {
- new IndexedPropertyDescriptor(propertyName, beanClass, "get"
- + propertyName, "set" + propertyName, "get" + propertyName,
- "set" + propertyName);
- fail("Should throw IntrospectionException.");
- } catch (IntrospectionException e) {
- }
- }
-
- public void testIndexedPropertyDescriptorStringClassStringStringStringString_ReadMethodNull()
- throws IntrospectionException {
- String propertyName = "PropertyFour";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
- IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor(
- propertyName, beanClass, null, "set" + propertyName, "get"
- + propertyName, "set" + propertyName);
- assertNull(ipd.getReadMethod());
- assertNotNull(ipd.getWriteMethod());
- assertEquals(String.class, ipd.getIndexedPropertyType());
- }
-
- public void testIndexedPropertyDescriptorStringClassStringStringStringString_WriteMethodNull()
- throws IntrospectionException {
- String propertyName = "PropertyFour";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
- IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor(
- propertyName, beanClass, "get" + propertyName, null, "get"
- + propertyName, "set" + propertyName);
- assertNotNull(ipd.getReadMethod());
- assertNull(ipd.getWriteMethod());
- assertEquals(String.class, ipd.getIndexedPropertyType());
-
- new IndexedPropertyDescriptor(
- propertyName, beanClass, "get" + propertyName, "set"+propertyName, "", "set" + propertyName);
-
- try{
- new IndexedPropertyDescriptor(
- propertyName, beanClass, "get" + propertyName, "set"+propertyName, "get" + propertyName, "");
- fail();
- }catch(Exception e){
- }
- }
-
- public void testIndexedPropertyDescriptorStringClassStringStringStringString_IndexedReadMethodNull()
- throws IntrospectionException {
- String propertyName = "PropertyFour";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
- IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor(
- propertyName, beanClass, "get" + propertyName, "set"
- + propertyName, null, "set" + propertyName);
- assertNull(ipd.getIndexedReadMethod());
- assertNotNull(ipd.getIndexedWriteMethod());
- assertEquals(String.class, ipd.getIndexedPropertyType());
- }
-
- public void testIndexedPropertyDescriptorStringClassStringStringStringString_IndexedWriteMethodNull()
- throws IntrospectionException {
- String propertyName = "PropertyFour";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
- IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor(
- propertyName, beanClass, "get" + propertyName, "set"
- + propertyName, "get" + propertyName, null);
- assertNotNull(ipd.getIndexedReadMethod());
- assertNull(ipd.getIndexedWriteMethod());
- assertEquals(String.class, ipd.getIndexedPropertyType());
- }
-
- /**
- * indexed read/write null
- *
- */
- public void testIndexedPropertyDescriptorStringClassStringStringStringString_RWNull()
- throws IntrospectionException {
- String propertyName = "PropertyFour";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
- IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor(
- propertyName, beanClass, null, null, "get" + propertyName,
- "set" + propertyName);
- assertNull(ipd.getReadMethod());
- assertNull(ipd.getWriteMethod());
- assertEquals(String.class, ipd.getIndexedPropertyType());
- assertNull(ipd.getPropertyType());
- }
-
- /**
- * indexed read/write null
- *
- */
- public void testIndexedPropertyDescriptorStringClassStringStringStringString_IndexedRWNull()
- throws IntrospectionException {
- String propertyName = "PropertyFour";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
- try {
- new IndexedPropertyDescriptor(propertyName, beanClass, "get"
- + propertyName, "set" + propertyName, null, null);
- fail("Should throw IntrospectionException.");
- } catch (IntrospectionException e) {
- }
- }
-
- /**
- * index read /read null
- */
- public void testIndexedPropertyDescriptorStringClassStringStringStringString_RNull()
- throws IntrospectionException {
- String propertyName = "PropertyFour";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
- IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor(
- propertyName, beanClass, null, "set" + propertyName, null,
- "set" + propertyName);
- assertEquals(String.class, ipd.getIndexedPropertyType());
- assertEquals(String[].class, ipd.getPropertyType());
- assertNotNull(ipd.getWriteMethod());
- assertNotNull(ipd.getIndexedWriteMethod());
- }
-
- /**
- * index write /write null
- */
- public void testIndexedPropertyDescriptorStringClassStringStringStringString_WNull()
- throws IntrospectionException {
- String propertyName = "PropertyFour";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
- IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor(
- propertyName, beanClass, "get" + propertyName, null, "get"
- + propertyName, null);
- assertEquals(String.class, ipd.getIndexedPropertyType());
- assertEquals(String[].class, ipd.getPropertyType());
- assertNotNull(ipd.getReadMethod());
- assertNotNull(ipd.getIndexedReadMethod());
- }
-
- public void testIndexedPropertyDescriptorStringClassStringStringStringString_allNull()
- throws IntrospectionException {
- String propertyName = "PropertyFour";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
- IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor(
- propertyName, beanClass, null, null, null, null);
- assertNull(ipd.getIndexedPropertyType());
- assertNull(ipd.getPropertyType());
- assertNull(ipd.getReadMethod());
- assertNull(ipd.getIndexedReadMethod());
- }
-
- /*
- * read/write incompatible
- *
- */
- public void testIndexedPropertyDescriptorStringClassStringStringStringString_RWIncompatible()
- throws IntrospectionException {
- String propertyName = "PropertyFour";
- String anotherProp = "PropertyFive";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
- IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor(
- propertyName, beanClass, "get" + propertyName, "set"
- + anotherProp, "get" + propertyName, "set"
- + propertyName);
- assertEquals(String.class, ipd.getIndexedPropertyType());
- assertEquals(String[].class, ipd.getPropertyType());
- assertEquals("set" + anotherProp, ipd.getWriteMethod().getName());
- }
-
- /**
- * IndexedRead/IndexedWrite incompatible
- *
- * @throws IntrospectionException
- *
- */
- public void testIndexedPropertyDescriptorStringClassStringStringStringString_IndexedRWIncompatible()
- throws IntrospectionException {
- String propertyName = "PropertyFour";
- String anotherProp = "PropertyFive";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
- IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor(
- propertyName, beanClass, "get" + propertyName, "set"
- + propertyName, "get" + propertyName, "set"
- + anotherProp);
- assertEquals(String.class, ipd.getIndexedPropertyType());
- assertEquals(String[].class, ipd.getPropertyType());
- assertEquals("set" + anotherProp, ipd.getIndexedWriteMethod().getName());
- }
-
- /*
- * ReadMethod/IndexedReadMethod incompatible
- *
- */
- public void testIndexedPropertyDescriptorStringClassStringStringStringString_RIndexedRcompatible()
- throws IntrospectionException {
- String propertyName = "PropertyFour";
- String anotherProp = "PropertyFive";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
- IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor(
- propertyName, beanClass, "get" + propertyName, "set"
- + propertyName, "get" + anotherProp, "set"
- + anotherProp);
- assertEquals(String.class, ipd.getIndexedPropertyType());
- assertEquals(String[].class, ipd.getPropertyType());
- assertEquals("set" + anotherProp, ipd.getIndexedWriteMethod().getName());
- }
-
- public void testIndexedPropertyDescriptorStringClassStringStringStringString_WrongArgumentNumber()
- throws IntrospectionException {
- IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor("a", DummyClass.class, null, "setAI",
- "getAI", "setAI");
- assertNotNull(ipd);
- }
-
- private class DummyClass {
- private int[] a;
-
- public void setAI(int v, int i) {
- a[i] = v;
- }
-
- public void setAI(int[] a) {
- this.a = a;
- }
-
- public int[] getA() {
- return a;
- }
-
- public int getAI(int i) {
- return a[i];
- }
- }
-
- /*
- * Class under test for void IndexedPropertyDescriptor(String, Method,
- * Method, Method, Method)
- */
- public void testIndexedPropertyDescriptorStringMethodMethodMethodMethod()
- throws SecurityException, NoSuchMethodException,
- IntrospectionException {
- String propertyName = "PropertyFour";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
-
- Method readMethod = beanClass.getMethod("get" + propertyName,
- (Class[]) null);
- Method writeMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { String[].class });
- Method indexedReadMethod = beanClass.getMethod("get" + propertyName,
- new Class[] { Integer.TYPE });
- Method indexedWriteMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { Integer.TYPE, String.class });
-
- IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor(
- propertyName, readMethod, writeMethod, indexedReadMethod,
- indexedWriteMethod);
-
- assertEquals(readMethod, ipd.getReadMethod());
- assertEquals(writeMethod, ipd.getWriteMethod());
- assertEquals(indexedReadMethod, ipd.getIndexedReadMethod());
- assertEquals(indexedWriteMethod, ipd.getIndexedWriteMethod());
-
- assertEquals(String[].class, ipd.getPropertyType());
- assertEquals(String.class, ipd.getIndexedPropertyType());
-
- assertFalse(ipd.isBound());
- assertFalse(ipd.isConstrained());
- assertNull(ipd.getPropertyEditorClass());
-
- assertEquals(propertyName, ipd.getDisplayName());
- assertEquals(propertyName, ipd.getName());
- assertEquals(propertyName, ipd.getShortDescription());
-
- assertNotNull(ipd.attributeNames());
-
- assertFalse(ipd.isExpert());
- assertFalse(ipd.isHidden());
- assertFalse(ipd.isPreferred());
- }
-
- /*
- * propertyName=null
- */
- public void testIndexedPropertyDescriptorStringMethodMethodMethodMethod_propNull()
- throws SecurityException, NoSuchMethodException,
- IntrospectionException {
- String propertyName = "PropertyFour";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
-
- Method readMethod = beanClass.getMethod("get" + propertyName,
- (Class[]) null);
- Method writeMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { String[].class });
- Method indexedReadMethod = beanClass.getMethod("get" + propertyName,
- new Class[] { Integer.TYPE });
- Method indexedWriteMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { Integer.TYPE, String.class });
-
- try {
- new IndexedPropertyDescriptor(null, readMethod, writeMethod,
- indexedReadMethod, indexedWriteMethod);
- fail("Should throw IntrospectionException.");
- } catch (IntrospectionException e) {
- }
- }
-
- /*
- * propertyname="";
- */
- public void testIndexedPropertyDescriptorStringMethodMethodMethodMethod_propEmpty()
- throws SecurityException, NoSuchMethodException {
- String propertyName = "PropertyFour";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
-
- Method readMethod = beanClass.getMethod("get" + propertyName,
- (Class[]) null);
- Method writeMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { String[].class });
- Method indexedReadMethod = beanClass.getMethod("get" + propertyName,
- new Class[] { Integer.TYPE });
- Method indexedWriteMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { Integer.TYPE, String.class });
-
- try {
- new IndexedPropertyDescriptor("", readMethod, writeMethod,
- indexedReadMethod, indexedWriteMethod);
- fail("Should throw IntrospectionException.");
- } catch (IntrospectionException e) {
- }
- }
-
- public void testIndexedPropertyDescriptorStringMethodMethodMethodMethod_propInvalid()
- throws SecurityException, NoSuchMethodException,
- IntrospectionException {
- String propertyName = "PropertyFour";
- String invalidName = "An Invalid Property name";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
-
- Method readMethod = beanClass.getMethod("get" + propertyName,
- (Class[]) null);
- Method writeMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { String[].class });
- Method indexedReadMethod = beanClass.getMethod("get" + propertyName,
- new Class[] { Integer.TYPE });
- Method indexedWriteMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { Integer.TYPE, String.class });
-
- IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor(
- invalidName, readMethod, writeMethod, indexedReadMethod,
- indexedWriteMethod);
- assertEquals(invalidName, ipd.getName());
- assertEquals(String.class, ipd.getIndexedPropertyType());
- }
-
- public void testIndexedPropertyDescriptorStringMethodMethodMethodMethod_ReadMethodNull()
- throws SecurityException, NoSuchMethodException,
- IntrospectionException {
- String propertyName = "PropertyFour";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
-
- Method writeMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { String[].class });
- Method indexedReadMethod = beanClass.getMethod("get" + propertyName,
- new Class[] { Integer.TYPE });
- Method indexedWriteMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { Integer.TYPE, String.class });
-
- IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor(
- propertyName, null, writeMethod, indexedReadMethod,
- indexedWriteMethod);
- assertNull(ipd.getReadMethod());
- assertEquals(String[].class, ipd.getPropertyType());
- assertEquals(String.class, ipd.getIndexedPropertyType());
- }
-
- public void testIndexedPropertyDescriptorStringMethodMethodMethodMethod_WriteMethodNull()
- throws SecurityException, NoSuchMethodException,
- IntrospectionException {
- String propertyName = "PropertyFour";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
-
- Method readMethod = beanClass.getMethod("get" + propertyName,
- (Class[]) null);
- Method indexedReadMethod = beanClass.getMethod("get" + propertyName,
- new Class[] { Integer.TYPE });
- Method indexedWriteMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { Integer.TYPE, String.class });
-
- IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor(
- propertyName, readMethod, null, indexedReadMethod,
- indexedWriteMethod);
- assertNull(ipd.getWriteMethod());
- assertEquals(String[].class, ipd.getPropertyType());
- assertEquals(String.class, ipd.getIndexedPropertyType());
- }
-
- public void testIndexedPropertyDescriptorStringMethodMethodMethodMethod_IndexedReadMethodNull()
- throws SecurityException, NoSuchMethodException,
- IntrospectionException {
- String propertyName = "PropertyFour";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
-
- Method readMethod = beanClass.getMethod("get" + propertyName,
- (Class[]) null);
- Method writeMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { String[].class });
- Method indexedWriteMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { Integer.TYPE, String.class });
-
- IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor(
- propertyName, readMethod, writeMethod, null, indexedWriteMethod);
- assertNull(ipd.getIndexedReadMethod());
- assertEquals(String[].class, ipd.getPropertyType());
- assertEquals(String.class, ipd.getIndexedPropertyType());
- }
-
- public void testIndexedPropertyDescriptorStringMethodMethodMethodMethod_IndexedWriteMethodNull()
- throws SecurityException, NoSuchMethodException,
- IntrospectionException {
- String propertyName = "PropertyFour";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
-
- Method readMethod = beanClass.getMethod("get" + propertyName,
- (Class[]) null);
- Method writeMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { String[].class });
- Method indexedReadMethod = beanClass.getMethod("get" + propertyName,
- new Class[] { Integer.TYPE });
-
- IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor(
- propertyName, readMethod, writeMethod, indexedReadMethod, null);
- assertNull(ipd.getIndexedWriteMethod());
- assertEquals(String[].class, ipd.getPropertyType());
- assertEquals(String.class, ipd.getIndexedPropertyType());
-
- }
-
- public void testIndexedPropertyDescriptorStringMethodMethodMethodMethod_IndexedRWNull()
- throws SecurityException, NoSuchMethodException,
- IntrospectionException {
- String propertyName = "PropertyFour";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
-
- Method readMethod = beanClass.getMethod("get" + propertyName,
- (Class[]) null);
- Method writeMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { String[].class });
- try {
- new IndexedPropertyDescriptor(propertyName, readMethod,
- writeMethod, null, null);
- fail("Should throw IntrospectionException.");
- } catch (IntrospectionException e) {
- }
-
- }
-
- public void testIndexedPropertyDescriptorStringMethodMethodMethodMethod_RWNull()
- throws SecurityException, NoSuchMethodException,
- IntrospectionException {
- String propertyName = "PropertyFour";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
-
- Method indexedReadMethod = beanClass.getMethod("get" + propertyName,
- new Class[] { Integer.TYPE });
- Method indexedWriteMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { Integer.TYPE, String.class });
-
- IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor(
- propertyName, null, null, indexedReadMethod, indexedWriteMethod);
-
- assertNull(ipd.getPropertyType());
- assertEquals(String.class, ipd.getIndexedPropertyType());
-
- }
-
- /*
- * read/write incompatible
- */
- public void testIndexedPropertyDescriptorStringMethodMethodMethodMethod_RWIncompatible()
- throws SecurityException, NoSuchMethodException,
- IntrospectionException {
- String propertyName = "PropertyFour";
- String anotherProp = "PropertyFive";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
-
- Method readMethod = beanClass.getMethod("get" + propertyName,
- (Class[]) null);
- Method writeMethod = beanClass.getMethod("set" + anotherProp,
- new Class[] { String[].class });
- Method indexedReadMethod = beanClass.getMethod("get" + propertyName,
- new Class[] { Integer.TYPE });
- Method indexedWriteMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { Integer.TYPE, String.class });
-
- IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor(
- propertyName, readMethod, writeMethod, indexedReadMethod,
- indexedWriteMethod);
- assertEquals(propertyName, ipd.getName());
- assertEquals(String[].class, ipd.getPropertyType());
- assertEquals(String.class, ipd.getIndexedPropertyType());
-
- }
-
- /*
- * IndexedRead/IndexedWrite incompatible
- */
- public void testIndexedPropertyDescriptorStringMethodMethodMethodMethod_IndexedRWIncompatible()
- throws SecurityException, NoSuchMethodException,
- IntrospectionException {
- String propertyName = "PropertyFour";
- String anotherProp = "PropertyFive";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
-
- Method readMethod = beanClass.getMethod("get" + propertyName,
- (Class[]) null);
- Method writeMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { String[].class });
- Method indexedReadMethod = beanClass.getMethod("get" + anotherProp,
- new Class[] { Integer.TYPE });
- Method indexedWriteMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { Integer.TYPE, String.class });
-
- IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor(
- propertyName, readMethod, writeMethod, indexedReadMethod,
- indexedWriteMethod);
- assertEquals(propertyName, ipd.getName());
- assertEquals(String[].class, ipd.getPropertyType());
- assertEquals(String.class, ipd.getIndexedPropertyType());
-
- indexedReadMethod = beanClass.getMethod("get" + anotherProp,
- new Class[] { Integer.TYPE, Integer.TYPE });
- try {
- new IndexedPropertyDescriptor(
- propertyName, readMethod, writeMethod, indexedReadMethod,
- indexedWriteMethod);
- fail("should throw IntrosecptionException");
- } catch (IntrospectionException e) {
- // expected
- }
- }
-
- public void testSetIndexedReadMethod() throws SecurityException,
- NoSuchMethodException, IntrospectionException {
- String propertyName = "PropertyFour";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
-
- Method readMethod = beanClass.getMethod("get" + propertyName,
- (Class[]) null);
- Method writeMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { String[].class });
- Method indexedReadMethod = beanClass.getMethod("get" + propertyName,
- new Class[] { Integer.TYPE });
- Method indexedWriteMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { Integer.TYPE, String.class });
-
- IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor(
- propertyName, readMethod, writeMethod, null, indexedWriteMethod);
- assertNull(ipd.getIndexedReadMethod());
- ipd.setIndexedReadMethod(indexedReadMethod);
- assertSame(indexedReadMethod, ipd.getIndexedReadMethod());
- }
-
- public void testSetIndexedReadMethod_invalid() throws SecurityException,
- NoSuchMethodException, IntrospectionException {
- String propertyName = "PropertyFour";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
-
- Method indexedReadMethod = beanClass.getMethod("get" + propertyName,
- new Class[] { Integer.TYPE });
-
- Method indexedWriteMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { Integer.TYPE, String.class });
-
- IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor(
- propertyName, null, null, indexedReadMethod, indexedWriteMethod);
- Method indexedReadMethod2 = beanClass.getMethod("getPropertySix",
- new Class[] { Integer.TYPE });
- try {
- ipd.setIndexedReadMethod(indexedReadMethod2);
- fail("Should throw IntrospectionException.");
- } catch (IntrospectionException e) {
-
- }
- }
-
- public void testSetIndexedReadMethod_null() throws SecurityException,
- NoSuchMethodException, IntrospectionException {
- String propertyName = "PropertyFour";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
-
- Method readMethod = beanClass.getMethod("get" + propertyName,
- (Class[]) null);
- Method writeMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { String[].class });
- Method indexedReadMethod = beanClass.getMethod("get" + propertyName,
- new Class[] { Integer.TYPE });
- Method indexedWriteMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { Integer.TYPE, String.class });
-
- IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor(
- propertyName, readMethod, writeMethod, indexedReadMethod,
- indexedWriteMethod);
- assertSame(indexedReadMethod, ipd.getIndexedReadMethod());
- ipd.setIndexedReadMethod(null);
- assertNull(ipd.getIndexedReadMethod());
- }
-
- /*
- * indexed read method without args
- */
- public void testSetIndexedReadMethod_RInvalidArgs()
- throws SecurityException, NoSuchMethodException,
- IntrospectionException {
- String propertyName = "PropertyFour";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
-
- Method readMethod = beanClass.getMethod("get" + propertyName,
- (Class[]) null);
- Method writeMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { String[].class });
- Method indexedReadMethod = beanClass.getMethod("get" + propertyName,
- new Class[] { Integer.TYPE });
- Method indexedWriteMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { Integer.TYPE, String.class });
-
- IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor(
- propertyName, readMethod, writeMethod, indexedReadMethod,
- indexedWriteMethod);
- assertSame(indexedReadMethod, ipd.getIndexedReadMethod());
- try {
- ipd.setIndexedReadMethod(readMethod);
- fail("Should throw IntrospectionException.");
- } catch (IntrospectionException e) {
- }
- }
-
- /*
- * indexed read method with invalid arg type (!Integer.TYPE)
- */
- public void testSetIndexedReadMethod_RInvalidArgType()
- throws SecurityException, NoSuchMethodException,
- IntrospectionException {
- String propertyName = "PropertyFour";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
-
- Method readMethod = beanClass.getMethod("get" + propertyName,
- (Class[]) null);
- Method writeMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { String[].class });
- Method indexedReadMethod = beanClass.getMethod("get" + propertyName,
- new Class[] { Integer.TYPE });
- Method indexedWriteMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { Integer.TYPE, String.class });
-
- IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor(
- propertyName, readMethod, writeMethod, indexedReadMethod,
- indexedWriteMethod);
- assertSame(indexedReadMethod, ipd.getIndexedReadMethod());
- try {
- ipd.setIndexedReadMethod(writeMethod);
- fail("Should throw IntrospectionException.");
- } catch (IntrospectionException e) {
- }
- }
-
- /*
- * indexed read method with void return.
- */
- public void testSetIndexedReadMethod_RInvalidReturn()
- throws SecurityException, NoSuchMethodException,
- IntrospectionException {
- String propertyName = "PropertyFour";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
-
- Method readMethod = beanClass.getMethod("get" + propertyName,
- (Class[]) null);
- Method writeMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { String[].class });
- Method indexedReadMethod = beanClass.getMethod("get" + propertyName,
- new Class[] { Integer.TYPE });
- Method indexedWriteMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { Integer.TYPE, String.class });
-
- IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor(
- propertyName, readMethod, writeMethod, indexedReadMethod,
- indexedWriteMethod);
- assertSame(indexedReadMethod, ipd.getIndexedReadMethod());
- Method voidMethod = beanClass.getMethod("getPropertyFourInvalid",
- new Class[] { Integer.TYPE });
- try {
- ipd.setIndexedReadMethod(voidMethod);
- fail("Should throw IntrospectionException.");
- } catch (IntrospectionException e) {
- }
- }
-
- public void testSetIndexedWriteMethod_null() throws IntrospectionException,
- NoSuchMethodException, NoSuchMethodException {
- String propertyName = "PropertyFour";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
-
- Method readMethod = beanClass.getMethod("get" + propertyName,
- (Class[]) null);
- Method writeMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { String[].class });
- Method indexedReadMethod = beanClass.getMethod("get" + propertyName,
- new Class[] { Integer.TYPE });
- Method indexedWriteMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { Integer.TYPE, String.class });
-
- IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor(
- propertyName, readMethod, writeMethod, indexedReadMethod,
- indexedWriteMethod);
- assertSame(indexedWriteMethod, ipd.getIndexedWriteMethod());
- ipd.setIndexedWriteMethod(null);
- assertNull(ipd.getIndexedWriteMethod());
- }
-
- public void testSetIndexedWriteMethod() throws IntrospectionException,
- NoSuchMethodException, NoSuchMethodException {
- String propertyName = "PropertyFour";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
-
- Method readMethod = beanClass.getMethod("get" + propertyName,
- (Class[]) null);
- Method writeMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { String[].class });
- Method indexedReadMethod = beanClass.getMethod("get" + propertyName,
- new Class[] { Integer.TYPE });
- Method indexedWriteMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { Integer.TYPE, String.class });
-
- IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor(
- propertyName, readMethod, writeMethod, indexedReadMethod, null);
- assertNull(ipd.getIndexedWriteMethod());
- ipd.setIndexedWriteMethod(indexedWriteMethod);
- assertSame(indexedWriteMethod, ipd.getIndexedWriteMethod());
- }
-
- /*
- * bad arg count
- */
- public void testSetIndexedWriteMethod_noargs()
- throws IntrospectionException, NoSuchMethodException,
- NoSuchMethodException {
- String propertyName = "PropertyFour";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
-
- Method readMethod = beanClass.getMethod("get" + propertyName,
- (Class[]) null);
- Method writeMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { String[].class });
- Method indexedReadMethod = beanClass.getMethod("get" + propertyName,
- new Class[] { Integer.TYPE });
-
- IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor(
- propertyName, readMethod, writeMethod, indexedReadMethod, null);
- assertNull(ipd.getIndexedWriteMethod());
- try {
- ipd.setIndexedWriteMethod(indexedReadMethod);
- fail("Should throw IntrospectionException.");
- } catch (IntrospectionException e) {
- }
- }
-
- /*
- * bad arg type
- */
- public void testSetIndexedWriteMethod_badargtype()
- throws IntrospectionException, NoSuchMethodException,
- NoSuchMethodException {
- String propertyName = "PropertyFour";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
-
- Method readMethod = beanClass.getMethod("get" + propertyName,
- (Class[]) null);
- Method writeMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { String[].class });
- Method indexedReadMethod = beanClass.getMethod("get" + propertyName,
- new Class[] { Integer.TYPE });
-
- IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor(
- propertyName, readMethod, writeMethod, indexedReadMethod, null);
- assertNull(ipd.getIndexedWriteMethod());
- Method badArgType = beanClass.getMethod("set" + propertyName,
- new Class[] { Integer.TYPE, Integer.TYPE });
- try {
- ipd.setIndexedWriteMethod(badArgType);
- fail("Should throw IntrospectionException");
- } catch (IntrospectionException e) {
- }
- }
-
- public void testSetIndexedWriteMethod_return()
- throws IntrospectionException, NoSuchMethodException,
- NoSuchMethodException {
- String propertyName = "PropertyFour";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
-
- Method readMethod = beanClass.getMethod("get" + propertyName,
- (Class[]) null);
- Method writeMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { String[].class });
- Method indexedReadMethod = beanClass.getMethod("get" + propertyName,
- new Class[] { Integer.TYPE });
-
- IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor(
- propertyName, readMethod, writeMethod, indexedReadMethod, null);
- assertNull(ipd.getIndexedWriteMethod());
- Method badArgType = beanClass.getMethod("setPropertyFourInvalid",
- new Class[] { Integer.TYPE, String.class });
- ipd.setIndexedWriteMethod(badArgType);
-
- assertEquals(String.class, ipd.getIndexedPropertyType());
- assertEquals(String[].class, ipd.getPropertyType());
- assertEquals(Integer.TYPE, ipd.getIndexedWriteMethod().getReturnType());
- }
-
- public void testSetIndexedWriteMethod_InvalidIndexType()
- throws IntrospectionException, NoSuchMethodException,
- NoSuchMethodException {
- String propertyName = "PropertyFour";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
-
- Method readMethod = beanClass.getMethod("get" + propertyName,
- (Class[]) null);
- Method writeMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { String[].class });
- Method indexedReadMethod = beanClass.getMethod("get" + propertyName,
- new Class[] { Integer.TYPE });
-
- IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor(
- propertyName, readMethod, writeMethod, indexedReadMethod, null);
- assertNull(ipd.getIndexedWriteMethod());
- Method badArgType = beanClass.getMethod("setPropertyFourInvalid2",
- new Class[] { String.class, String.class });
- try {
- ipd.setIndexedWriteMethod(badArgType);
- fail("Should throw IntrospectionException");
- } catch (IntrospectionException e) {
- }
-
- ipd = new IndexedPropertyDescriptor("data", NormalBean.class);
- ipd.setIndexedReadMethod(null);
- try {
- ipd.setIndexedWriteMethod(NormalBean.class.getMethod("setData", Integer.TYPE, Integer.TYPE));
- fail("should throw IntrospectionException");
- } catch (IntrospectionException e) {
- // expected
- }
- }
-
- public void testSetIndexedMethodNullNull() throws Exception {
- try {
- IndexedPropertyDescriptor i = new IndexedPropertyDescriptor("a",
- NormalBean.class, "getData", "setData", null,
- "setData");
- i.setIndexedWriteMethod(null);
- fail("should throw IntrospectionException.");
- } catch (IntrospectionException e) {
- // expected
- }
- try {
- IndexedPropertyDescriptor i = new IndexedPropertyDescriptor("a",
- NormalBean.class, "getData", "setData",
- "getData", null);
- i.setIndexedReadMethod(null);
- fail("should throw IntrospectionException.");
- } catch (IntrospectionException e) {
- // expected
- }
- }
-
-
- public void testSetIndexedReadMethodFollowANullValue() throws Exception {
- try {
- IndexedPropertyDescriptor i = new IndexedPropertyDescriptor("a",
- DummyBean.class, "readMethod", "writeMethod", null,
- "indexedReadMethod");
- Method irm = DummyBean.class.getDeclaredMethod("indexedReadMethod",
- Integer.TYPE);
- i.setIndexedReadMethod(irm);
- fail("should throw IntrospectionException.");
- } catch (IntrospectionException e) {
- // expected
- }
- }
-
- static class DummyBean {
-
- public int[] readMehtod() {
- return null;
- }
-
- public void writeMethod(int[] a) {
- }
-
- public double indexedReadMethod(int i) {
- return 0;
- }
-
- public void indexedWriteMethod(int i, int j) {
- }
-
- }
-
- class NotJavaBean {
-
- private String[] propertyOne;
-
- /**
- * @return Returns the propertyOne.
- */
- public String[] getPropertyOne() {
- return propertyOne;
- }
-
- /**
- * @param propertyOne
- * The propertyOne to set.
- */
- public void setPropertyOne(String[] propertyOne) {
- this.propertyOne = propertyOne;
- }
-
- public String getPropertyOne(int i) {
- return getPropertyOne()[i];
- }
-
- public void setPropertyOne(int i, String value) {
- this.propertyOne[i] = value;
- }
-
- }
-
- //Regression Test
- class InCompatibleGetterSetterBean
- {
- private Object[] data = new Object[10];
- public void setData(Object[] data) {
- this.data = data;
- }
- public Object[] getDate() {
- return data;
- }
- public void setData(int index, Object o) {
- this.data[index] = o;
- }
- }
-
- public void testInCompatibleGetterSetterBean() {
- try {
- new IndexedPropertyDescriptor("data",
- InCompatibleGetterSetterBean.class);
- fail("should throw IntrospectionException");
- } catch (IntrospectionException e) {
- // expected
- }
- }
-
- class NormalBean {
- private Object[] data = new Object[10];
-
- public Object[] getData() {
- return data;
- }
-
- public void setData(Object[] data) {
- this.data = data;
- }
-
- public void setData(int index, Object o) {
- data[index] = o;
- }
-
- public void setData(int index, int value) {
- // do nothing
- }
-
- public Object getData(int index) {
- return data[index];
- }
- }
-
- public void testEquals_superClass() throws Exception {
- PropertyDescriptor propertyDescriptor = new PropertyDescriptor("data",
- NormalBean.class);
- IndexedPropertyDescriptor indexedPropertyDescriptor = new IndexedPropertyDescriptor(
- "data", NormalBean.class);
- assertFalse(indexedPropertyDescriptor.equals(propertyDescriptor));
- assertTrue(propertyDescriptor.equals(indexedPropertyDescriptor));
- }
-
- public void testHashCode() throws Exception {
- String propertyName = "PropertyFour";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
-
- Method readMethod = beanClass.getMethod("get" + propertyName,
- (Class[]) null);
- Method writeMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { String[].class });
- Method indexedReadMethod = beanClass.getMethod("get" + propertyName,
- new Class[] { Integer.TYPE });
- Method indexedWriteMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { Integer.TYPE, String.class });
-
- IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor(
- propertyName, readMethod, writeMethod, indexedReadMethod,
- indexedWriteMethod);
-
- IndexedPropertyDescriptor ipd2 = new IndexedPropertyDescriptor(
- propertyName, beanClass);
-
- assertEquals(ipd, ipd2);
- assertEquals(ipd.hashCode(), ipd2.hashCode());
- }
-
- public void testIncompatibleGetterAndIndexedGetterBean() {
- try {
- new IndexedPropertyDescriptor("data",
- IncompatibleGetterAndIndexedGetterBean.class);
- fail("should throw IntrospectionException");
-
- } catch (IntrospectionException e) {
- //expected
- }
- }
-
- private class IncompatibleGetterAndIndexedGetterBean {
- private int[] data;
-
- public int getData() {
- return data[0];
- }
-
- public int getData(int index) {
- return data[index];
- }
-
- public void setData(int index, int data) {
- this.data[index] = data;
- }
- }
-}
diff --git a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/IntrospectionExceptionTest.java b/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/IntrospectionExceptionTest.java
deleted file mode 100644
index 1facbc2..0000000
--- a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/IntrospectionExceptionTest.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * 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.java.beans;
-
-import java.beans.IntrospectionException;
-
-import junit.framework.TestCase;
-
-import org.apache.harmony.testframework.serialization.SerializationTest;
-
-/**
- * Unit test of IntrospectionException.
- */
-
-public class IntrospectionExceptionTest extends TestCase {
-
- public void testConstructor() {
- String message = "IntrospectionExceptionTest";
- IntrospectionException e = new IntrospectionException(message);
- assertSame(message, e.getMessage());
- }
-
- public void testConstructor_MessageNull() {
- IntrospectionException e = new IntrospectionException(null);
- assertNull(e.getMessage());
- }
-
- /**
- * @tests serialization/deserialization.
- */
- public void testSerializationSelf() throws Exception {
-
- SerializationTest.verifySelf(new IntrospectionException(
- "IntrospectionExceptionTest"));
- }
-
- /**
- * @tests serialization/deserialization compatibility with RI.
- */
- public void testSerializationCompatibility() throws Exception {
-
- SerializationTest.verifyGolden(this, new IntrospectionException(
- "IntrospectionExceptionTest"));
- }
-
- public void testIntrospectionExceptionMessage() {
- // Regression for HARMONY-235
- IntrospectionException e = new IntrospectionException("test message");
- assertEquals("test message", e.getMessage());
- }
-}
diff --git a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/IntrospectorTest.java b/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/IntrospectorTest.java
deleted file mode 100644
index 78bf638..0000000
--- a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/IntrospectorTest.java
+++ /dev/null
@@ -1,6521 +0,0 @@
-/*
- * 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.java.beans;
-
-import java.awt.Image;
-import java.awt.image.BufferedImage;
-import java.beans.BeanDescriptor;
-import java.beans.BeanInfo;
-import java.beans.EventSetDescriptor;
-import java.beans.IndexedPropertyDescriptor;
-import java.beans.IntrospectionException;
-import java.beans.Introspector;
-import java.beans.MethodDescriptor;
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyDescriptor;
-import java.beans.SimpleBeanInfo;
-import java.io.Serializable;
-import java.lang.reflect.Method;
-import java.security.Permission;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.EventListener;
-import java.util.EventObject;
-import java.util.PropertyPermission;
-import java.util.TooManyListenersException;
-
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.apache.harmony.beans.tests.support.ChildBean;
-import org.apache.harmony.beans.tests.support.GrannyBean;
-import org.apache.harmony.beans.tests.support.MisprintBean;
-import org.apache.harmony.beans.tests.support.OtherBean;
-import org.apache.harmony.beans.tests.support.SampleBean;
-import org.apache.harmony.beans.tests.support.StandardBean2;
-import org.apache.harmony.beans.tests.support.mock.FakeFox;
-import org.apache.harmony.beans.tests.support.mock.FakeFox01;
-import org.apache.harmony.beans.tests.support.mock.FakeFox011;
-import org.apache.harmony.beans.tests.support.mock.FakeFox01BeanInfo;
-import org.apache.harmony.beans.tests.support.mock.FakeFox02;
-import org.apache.harmony.beans.tests.support.mock.FakeFox031;
-import org.apache.harmony.beans.tests.support.mock.FakeFox041;
-import org.apache.harmony.beans.tests.support.mock.FakeFox0411;
-import org.apache.harmony.beans.tests.support.mock.MockButton;
-import org.apache.harmony.beans.tests.support.mock.MockFoo;
-import org.apache.harmony.beans.tests.support.mock.MockFooButton;
-import org.apache.harmony.beans.tests.support.mock.MockFooLabel;
-import org.apache.harmony.beans.tests.support.mock.MockFooStop;
-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.MockNullSubClass;
-import org.apache.harmony.beans.tests.support.mock.MockSubClass;
-
-/**
- * Unit test for Introspector.
- */
-public class IntrospectorTest extends TestCase {
-
- private String[] defaultPackage;
-
- public IntrospectorTest(String str) {
- super(str);
- }
-
- public IntrospectorTest() {}
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- defaultPackage = Introspector.getBeanInfoSearchPath();
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- Introspector.flushCaches();
- Introspector.setBeanInfoSearchPath(defaultPackage);
- }
-
- /**
- * The test checks the constructor is private
- */
- public void testIntrospectorConstructor() {
- try {
- Class.forName("java.beans.Introspector").newInstance();
- fail("No exception is thrown on new Introspector() call");
- } catch (Exception e) {
- }
- }
-
- /**
- * The test checks the getBeanDescriptor method
- */
- public void testBeanDescriptor() throws Exception {
- String[] oldBeanInfoSearchPath = Introspector.getBeanInfoSearchPath();
- try {
- Introspector
- .setBeanInfoSearchPath(new String[] { "java.beans.infos" });
- BeanInfo info = Introspector.getBeanInfo(SampleBean.class);
- assertNotNull(info);
- BeanDescriptor descriptor = info.getBeanDescriptor();
- assertNotNull(descriptor);
- assertEquals(SampleBean.class, descriptor.getBeanClass());
- } finally {
- Introspector.setBeanInfoSearchPath(oldBeanInfoSearchPath);
- }
- }
-
- public void testBeanDescriptor_Same() throws Exception {
- BeanInfo beanInfo = Introspector.getBeanInfo(MockJavaBean.class);
- assertSame(beanInfo.getBeanDescriptor(), beanInfo.getBeanDescriptor());
- }
-
- /**
- * The test checks the getMethodDescriptor method
- *
- * @throws IntrospectionException
- */
- public void testNonUniqueByNameMethodDescriptors()
- throws IntrospectionException {
- BeanInfo info = Introspector.getBeanInfo(ChildBean.class);
- assertNotNull(info);
- MethodDescriptor[] mds = info.getMethodDescriptors();
- assertNotNull(mds);
- assertEquals(11, mds.length);
- }
-
- /**
- * The test checks the getEventSetDescriptors method
- *
- * @throws IntrospectionException
- */
- public void testUnicastEventSetDescriptor() throws IntrospectionException {
- BeanInfo info = Introspector.getBeanInfo(SampleBean.class);
- assertNotNull(info);
- EventSetDescriptor[] descriptors = info.getEventSetDescriptors();
- assertNotNull(descriptors);
- for (EventSetDescriptor descriptor : descriptors) {
- Method m = descriptor.getAddListenerMethod();
- if (m != null) {
- Class<?>[] exceptionTypes = m.getExceptionTypes();
- boolean found = false;
-
- for (Class<?> et : exceptionTypes) {
- if (et
- .equals(TooManyListenersException.class)) {
- assertTrue(descriptor.isUnicast());
- found = true;
- break;
- }
- }
-
- if (!found) {
- assertFalse(descriptor.isUnicast());
- }
- }
- }
- }
-
- /**
- * The test checks the getEventSetDescriptors method
- *
- * @throws IntrospectionException
- */
- public void testEventSetDescriptorWithoutAddListenerMethod()
- throws IntrospectionException {
- BeanInfo info = Introspector.getBeanInfo(OtherBean.class);
- EventSetDescriptor[] descriptors;
-
- assertNotNull(info);
- descriptors = info.getEventSetDescriptors();
- assertNotNull(descriptors);
- assertEquals(1, descriptors.length);
- assertTrue(contains("sample", descriptors));
- }
-
- /**
- * The test checks the getEventSetDescriptors method
- *
- * @throws IntrospectionException
- */
- public void testIllegalEventSetDescriptor() throws IntrospectionException {
- BeanInfo info = Introspector.getBeanInfo(MisprintBean.class);
- assertNotNull(info);
- EventSetDescriptor[] descriptors = info.getEventSetDescriptors();
- assertNotNull(descriptors);
- assertEquals(0, descriptors.length);
- }
-
- /**
- * The test checks the getPropertyDescriptors method
- *
- * @throws IntrospectionException
- */
- public void testPropertyDescriptorWithSetMethod()
- throws IntrospectionException {
- BeanInfo info = Introspector.getBeanInfo(OtherBean.class);
- assertNotNull(info);
- PropertyDescriptor[] descriptors = info.getPropertyDescriptors();
- assertNotNull(descriptors);
- assertEquals(2, descriptors.length);
- assertEquals("class", descriptors[0].getName());
- assertEquals("number", descriptors[1].getName());
- }
-
- /**
- * The test checks the getPropertyDescriptors method
- *
- * @throws IntrospectionException
- */
- public void testUseAllBeanInfo() throws IntrospectionException {
- BeanInfo info = Introspector.getBeanInfo(ChildBean.class,
- Introspector.USE_ALL_BEANINFO);
- PropertyDescriptor[] pds = info.getPropertyDescriptors();
- assertEquals(1, pds.length);
- assertEquals("childText", pds[0].getName());
- }
-
- public void testGetBeanInfo_NPE() throws IntrospectionException {
- // Regression for HARMONY-257
- try {
- Introspector.getBeanInfo((java.lang.Class) null);
- fail("getBeanInfo should throw NullPointerException");
- } catch (NullPointerException e) {
- }
-
- try {
- Introspector.getBeanInfo((java.lang.Class) null,
- (java.lang.Class) null);
- fail("getBeanInfo should throw NullPointerException");
- } catch (NullPointerException e) {
- }
-
- try {
- Introspector.getBeanInfo((java.lang.Class) null, 0);
- fail("getBeanInfo should throw NullPointerException");
- } catch (NullPointerException e) {
- }
- }
-
- /**
- * The test checks the getPropertyDescriptors method for
- * IGNORE_IMMEDIATE_BEANINFO flag
- *
- * @throws IntrospectionException
- */
- public void testIgnoreImmediateBeanInfo() throws IntrospectionException {
- BeanInfo info = Introspector.getBeanInfo(ChildBean.class,
- Introspector.IGNORE_IMMEDIATE_BEANINFO);
- PropertyDescriptor[] pds = info.getPropertyDescriptors();
- assertEquals(1, pds.length);
- assertEquals("parentText", pds[0].getName());
- }
-
- /**
- * The test checks the getPropertyDescriptors method for IGNORE_ALL_BEANINFO
- * flag
- *
- * @throws IntrospectionException
- */
- public void testIgnoreAllBeanInfo() throws IntrospectionException {
- BeanInfo info = Introspector.getBeanInfo(ChildBean.class,
- Introspector.IGNORE_ALL_BEANINFO);
- PropertyDescriptor[] pds = info.getPropertyDescriptors();
- assertEquals(2, pds.length);
- assertEquals("class", pds[0].getName());
- assertEquals("text", pds[1].getName());
- }
-
- /**
- * The test checks the getPropertyDescriptors method
- *
- * @throws IntrospectionException
- */
- public void testAdditionalBeanInfo() throws IntrospectionException {
- BeanInfo info = Introspector.getBeanInfo(StandardBean2.class);
- assertNull(info.getAdditionalBeanInfo());
- PropertyDescriptor[] pds = info.getPropertyDescriptors();
- assertEquals(2, pds.length);
- assertEquals("class", pds[0].getName());
- }
-
- /**
- * The test checks the getPropertyDescriptors for stop class prune
- *
- * @throws IntrospectionException
- */
- public void testStopClass() throws IntrospectionException {
- BeanInfo info = Introspector.getBeanInfo(ChildBean.class,
- GrannyBean.class);
- PropertyDescriptor[] pds = info.getPropertyDescriptors();
- assertEquals(1, pds.length);
- assertEquals("childText", pds[0].getName());
- }
-
- /*
- * Common
- */
- public void testDecapitalize() {
- assertEquals("fooBah", Introspector.decapitalize("FooBah"));
- assertEquals("fooBah", Introspector.decapitalize("fooBah"));
- assertEquals("x", Introspector.decapitalize("X"));
- assertNull(Introspector.decapitalize(null));
- assertEquals("", Introspector.decapitalize(""));
- assertEquals("a1", Introspector.decapitalize("A1"));
- }
-
- public void testFlushCaches() throws IntrospectionException {
- BeanInfo info = Introspector.getBeanInfo(MockJavaBean.class);
- BeanDescriptor beanDesc = new BeanDescriptor(MockJavaBean.class);
- assertEquals(beanDesc.getName(), info.getBeanDescriptor().getName());
- assertEquals(beanDesc.isExpert(), info.getBeanDescriptor().isExpert());
-
- Introspector.flushCaches();
- BeanInfo cacheInfo = Introspector.getBeanInfo(MockJavaBean.class);
- assertNotSame(info, cacheInfo);
- beanDesc = new BeanDescriptor(MockJavaBean.class);
- assertEquals(beanDesc.getName(), info.getBeanDescriptor().getName());
- assertEquals(beanDesc.isExpert(), info.getBeanDescriptor().isExpert());
- }
-
- public void testFlushFromCaches() throws IntrospectionException {
- BeanInfo info = Introspector.getBeanInfo(MockFooSubSub.class);
- BeanInfo info2 = Introspector.getBeanInfo(MockFooSubSub.class);
- assertSame(info, info2);
- Introspector.flushFromCaches(MockFooSubSub.class);
- BeanInfo info3 = Introspector.getBeanInfo(MockFooSubSub.class);
- assertNotSame(info, info3);
- }
-
- public void testFlushFromCaches_Null() throws IntrospectionException {
- BeanInfo info = Introspector.getBeanInfo(MockJavaBean.class);
- BeanDescriptor beanDesc = new BeanDescriptor(MockJavaBean.class);
- assertEquals(beanDesc.getName(), info.getBeanDescriptor().getName());
- assertEquals(beanDesc.isExpert(), info.getBeanDescriptor().isExpert());
- try {
- Introspector.flushFromCaches(null);
- fail("Should throw NullPointerException.");
- } catch (NullPointerException e) {
- }
- }
-
- /*
- * Class under test for BeanInfo getBeanInfo(Class) No XXXXBeanInfo + test
- * cache info
- */
- public void testGetBeanInfoClass_no_BeanInfo()
- throws IntrospectionException {
- Class<FakeFox> beanClass = FakeFox.class;
- BeanInfo info = Introspector.getBeanInfo(beanClass);
- assertNull(info.getAdditionalBeanInfo());
- BeanDescriptor beanDesc = info.getBeanDescriptor();
- assertEquals("FakeFox", beanDesc.getName());
- assertEquals(0, info.getEventSetDescriptors().length);
- assertEquals(-1, info.getDefaultEventIndex());
- assertEquals(-1, info.getDefaultPropertyIndex());
-
- MethodDescriptor[] methodDesc = info.getMethodDescriptors();
- Method[] methods = beanClass.getMethods();
- assertEquals(methods.length, methodDesc.length);
- ArrayList<Method> methodList = new ArrayList<Method>();
-
- for (Method element : methods) {
- methodList.add(element);
- }
-
- for (MethodDescriptor element : methodDesc) {
- assertTrue(methodList.contains(element.getMethod()));
- }
-
- PropertyDescriptor[] propertyDesc = info.getPropertyDescriptors();
- assertEquals(1, propertyDesc.length);
- for (PropertyDescriptor element : propertyDesc) {
- if (element.getName().equals("class")) {
- assertNull(element.getWriteMethod());
- assertNotNull(element.getReadMethod());
- }
- }
-
- BeanInfo cacheInfo = Introspector.getBeanInfo(FakeFox.class);
- assertSame(info, cacheInfo);
- }
-
- /*
- * There is a BeanInfo class + test cache info
- */
- public void testGetBeanInfoClass_HaveBeanInfo()
- throws IntrospectionException {
- Class<FakeFox01> beanClass = FakeFox01.class;
- BeanInfo info = Introspector.getBeanInfo(beanClass);
- // printInfo(info);
-
- BeanInfo beanInfo = new FakeFox01BeanInfo();
-
- assertBeanInfoEquals(beanInfo, info);
- assertEquals(-1, info.getDefaultEventIndex());
- assertEquals(0, info.getDefaultPropertyIndex());
-
- BeanInfo cacheInfo = Introspector.getBeanInfo(beanClass);
- assertSame(info, cacheInfo);
- }
-
- public void testGetBeanInfoClass_ClassNull() throws IntrospectionException {
- try {
- Introspector.getBeanInfo(null);
- fail("Should throw NullPointerException.");
- } catch (NullPointerException e) {
- }
- }
-
- /*
- * Class under test for BeanInfo getBeanInfo(Class, Class)
- */
- public void testGetBeanInfoClassClass_Property()
- throws IntrospectionException {
- BeanInfo info = Introspector.getBeanInfo(MockFoo.class,
- MockFooStop.class);
- PropertyDescriptor[] pds = info.getPropertyDescriptors();
-
- assertEquals(2, pds.length);
- assertTrue(contains("name", String.class, pds));
- assertTrue(contains("complexLabel", MockFooLabel.class, pds));
- }
-
- public void testGetBeanInfoClassClass_Method()
- throws IntrospectionException {
- BeanInfo info = Introspector.getBeanInfo(MockFoo.class,
- MockFooStop.class);
- MethodDescriptor[] mds = info.getMethodDescriptors();
-
- assertEquals(4, mds.length);
- assertTrue(contains("getName", mds));
- assertTrue(contains("setName", mds));
- assertTrue(contains("getComplexLabel", mds));
- assertTrue(contains("setComplexLabel", mds));
- try {
- Introspector.getBeanInfo(MockFoo.class, Serializable.class);
- fail("Shoule throw exception, stopclass must be superclass of given bean");
- } catch (IntrospectionException e) {
- }
- }
-
- /*
- * BeanClass provide bean info about itself
- */
- public static class MockBeanInfo4BeanClassSelf implements BeanInfo {
-
- public void setValue(String v) throws Exception {
- }
-
- public int getValue() {
- return 0;
- }
-
- public BeanDescriptor getBeanDescriptor() {
- return null;
- }
-
- public EventSetDescriptor[] getEventSetDescriptors() {
- return new EventSetDescriptor[0];
- }
-
- public int getDefaultEventIndex() {
- return -1;
- }
-
- public int getDefaultPropertyIndex() {
- return -1;
- }
-
- public PropertyDescriptor[] getPropertyDescriptors() {
- return new PropertyDescriptor[0];
- }
-
- public MethodDescriptor[] getMethodDescriptors() {
- return new MethodDescriptor[0];
- }
-
- public BeanInfo[] getAdditionalBeanInfo() {
- return null;
- }
-
- public Image getIcon(int iconKind) {
- return null;
- }
- }
-
- public void test_BeanInfo_Self() throws Exception {
- BeanInfo info = Introspector
- .getBeanInfo(MockBeanInfo4BeanClassSelf.class);
- assertEquals(0, info.getMethodDescriptors().length);
- assertEquals(0, info.getPropertyDescriptors().length);
- assertEquals(0, info.getEventSetDescriptors().length);
- }
-
- /*
- * Introspect static methods
- */
- public void testGetBeanInfo_StaticMethods() throws Exception {
- BeanInfo beanInfo = Introspector.getBeanInfo(StaticClazz.class);
- PropertyDescriptor[] propertyDescriptors = beanInfo
- .getPropertyDescriptors();
- assertEquals(1, propertyDescriptors.length);
- assertTrue(contains("class", Class.class, propertyDescriptors));
- MethodDescriptor[] methodDescriptors = beanInfo.getMethodDescriptors();
- assertTrue(contains("getStaticMethod", methodDescriptors));
- assertTrue(contains("setStaticMethod", methodDescriptors));
-
- beanInfo = Introspector.getBeanInfo(StaticClazzWithProperty.class);
- propertyDescriptors = beanInfo.getPropertyDescriptors();
- assertEquals(1, propertyDescriptors.length);
- methodDescriptors = beanInfo.getMethodDescriptors();
- assertTrue(contains("getStaticName", methodDescriptors));
- assertTrue(contains("setStaticName", methodDescriptors));
- }
-
- public void testMockIncompatibleGetterAndIndexedGetterBean() throws Exception {
- Class beanClass = MockIncompatibleGetterAndIndexedGetterBean.class;
- BeanInfo beanInfo = Introspector.getBeanInfo(beanClass);
- PropertyDescriptor pd = null;
- PropertyDescriptor[] pds = beanInfo.getPropertyDescriptors();
- for (int i = 0; i < pds.length; i++) {
- pd = pds[i];
- if (pd.getName().equals("data")) {
- break;
- }
- }
- assertNotNull(pd);
- assertTrue(pd instanceof IndexedPropertyDescriptor);
- IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd;
- assertNull(ipd.getReadMethod());
- assertNull(ipd.getWriteMethod());
- Method indexedReadMethod = beanClass.getMethod("getData",
- new Class[] { int.class });
- Method indexedWriteMethod = beanClass.getMethod("setData", new Class[] {
- int.class, int.class });
- assertEquals(indexedReadMethod, ipd.getIndexedReadMethod());
- assertEquals(indexedWriteMethod, ipd.getIndexedWriteMethod());
- }
-
- public void testMockIncompatibleSetterAndIndexedSetterBean() throws Exception {
- Class beanClass = MockIncompatibleSetterAndIndexedSetterBean.class;
- BeanInfo beanInfo = Introspector.getBeanInfo(beanClass);
- PropertyDescriptor pd = null;
- PropertyDescriptor[] pds = beanInfo.getPropertyDescriptors();
- for (int i = 0; i < pds.length; i++) {
- pd = pds[i];
- if (pd.getName().equals("data")) {
- break;
- }
- }
- assertNotNull(pd);
- assertTrue(pd instanceof IndexedPropertyDescriptor);
- IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd;
- assertNull(ipd.getReadMethod());
- assertNull(ipd.getWriteMethod());
- Method indexedReadMethod = beanClass.getMethod("getData",
- new Class[] { int.class });
- Method indexedWriteMethod = beanClass.getMethod("setData", new Class[] {
- int.class, int.class });
- assertEquals(indexedReadMethod, ipd.getIndexedReadMethod());
- assertEquals(indexedWriteMethod, ipd.getIndexedWriteMethod());
- }
-
- public void testMockIncompatibleAllSetterAndGetterBean() throws Exception {
- Class beanClass = MockIncompatibleAllSetterAndGetterBean.class;
- BeanInfo beanInfo = Introspector.getBeanInfo(beanClass);
- PropertyDescriptor pd = null;
- PropertyDescriptor[] pds = beanInfo.getPropertyDescriptors();
- for (int i = 0; i < pds.length; i++) {
- pd = pds[i];
- if (pd.getName().equals("data")) {
- break;
- }
- }
- assertNotNull(pd);
- assertTrue(pd instanceof IndexedPropertyDescriptor);
- IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd;
- assertNull(ipd.getReadMethod());
- assertNull(ipd.getWriteMethod());
- Method indexedReadMethod = beanClass.getMethod("getData",
- new Class[] { int.class });
- Method indexedWriteMethod = beanClass.getMethod("setData", new Class[] {
- int.class, int.class });
- assertEquals(indexedReadMethod, ipd.getIndexedReadMethod());
- assertEquals(indexedWriteMethod, ipd.getIndexedWriteMethod());
- }
-
- public class MockIncompatibleGetterAndIndexedGetterBean {
- private int[] datas;
-
- public int getData() {
- return datas[0];
- }
-
- public int getData(int index) {
- return datas[index];
- }
-
- public void setData(int index, int data) {
- this.datas[index] = data;
- }
- }
-
- public class MockIncompatibleSetterAndIndexedSetterBean {
-
- private int[] datas;
-
- public int getData(int index){
- return datas[index];
- }
-
- public void setData(int index, int data) {
- this.datas[index] = data;
- }
-
- public void setData(int data){
- this.datas[0] = data;
- }
-
- }
-
- public class MockIncompatibleAllSetterAndGetterBean {
-
- private int[] datas;
-
- public int getData(){
- return datas[0];
- }
-
- public int getData(int index){
- return datas[index];
- }
-
- public void setData(int index, int data) {
- this.datas[index] = data;
- }
-
- public void setData(int data){
- this.datas[0] = data;
- }
-
- public void setData(){
- this.datas[0] = 0;
- }
-
- }
-
- public static class StaticClazz {
-
- /*
- * public static get method
- */
- public static String getStaticMethod() {
- return "static class";
- }
-
- /*
- * public static set method
- */
- public static void setStaticMethod(String content) {
- // do nothing
- }
-
- }
-
- public static class StaticClazzWithProperty {
-
- private static String staticName = "Static Clazz";
-
- /*
- * public static get method
- */
- public static String getStaticName() {
- return staticName;
- }
-
- /*
- * public static set method
- */
- public static void setStaticName(String name) {
- staticName = name;
- }
- }
-
- public void testGetBeanInfoClassClass_StopNull()
- throws IntrospectionException {
- BeanInfo info = Introspector.getBeanInfo(MockFoo.class);// , null);
- PropertyDescriptor[] pds = info.getPropertyDescriptors();
- boolean name = false;
- boolean label = false;
- for (PropertyDescriptor element : pds) {
- if (element.getName().equals("name")) {
- name = true;
- }
- if (element.getName().equals("label")) {
- label = true;
- }
- }
-
- assertTrue(name);
- assertTrue(label);
- }
-
- public void testGetBeanInfoClassClass_ClassNull()
- throws IntrospectionException {
- try {
- Introspector.getBeanInfo(null, MockFooStop.class);
- fail("Should throw NullPointerException.");
- } catch (NullPointerException e) {
- }
- }
-
- /*
- * StopClass is not a supper class of the bean.
- */
- public void testGetBeanInfoClassClass_ClassInvalid()
- throws IntrospectionException {
- try {
- Introspector.getBeanInfo(MockButton.class, MockFooStop.class);
- fail("Should throw IntrospectionException.");
- } catch (IntrospectionException e) {
- }
- }
-
- /*
- * Class under test for BeanInfo getBeanInfo(Class, int)
- */
- public void testGetBeanInfoClassint_UseAll_Property()
- throws IntrospectionException {
- BeanInfo info = Introspector.getBeanInfo(MockFooSubSub.class,
- Introspector.USE_ALL_BEANINFO);
- PropertyDescriptor[] pds = info.getPropertyDescriptors();
- int parentProperty = 0;
- for (PropertyDescriptor element : pds) {
- String name = element.getName();
- if (name.startsWith("text")) {
- parentProperty++;
- assertEquals("text.MockFooSubBeanInfo", name);
- }
- }
- assertEquals(1, parentProperty);
- }
-
- public void testGetBeanInfoClassint_UseAll_Method()
- throws IntrospectionException {
- BeanInfo info = Introspector.getBeanInfo(MockFooSubSub.class,
- Introspector.USE_ALL_BEANINFO);
- MethodDescriptor[] mds = info.getMethodDescriptors();
- int parentMethodGet = 0;
- int parentMethodSet = 0;
- for (MethodDescriptor element : mds) {
- String name = element.getName();
- if (name.startsWith("getText")) {
- parentMethodGet++;
- assertEquals("getText.MockFooSubBeanInfo", name);
- }
- if (name.startsWith("setText")) {
- parentMethodSet++;
- assertEquals("setText.MockFooSubBeanInfo", name);
- }
- }
-
- assertEquals(1, parentMethodGet);
- assertEquals(1, parentMethodSet);
- }
-
- public void testGetBeanInfoClassint_UseAll_Event()
- throws IntrospectionException {
- BeanInfo info = Introspector.getBeanInfo(MockFooSubSub.class,
- Introspector.USE_ALL_BEANINFO);
- EventSetDescriptor[] esds = info.getEventSetDescriptors();
- assertEquals(1, esds.length);
- for (EventSetDescriptor element : esds) {
- String name = element.getName();
- assertEquals("mockPropertyChange.MockFooSubBeanInfo", name);
- }
- }
-
- /*
- * FLAG=IGNORE_IMMEDIATE;
- */
- public void testGetBeanInfoClassint_IGNORE_IMMEDIATE_Property()
- throws IntrospectionException {
- BeanInfo info = Introspector.getBeanInfo(MockFooSub.class,
- Introspector.IGNORE_IMMEDIATE_BEANINFO);
- PropertyDescriptor[] pds = info.getPropertyDescriptors();
- int fromParent = 0;
- for (PropertyDescriptor element : pds) {
- String name = element.getName();
- if (name.startsWith("childName")) {
- fromParent++;
- assertEquals("childName.MockFooChildBeanInfo", name);
- }
- }
- assertEquals(1, fromParent);
- }
-
- /*
- * FLAG=IGNORE_IMMEDIATE;
- */
- public void testGetBeanInfoClassint_IGNORE_IMMEDIATE_Method()
- throws IntrospectionException {
- BeanInfo info = Introspector.getBeanInfo(MockFooSub.class,
- Introspector.IGNORE_IMMEDIATE_BEANINFO);
- MethodDescriptor[] mds = info.getMethodDescriptors();
- int parentMethodGet = 0;
- int parentMethodSet = 0;
- for (MethodDescriptor element : mds) {
- String name = element.getName();
- if (name.startsWith("getChildName")) {
- parentMethodGet++;
- assertEquals("getChildName.MockFooChildBeanInfo", name);
- }
- if (name.startsWith("setChildName")) {
- parentMethodSet++;
- assertEquals("setChildName.MockFooChildBeanInfo", name);
- }
- }
-
- assertEquals(1, parentMethodGet);
- assertEquals(1, parentMethodSet);
- }
-
- /*
- * FLAG=IGNORE_IMMEDIATE;
- */
- public void testGetBeanInfoClassint_IGNORE_IMMEDIATE_Event()
- throws IntrospectionException {
- BeanInfo info = Introspector.getBeanInfo(MockFooSub.class,
- Introspector.IGNORE_IMMEDIATE_BEANINFO);
- EventSetDescriptor[] esds = info.getEventSetDescriptors();
-
- assertEquals(2, esds.length);
- assertTrue(contains("mockPropertyChange", esds));
- assertTrue(contains("mockPropertyChange.MockFooChildBeanInfo", esds));
- }
-
- /*
- * FLAG=IGNORE_ALL_BEANINFO;
- */
- public void testGetBeanInfoClassint_IGNORE_ALL_Property()
- throws IntrospectionException {
- BeanInfo info = Introspector.getBeanInfo(MockFooSub.class,
- Introspector.IGNORE_ALL_BEANINFO);
- PropertyDescriptor[] pds = info.getPropertyDescriptors();
- int text = 0;
- for (PropertyDescriptor element : pds) {
- String name = element.getName();
- if (name.startsWith("text")) {
- text++;
- assertEquals("text", name);
- }
- }
- assertEquals(1, text);
- }
-
- /*
- * FLAG=IGNORE_ALL_BEANINFO;
- */
- public void testGetBeanInfoClassint_IGNORE_ALL_Method()
- throws IntrospectionException {
- BeanInfo info = Introspector.getBeanInfo(MockFooSub.class,
- Introspector.IGNORE_ALL_BEANINFO);
- MethodDescriptor[] mds = info.getMethodDescriptors();
- int getMethod = 0;
- int setMethod = 0;
- for (MethodDescriptor element : mds) {
- String name = element.getName();
- if (name.startsWith("getText")) {
- getMethod++;
- assertEquals("getText", name);
- }
- if (name.startsWith("setText")) {
- setMethod++;
- assertEquals("setText", name);
- }
- }
-
- assertEquals(1, getMethod);
- assertEquals(1, setMethod);
- }
-
- /*
- * FLAG=IGNORE_ALL_BEANINFO;
- */
- public void testGetBeanInfoClassint_IGNORE_ALL_Event()
- throws IntrospectionException {
- BeanInfo info = Introspector.getBeanInfo(MockFooSub.class,
- Introspector.IGNORE_ALL_BEANINFO);
- EventSetDescriptor[] esds = info.getEventSetDescriptors();
-
- assertEquals(1, esds.length);
- assertTrue(contains("mockPropertyChange", esds));
- }
-
- /*
- * FLAG invalid;
- */
- public void testGetBeanInfoClassint_FLAG_Invalid()
- throws IntrospectionException {
- BeanInfo info = Introspector.getBeanInfo(MockFooSub.class, -1);
- PropertyDescriptor[] pds = info.getPropertyDescriptors();
-
- Introspector.getBeanInfo(MockFooSub.class,
- Introspector.IGNORE_ALL_BEANINFO);
- PropertyDescriptor[] pds2 = info.getPropertyDescriptors();
- assertEquals(pds.length, pds2.length);
- for (int i = 0; i < pds.length; i++) {
- assertEquals(pds[i], pds2[i]);
- }
- }
-
- /*
- * @test Introspector.getBeanInfo
- * @test StandardBeanInfo.mergeProps
- */
- public void testGetBeanInfo_StandardBeanInfo_mergeProps() throws Exception {
- class MockParent {
- public void setValue(int v) {
- // do nothing
- }
-
- public void setValue(int v, String s) {
- // do nothing
- }
- }
-
- class MockChild extends MockParent {
- public void setValue(int v) {
- // do nothing
- }
- }
-
- BeanInfo beanInfo = Introspector.getBeanInfo(MockChild.class);
- PropertyDescriptor[] pds = beanInfo.getPropertyDescriptors();
- PropertyDescriptor pd = null;
- for(int i = 0; i < pds.length; i++){
- if("value".equals(pds[i].getName())){
- pd = pds[i];
- }
- }
- assertNotNull(pd);
- assertEquals(Integer.TYPE, pd.getPropertyType());
- }
-
- public void testSetBeanInfoSearchPath_null() throws IntrospectionException{
- String[] oldPath = Introspector.getBeanInfoSearchPath();
- try{
- Introspector.setBeanInfoSearchPath(null);
- try{
- Introspector.getBeanInfoSearchPath();
- fail("should throw NPE");
- }catch(NullPointerException e){
- }
- String[] newPath = new String[]{"mock", null, ""};
- Introspector.setBeanInfoSearchPath(newPath);
- Introspector.getBeanInfo(this.getClass());
- }finally{
- Introspector.setBeanInfoSearchPath(oldPath);
- }
- }
-
- public void testGetBeanInfoSearchPath() {
- String[] path = Introspector.getBeanInfoSearchPath();
- assertEquals(1, path.length);
- assertTrue(path[0].endsWith("beans.infos"));
- }
-
- public void testGetBeanInfoSearchPath_Default()
- throws IntrospectionException, ClassNotFoundException {
- BeanInfo info = Introspector.getBeanInfo(MockFooButton.class);
- PropertyDescriptor[] pds = info.getPropertyDescriptors();
- BeanDescriptor beanDesc;
-
- assertEquals(2, pds.length);
- assertEquals("class", pds[0].getName());
-
- beanDesc = info.getBeanDescriptor();
- assertEquals("MockFooButton", beanDesc.getName());
- }
-
- public void testSetBeanInfoSearchPath() throws IntrospectionException {
- String[] oldPath = Introspector.getBeanInfoSearchPath();
- String[] newPath = new String[] { "org.apache.harmony.beans.tests.java.beans", };
- Introspector.setBeanInfoSearchPath(newPath);
-
- BeanInfo info = Introspector.getBeanInfo(MockFooLabel.class);
- PropertyDescriptor[] pds = info.getPropertyDescriptors();
- for (PropertyDescriptor element : pds) {
- String name = element.getName();
- assertEquals("text.MockFooLabelBeanInfo", name);
- }
-
- String[] path = Introspector.getBeanInfoSearchPath();
- for (int i = 0; i < newPath.length; i++) {
- assertEquals(newPath[i], path[i]);
- }
- Introspector.setBeanInfoSearchPath(oldPath);
- }
-
- /*
- * Sub is PropertyDescriptor, Super is null
- */
- public void testIntrospection_1() throws IntrospectionException {
- Class<FakeFox101> beanClass = FakeFox101.class;
- BeanInfo info = Introspector.getBeanInfo(beanClass);
-
- assertEquals(0, info.getEventSetDescriptors().length);
- assertEquals(11, info.getMethodDescriptors().length);
-
- PropertyDescriptor[] propertyDesc = info.getPropertyDescriptors();
- assertEquals(2, propertyDesc.length);
-
- for (PropertyDescriptor element : propertyDesc) {
- if (element.getName().equals("class")) {
- assertNull(element.getWriteMethod());
- assertNotNull(element.getReadMethod());
- } else {
- assertEquals("fox101", element.getName());
- assertEquals("setFox101", element.getWriteMethod()
- .getName());
- assertEquals("getFox101", element.getReadMethod()
- .getName());
- }
- }
- }
-
- /*
- * Sub is PropertyDescriptor, Super is PropertyDescriptor get in sub, set in
- * super
- */
- public void testIntrospection_2() throws IntrospectionException {
- Class<FakeFox201> beanClass = FakeFox201.class;
- BeanInfo info = Introspector.getBeanInfo(beanClass);
-
- assertEquals(0, info.getEventSetDescriptors().length);
- assertEquals(11, info.getMethodDescriptors().length);
-
- PropertyDescriptor[] propertyDesc = info.getPropertyDescriptors();
- assertEquals(2, propertyDesc.length);
-
- for (PropertyDescriptor element : propertyDesc) {
- if (element.getName().equals("class")) {
- assertNull(element.getWriteMethod());
- assertNotNull(element.getReadMethod());
- } else {
- assertEquals("fox201", element.getName());
- assertEquals(String.class.getName(), element
- .getPropertyType().getName());
- assertNotNull(element.getWriteMethod().getName());
- assertNotNull(element.getReadMethod().getName());
- }
- }
- }
-
- /*
- * Sub is PropertyDescriptor, Super is PropertyDescriptor Sub get ->
- * Integer, super set->String
- */
- public void testIntrospection_3() throws IntrospectionException {
- Class<FakeFox202> beanClass = FakeFox202.class;
- BeanInfo info = Introspector.getBeanInfo(beanClass);
-
- assertEquals(0, info.getEventSetDescriptors().length);
- assertEquals(11, info.getMethodDescriptors().length);
-
- PropertyDescriptor[] propertyDesc = info.getPropertyDescriptors();
- assertEquals(2, propertyDesc.length);
-
- for (PropertyDescriptor element : propertyDesc) {
- if (element.getName().equals("class")) {
- assertNull(element.getWriteMethod());
- assertNotNull(element.getReadMethod());
- } else {
- assertEquals("fox201", element.getName());
- assertEquals(Integer.class.getName(), element
- .getPropertyType().getName());
- assertNull(element.getWriteMethod());
- assertNotNull(element.getReadMethod());
- }
- }
- }
-
- /*
- * Sub is PropertyDescriptor, Super is PropertyDescriptor Sub set->String,
- * super get -> Integer
- */
- public void testIntrospection_4() throws IntrospectionException {
- // XXX will fail on RI, see HARMONY-2289
- Class<FakeFox301> beanClass = FakeFox301.class;
- BeanInfo info = Introspector.getBeanInfo(beanClass);
-
- assertEquals(0, info.getEventSetDescriptors().length);
- assertEquals(11, info.getMethodDescriptors().length);
-
- PropertyDescriptor[] propertyDesc = info.getPropertyDescriptors();
- assertEquals(2, propertyDesc.length);
-
- for (PropertyDescriptor element : propertyDesc) {
- if (element.getName().equals("class")) {
- assertNull(element.getWriteMethod());
- assertNotNull(element.getReadMethod());
- } else {
- assertEquals("fox301", element.getName());
- assertEquals(Integer.class.getName(), element
- .getPropertyType().getName());
- assertNull(element.getWriteMethod());
- assertNotNull(element.getReadMethod());
- }
- }
- }
-
- /*
- * Sub PropertyDescriptor, super IndexedPropertyDescriptor
- */
- public void testIntrospection_5() throws IntrospectionException {
- Class<FakeFox401> beanClass = FakeFox401.class;
- BeanInfo info = Introspector.getBeanInfo(beanClass);
- PropertyDescriptor[] pds;
-
-
- assertEquals(0, info.getEventSetDescriptors().length);
- assertEquals(13, info.getMethodDescriptors().length);
-
- pds = info.getPropertyDescriptors();
- assertEquals(2, pds.length);
-
- for (PropertyDescriptor element : pds) {
- if (element.getName().equals("class")) {
- assertNull(element.getWriteMethod());
- assertNotNull(element.getReadMethod());
- } else {
- IndexedPropertyDescriptor indexedDesc =
- (IndexedPropertyDescriptor) element;
-
- assertEquals("fox401", element.getName());
- assertEquals(String[].class.getName(), element
- .getPropertyType().getName());
- assertEquals(String.class.getName(), indexedDesc
- .getIndexedPropertyType().getName());
- assertNotNull(element.getWriteMethod());
- assertNotNull(element.getReadMethod());
- assertNotNull(indexedDesc.getIndexedReadMethod());
- assertNotNull(indexedDesc.getIndexedWriteMethod());
- }
- }
- }
-
- /*
- * Sub PropertyDescriptor, super IndexedPropertyDescriptor Get/Set is
- * mismatch
- */
- public void testIntrospection_6() throws IntrospectionException {
- Class<FakeFox402> beanClass = FakeFox402.class;
- BeanInfo info = Introspector.getBeanInfo(beanClass);
- assertEquals(0, info.getEventSetDescriptors().length);
- assertEquals(13, info.getMethodDescriptors().length);
- PropertyDescriptor[] propertyDesc = info.getPropertyDescriptors();
- assertEquals(2, propertyDesc.length);
-
- for (PropertyDescriptor element : propertyDesc) {
- if (element.getName().equals("class")) {
- assertNull(element.getWriteMethod());
- assertNotNull(element.getReadMethod());
- } else {
- assertEquals("fox401", element.getName());
- assertEquals(Integer[].class.getName(), element
- .getPropertyType().getName());
- assertNull(element.getWriteMethod());
- assertNotNull(element.getReadMethod());
- }
- }
- }
-
- /*
- * Sub is IndexedPropertyDescriptor, Super is PropertyDescriptor sub set,
- * indexed get. Super get
- */
- public void testIntrospection_7() throws IntrospectionException {
- Class<FakeFox501> beanClass = FakeFox501.class;
- BeanInfo info = Introspector.getBeanInfo(beanClass);
- PropertyDescriptor[] propertyDesc;
-
- assertEquals(0, info.getEventSetDescriptors().length);
- assertEquals(12, info.getMethodDescriptors().length);
-
- propertyDesc = info.getPropertyDescriptors();
- assertEquals(2, propertyDesc.length);
-
- for (PropertyDescriptor element : propertyDesc) {
- if (element.getName().equals("class")) {
- assertNull(element.getWriteMethod());
- assertNotNull(element.getReadMethod());
- } else {
- IndexedPropertyDescriptor indexedDesc =
- (IndexedPropertyDescriptor) element;
-
- assertEquals("fox501", element.getName());
- assertEquals(String[].class.getName(), element
- .getPropertyType().getName());
- assertNotNull(element.getWriteMethod());
- assertNotNull(element.getReadMethod());
- assertNotNull(indexedDesc.getIndexedReadMethod());
- assertNull(indexedDesc.getIndexedWriteMethod());
- assertEquals(String.class.getName(), indexedDesc
- .getIndexedPropertyType().getName());
- }
- }
- }
-
- /*
- * Sub is IndexedPropertyDescriptor, Super is PropertyDescriptor sub indexed
- * set. Super get
- */
- public void testIntrospection_8() throws IntrospectionException {
- Class<FakeFox502> beanClass = FakeFox502.class;
- BeanInfo info = Introspector.getBeanInfo(beanClass);
- assertEquals(0, info.getEventSetDescriptors().length);
- assertEquals(11, info.getMethodDescriptors().length);
-
- PropertyDescriptor[] propertyDesc = info.getPropertyDescriptors();
- assertEquals(2, propertyDesc.length);
-
- for (PropertyDescriptor element : propertyDesc) {
- if (element.getName().equals("class")) {
- assertNull(element.getWriteMethod());
- assertNotNull(element.getReadMethod());
- } else {
- IndexedPropertyDescriptor indexedDesc = (IndexedPropertyDescriptor) element;
- assertEquals("fox501", element.getName());
- assertEquals(String[].class.getName(), element
- .getPropertyType().getName());
- assertNull(element.getWriteMethod());
- assertNotNull(element.getReadMethod());
- assertNull(indexedDesc.getIndexedReadMethod());
- assertNotNull(indexedDesc.getIndexedWriteMethod());
- assertEquals(String.class.getName(), indexedDesc
- .getIndexedPropertyType().getName());
- }
- }
- }
-
- /*
- * Sub is IndexedPropertyDescriptor, Super is PropertyDescriptor sub indexed
- * set. Super get. Type is different
- */
- public void testIntrospection_9() throws IntrospectionException {
- Class<FakeFox503> beanClass = FakeFox503.class;
- BeanInfo info = Introspector.getBeanInfo(beanClass);
- assertEquals(0, info.getEventSetDescriptors().length);
- assertEquals(11, info.getMethodDescriptors().length);
-
- PropertyDescriptor[] propertyDesc = info.getPropertyDescriptors();
- assertEquals(2, propertyDesc.length);
-
- for (PropertyDescriptor element : propertyDesc) {
- if (element.getName().equals("class")) {
- assertNull(element.getWriteMethod());
- assertNotNull(element.getReadMethod());
- } else {
- IndexedPropertyDescriptor indexedDesc = (IndexedPropertyDescriptor) element;
- assertEquals("fox501", element.getName());
- assertNull(element.getPropertyType());
- assertNull(element.getWriteMethod());
- assertNull(element.getReadMethod());
- assertNull(indexedDesc.getIndexedReadMethod());
- assertNotNull(indexedDesc.getIndexedWriteMethod());
- assertEquals(Integer.class.getName(), indexedDesc
- .getIndexedPropertyType().getName());
- }
- }
- }
-
- /*
- * Test introspect events, add/remove
- */
- public void testIntrospection_10() throws IntrospectionException {
- Class<FakeFox601> beanClass = FakeFox601.class;
- BeanInfo info = Introspector.getBeanInfo(beanClass);
- PropertyDescriptor[] propertyDesc;
- EventSetDescriptor eventDesc;
-
- assertEquals(1, info.getEventSetDescriptors().length);
- eventDesc = info.getEventSetDescriptors()[0];
- assertNotNull(eventDesc.getAddListenerMethod());
- assertNotNull(eventDesc.getRemoveListenerMethod());
- assertNull(eventDesc.getGetListenerMethod());
- assertEquals(1, eventDesc.getListenerMethods().length);
-
- assertEquals(11, info.getMethodDescriptors().length);
-
- propertyDesc = info.getPropertyDescriptors();
- assertEquals(1, propertyDesc.length);
-
- for (PropertyDescriptor element : propertyDesc) {
- if (element.getName().equals("class")) {
- assertNull(element.getWriteMethod());
- assertNotNull(element.getReadMethod());
- }
- }
- }
-
- /*
- * Test introspect events, add/remove/get
- */
- public void testIntrospection_11() throws IntrospectionException {
- Class<FakeFox602> beanClass = FakeFox602.class;
- BeanInfo info = Introspector.getBeanInfo(beanClass);
- EventSetDescriptor eventDesc;
- PropertyDescriptor[] propertyDesc;
-
- assertEquals(1, info.getEventSetDescriptors().length);
- eventDesc = info.getEventSetDescriptors()[0];
- assertFalse(eventDesc.isUnicast());
- assertNotNull(eventDesc.getAddListenerMethod());
- assertNotNull(eventDesc.getRemoveListenerMethod());
- assertNotNull(eventDesc.getGetListenerMethod());
- assertEquals(1, eventDesc.getListenerMethods().length);
-
- assertEquals(12, info.getMethodDescriptors().length);
-
- propertyDesc = info.getPropertyDescriptors();
- assertEquals(2, propertyDesc.length);
-
- for (PropertyDescriptor element : propertyDesc) {
- if (element.getName().equals("class")) {
- assertNull(element.getWriteMethod());
- assertNotNull(element.getReadMethod());
- }
- }
- }
-
- /*
- * Test introspect events, add
- */
- public void testIntrospection_12() throws IntrospectionException {
- Class<FakeFox603> beanClass = FakeFox603.class;
- BeanInfo info = Introspector.getBeanInfo(beanClass);
- assertEquals(0, info.getEventSetDescriptors().length);
-
- assertEquals(10, info.getMethodDescriptors().length);
-
- PropertyDescriptor[] propertyDesc = info.getPropertyDescriptors();
- assertEquals(1, propertyDesc.length);
-
- for (PropertyDescriptor element : propertyDesc) {
- if (element.getName().equals("class")) {
- assertNull(element.getWriteMethod());
- assertNotNull(element.getReadMethod());
- }
- }
- }
-
- /*
- * Test introspect events, add/remove Add throws TooManyListenersException
- */
- public void testIntrospection_13() throws IntrospectionException {
- Class<FakeFox604> beanClass = FakeFox604.class;
- BeanInfo info = Introspector.getBeanInfo(beanClass);
- assertEquals(1, info.getEventSetDescriptors().length);
- EventSetDescriptor eventDesc = info.getEventSetDescriptors()[0];
- assertTrue(eventDesc.isUnicast());
- assertNotNull(eventDesc.getAddListenerMethod());
- assertNotNull(eventDesc.getRemoveListenerMethod());
- assertNull(eventDesc.getGetListenerMethod());
- assertEquals(1, eventDesc.getListenerMethods().length);
-
- assertEquals(11, info.getMethodDescriptors().length);
-
- PropertyDescriptor[] propertyDesc = info.getPropertyDescriptors();
- assertEquals(1, propertyDesc.length);
-
- for (PropertyDescriptor element : propertyDesc) {
- if (element.getName().equals("class")) {
- assertNull(element.getWriteMethod());
- assertNotNull(element.getReadMethod());
- }
- }
- }
-
- // for test coverage
- public void testIntrospection_14() throws IntrospectionException {
- Class<FakeFox5001> beanClass = FakeFox5001.class;
- Introspector.getBeanInfo(beanClass);
-
- // Introspector in = new Introspector();
- }
-
- /*
- * Test Introspection with BeanInfo No immediate BeanInfo Have super
- * BeanInfo
- */
- public void testBeanInfo_1() throws IntrospectionException {
- Class<FakeFox011> beanClass = FakeFox011.class;
- BeanInfo info = Introspector.getBeanInfo(beanClass);
- assertNull(info.getAdditionalBeanInfo());
- BeanDescriptor beanDesc = info.getBeanDescriptor();
- assertEquals("FakeFox011", beanDesc.getName());
- assertEquals(0, info.getEventSetDescriptors().length);
- assertEquals(-1, info.getDefaultEventIndex());
- assertEquals(0, info.getDefaultPropertyIndex());
-
- MethodDescriptor[] methodDesc = info.getMethodDescriptors();
-
- assertEquals(4, methodDesc.length);
-
- PropertyDescriptor[] propertyDesc = info.getPropertyDescriptors();
- assertEquals(2, propertyDesc.length);
- for (PropertyDescriptor element : propertyDesc) {
- if (element.getName().equals("class")) {
- assertNull(element.getWriteMethod());
- assertNotNull(element.getReadMethod());
- }
- }
- }
-
- public void testBeanInfo_2() throws IntrospectionException {
- Class<FakeFox02> beanClass = FakeFox02.class;
- BeanInfo info = Introspector.getBeanInfo(beanClass);
- assertNull(info.getAdditionalBeanInfo());
- BeanDescriptor beanDesc = info.getBeanDescriptor();
- assertEquals("FakeFox02", beanDesc.getName());
- assertEquals(0, info.getEventSetDescriptors().length);
- assertEquals(-1, info.getDefaultEventIndex());
- assertEquals(-1, info.getDefaultPropertyIndex());
-
- MethodDescriptor[] methodDesc = info.getMethodDescriptors();
-
- assertEquals(11, methodDesc.length);
-
- PropertyDescriptor[] propertyDesc = info.getPropertyDescriptors();
- assertEquals(1, propertyDesc.length);
- for (PropertyDescriptor element : propertyDesc) {
- if (element.getName().equals("fox02")) {
- assertEquals("fox02.beaninfo", element.getDisplayName());
- }
- }
- }
-
- public void testPropertySort() throws IntrospectionException {
- Class<FakeFox70> beanClass = FakeFox70.class;
- BeanInfo info = Introspector.getBeanInfo(beanClass);
- PropertyDescriptor[] descs = info.getPropertyDescriptors();
- String[] names = { "a", "aaa", "bb", "bbb", "bc", "class", "ddd", "ff", };
- for (int i = 0; i < descs.length; i++) {
- assertEquals(names[i], descs[i].getName());
- }
- }
-
- public void testIntrospectProperties() throws IntrospectionException {
- Class<FakeFox80> beanClass = FakeFox80.class;
- BeanInfo info = Introspector.getBeanInfo(beanClass);
- assertEquals(2, info.getPropertyDescriptors().length);
- }
-
- public void testIntrospectProperties2() throws IntrospectionException {
- Class<FakeFox90> beanClass = FakeFox90.class;
- BeanInfo info = Introspector.getBeanInfo(beanClass);
- // printInfo(info);
- PropertyDescriptor[] pds = info.getPropertyDescriptors();
- assertEquals(2, pds.length);
- assertNull(pds[1].getReadMethod());
- }
-
- public void testExplicitBeanInfo() throws IntrospectionException {
- BeanInfo info = Introspector.getBeanInfo(MockFoo23.class);
-
- assertNull(info.getAdditionalBeanInfo());
- BeanDescriptor beanDesc = info.getBeanDescriptor();
- assertEquals("IntrospectorTest$MockFoo23", beanDesc.getName());
- assertEquals(0, info.getEventSetDescriptors().length);
- assertEquals(-1, info.getDefaultEventIndex());
- assertEquals(-1, info.getDefaultPropertyIndex());
-
- MethodDescriptor[] methodDesc = info.getMethodDescriptors();
-
- assertEquals(10, methodDesc.length);
-
- PropertyDescriptor[] propertyDesc = info.getPropertyDescriptors();
- assertEquals(1, propertyDesc.length);
- assertEquals("name.beanInfo", propertyDesc[0].getDisplayName());
- assertNotNull(propertyDesc[0].getReadMethod());
- assertNull(propertyDesc[0].getWriteMethod());
- }
-
- public void testExplicitBeanInfo2() throws IntrospectionException {
- BeanInfo info = Introspector.getBeanInfo(MockFox001.class);
-
- assertNull(info.getAdditionalBeanInfo());
- BeanDescriptor beanDesc = info.getBeanDescriptor();
- assertEquals("IntrospectorTest$MockFox001", beanDesc.getName());
- assertEquals(0, info.getEventSetDescriptors().length);
- assertEquals(-1, info.getDefaultEventIndex());
- assertEquals(-1, info.getDefaultPropertyIndex());
-
- MethodDescriptor[] methodDesc = info.getMethodDescriptors();
-
- assertEquals(1, methodDesc.length);
-
- PropertyDescriptor[] propertyDesc = info.getPropertyDescriptors();
- assertEquals(1, propertyDesc.length);
- assertEquals("name.beaninfo", propertyDesc[0].getDisplayName());
- assertNotNull(propertyDesc[0].getReadMethod());
- assertNull(propertyDesc[0].getWriteMethod());
- }
-
- public void testExplicitBeanInfo3() throws IntrospectionException {
- BeanInfo info = Introspector.getBeanInfo(MockFox011.class);
- // printInfo(info);
-
- assertNull(info.getAdditionalBeanInfo());
- BeanDescriptor beanDesc = info.getBeanDescriptor();
- assertEquals("IntrospectorTest$MockFox011", beanDesc.getName());
- assertEquals(0, info.getEventSetDescriptors().length);
- assertEquals(-1, info.getDefaultEventIndex());
- assertEquals(-1, info.getDefaultPropertyIndex());
-
- MethodDescriptor[] methodDesc = info.getMethodDescriptors();
-
- assertEquals(1, methodDesc.length);
-
- PropertyDescriptor[] propertyDesc = info.getPropertyDescriptors();
- assertEquals(3, propertyDesc.length);
-
- assertEquals("class", propertyDesc[0].getDisplayName());
- assertNotNull(propertyDesc[0].getReadMethod());
- assertNull(propertyDesc[0].getWriteMethod());
-
- assertEquals("label", propertyDesc[1].getDisplayName());
- assertNotNull(propertyDesc[1].getReadMethod());
- assertNull(propertyDesc[1].getWriteMethod());
-
- assertEquals("name", propertyDesc[2].getDisplayName());
- assertNotNull(propertyDesc[2].getReadMethod());
- assertNotNull(propertyDesc[2].getWriteMethod());
- }
-
- /*
- * If Bean1 has wrong getter method: public int getProp6(boolean i), then
- * Introspector.getBeanInfo(Bean1) throws java.beans.IntrospectionException.
- */
- public void testIntrospectorGetBeanInfo() throws IntrospectionException {
- Class<FakeFoxInfo> clazz = FakeFoxInfo.class;
- BeanInfo info = Introspector.getBeanInfo(clazz);
- // printInfo(info);
- PropertyDescriptor[] pds = info.getPropertyDescriptors();
- assertEquals("prop6", pds[1].getName());
- assertNull(pds[1].getReadMethod());
- 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);
- }
-
- public void testGetBeanInfoExplicitNull() throws Exception {
- Introspector.flushCaches();
- BeanInfo subinfo = Introspector.getBeanInfo(MockNullSubClass.class);
- assertNotNull(subinfo.getPropertyDescriptors());
- assertNotNull(subinfo.getEventSetDescriptors());
- assertNotNull(subinfo.getMethodDescriptors());
- assertEquals(-1, subinfo.getDefaultEventIndex());
- assertEquals(-1, subinfo.getDefaultPropertyIndex());
- }
-
- static class FakeFoxInfo {
-
- public int getProp6(boolean i) {
- return 0;
- }
-
- public void setProp6(boolean i) {
-
- }
- }
-
- /*
- * @test setBeanInfoSearchPath
- *
- * Change the sequence of the paths in Introspector.searchpaths, check
- * whether the BeanInfo is consistent with the bean class
- */
- public void testSetBeanInfoSearchPath_SameClassesInDifferentPackage()
- throws IntrospectionException {
- // set the search path in the correct sequence
- Introspector
- .setBeanInfoSearchPath(new String[] {
- "org.apache.harmony.beans.tests.support.mock.homonymy.mocksubject1.info",
- "org.apache.harmony.beans.tests.support.mock.homonymy.mocksubject2.info", });
-
- BeanInfo beanInfo = Introspector
- .getBeanInfo(org.apache.harmony.beans.tests.support.mock.homonymy.mocksubject1.MockHomonymySubject.class);
- BeanDescriptor beanDesc = beanInfo.getBeanDescriptor();
-
- assertEquals(beanDesc.getName(), "mocksubject1");
- assertEquals(
- beanDesc.getBeanClass(),
- org.apache.harmony.beans.tests.support.mock.homonymy.mocksubject1.MockHomonymySubject.class);
-
- // set the search path in the reverse sequence
- Introspector
- .setBeanInfoSearchPath(new String[] {
- "org.apache.harmony.beans.tests.support.mock.homonymy.mocksubject2.info",
- "org.apache.harmony.beans.tests.support.mock.homonymy.mocksubject1.info", });
-
- beanInfo = Introspector
- .getBeanInfo(org.apache.harmony.beans.tests.support.mock.homonymy.mocksubject1.MockHomonymySubject.class);
- beanDesc = beanInfo.getBeanDescriptor();
-
- assertEquals(beanDesc.getName(), "mocksubject1");
- assertEquals(
- beanDesc.getBeanClass(),
- org.apache.harmony.beans.tests.support.mock.homonymy.mocksubject1.MockHomonymySubject.class);
-
- }
-
- /*
- * If Bean3 has empty BeanInfo, then
- * Introspector.getBeanInfo(Bean3.class).getBeanDescriptor() returns null.
- */
- public void testNullBeanDescriptor() throws IntrospectionException {
- Class<Bean3> clazz = Bean3.class;
- BeanInfo info = Introspector.getBeanInfo(clazz);
- // printInfo(info);
- assertNotNull(info.getBeanDescriptor());
- }
-
- public static class Bean3 {
-
- private String prop1;
-
- public String getProp1() {
- return prop1;
- }
-
- public void setProp1(String prop1) {
- this.prop1 = prop1;
- }
- }
-
- public static class Bean3BeanInfo extends SimpleBeanInfo {
- }
-
- public void testGetPropertyDescriptors_H1838()
- throws IntrospectionException {
- // Regression for HARMONY-1838
- PropertyDescriptor[] propertyDescriptors = Introspector.getBeanInfo(
- Bean.class).getPropertyDescriptors();
-
- assertEquals("class", propertyDescriptors[0].getName());
- assertEquals("prop1", propertyDescriptors[1].getName());
- assertEquals("prop2", propertyDescriptors[2].getName());
- assertEquals(3, propertyDescriptors.length);
- }
-
- public static class Bean {
- public String getProp1(int i) {
- return null;
- }
-
- public void setProp2(int i, String str) {
- }
- }
-
- /*
- *
- */
- public void testGetPropertyDescriptors() throws IntrospectionException {
- Class<Bean2> clazz = Bean2.class;
- BeanInfo info = Introspector.getBeanInfo(clazz);
- PropertyDescriptor[] pds = info.getPropertyDescriptors();
-
- assertEquals(2, pds.length);
- assertEquals("property1", pds[0].getName());
- assertEquals("property8", pds[1].getName());
- }
-
- public void testHarmony4861() throws IntrospectionException {
- final PropertyDescriptor[] propertyDescriptors = Introspector
- .getBeanInfo(TestBean.class).getPropertyDescriptors();
-
- for (PropertyDescriptor d : propertyDescriptors) {
- if (d.getName().equals("prop1")) { //$NON-NLS-1$
- assertEquals("isProp1", d.getReadMethod().getName()); //$NON-NLS-1$
- return;
- }
- }
- }
-
- public static class TestBean {
- boolean prop1;
-
- public void setProp1(boolean prop1) {
- this.prop1 = prop1;
- }
-
- public boolean isProp1() {
- return prop1;
- }
-
- public boolean getProp1() {
- return prop1;
- }
- }
-
- public static TestSuite suite() {
-// TestSuite suite = new TestSuite();
- TestSuite suite = new TestSuite(IntrospectorTest.class);
-
-// suite.addTest(new IntrospectorTest("testIntrospection_7"));
- return suite;
- }
-
- public static class Bean1 {
-
- private int i;
-
- public int ggetI() {
- return i;
- }
-
- public void ssetI(int i) {
- this.i = i;
- }
- }
-
- public static class Bean1BeanInfo extends SimpleBeanInfo {
-
- @Override
- public PropertyDescriptor[] getPropertyDescriptors() {
- try {
- PropertyDescriptor _property1 = new PropertyDescriptor(
- "property1", Bean1.class, "ggetI", "ssetI");
- PropertyDescriptor[] pds = new PropertyDescriptor[] { _property1 };
- return pds;
- } catch (IntrospectionException exception) {
- return null;
- }
- }
- }
-
- public static class Bean2 extends Bean1 {
-
- private int property8;
-
- public int getProperty8() {
- return property8;
- }
-
- public void setProperty8(int property8) {
- this.property8 = property8;
- }
- }
-
- private static void assertBeanInfoEquals(BeanInfo beanInfo, BeanInfo info) {
- // compare BeanDescriptor
- assertEquals(beanInfo.getBeanDescriptor().getDisplayName(), info
- .getBeanDescriptor().getDisplayName());
-
- // compare MethodDescriptor
- MethodDescriptor[] methodDesc1 = beanInfo.getMethodDescriptors();
- MethodDescriptor[] methodDesc2 = info.getMethodDescriptors();
- assertEquals(methodDesc1.length, methodDesc2.length);
-
- for (int i = 0; i < methodDesc1.length; i++) {
- assertEquals(methodDesc1[i].getMethod(), methodDesc2[i].getMethod());
- assertEquals(methodDesc1[i].getDisplayName(), methodDesc2[i]
- .getDisplayName());
- }
-
- // compare PropertyDescriptor
- PropertyDescriptor[] propertyDesc1 = beanInfo.getPropertyDescriptors();
- PropertyDescriptor[] propertyDesc2 = info.getPropertyDescriptors();
- assertEquals(propertyDesc1.length, propertyDesc2.length);
-
- for (int i = 0; i < propertyDesc1.length; i++) {
- assertEquals(propertyDesc1[i], propertyDesc2[i]);
- }
-
- // compare EventSetDescriptor
- EventSetDescriptor[] eventDesc1 = beanInfo.getEventSetDescriptors();
- EventSetDescriptor[] eventDesc2 = beanInfo.getEventSetDescriptors();
- if (eventDesc1 == null) {
- assertNull(eventDesc2);
- }
- if (eventDesc2 == null) {
- assertNull(eventDesc1);
- }
- if ((eventDesc1 != null) && (eventDesc1 != null)) {
- assertEquals(eventDesc1.length, eventDesc2.length);
- for (int i = 0; i < eventDesc1.length; i++) {
- assertEquals(eventDesc1[i].getAddListenerMethod(),
- eventDesc2[i].getAddListenerMethod());
- assertEquals(eventDesc1[i].getRemoveListenerMethod(),
- eventDesc2[i].getRemoveListenerMethod());
- assertEquals(eventDesc1[i].getGetListenerMethod(),
- eventDesc2[i].getGetListenerMethod());
- assertEquals(eventDesc1[i].getListenerMethods().length,
- eventDesc2[i].getListenerMethods().length);
- }
- }
-
- }
-
- private static boolean contains(String propName, Class<?> propClass,
- PropertyDescriptor[] pds)
- {
- for (PropertyDescriptor pd : pds) {
- if (propName.equals(pd.getName()) &&
- propClass.equals(pd.getPropertyType())) {
- return true;
- }
- }
-
- return false;
- }
-
- private static boolean contains(String methodName,
- MethodDescriptor[] mds)
- {
- for (MethodDescriptor md : mds) {
- if (methodName.equals(md.getName())) {
- return true;
- }
- }
-
- return false;
- }
-
- private static boolean contains(String eventSetName,
- EventSetDescriptor[] esds)
- {
- for (EventSetDescriptor esd : esds) {
- if (eventSetName.equals(esd.getName())) {
- return true;
- }
- }
-
- return false;
- }
-
- /*
- * The following classes are used to test introspect properties
- */
- static class FakeFox10 {
-
- }
-
- static class FakeFox101 extends FakeFox10 {
-
- public void setFox101(String value) {
- }
-
- public String getFox101() {
- return null;
- }
- }
-
- static class FakeFox20 {
-
- public void setFox201(String value) {
- }
- }
-
- static class FakeFox201 extends FakeFox20 {
-
- public String getFox201() {
- return null;
- }
- }
-
- static class FakeFox202 extends FakeFox20 {
-
- public Integer getFox201() {
- return null;
- }
- }
-
- static class FakeFox30 {
-
- public Integer getFox301() {
- return null;
- }
- }
-
- static class FakeFox301 extends FakeFox30 {
-
- public void setFox301(String value) {
- }
-
- }
-
- static class FakeFox40 {
-
- public String getFox401(int i) {
- return null;
- }
-
- public void setFox401(int i, String value) {
-
- }
- }
-
- static class FakeFox401 extends FakeFox40 {
-
- public String[] getFox401() {
- return null;
- }
-
- public void setFox401(String[] value) {
-
- }
- }
-
- static class FakeFox402 extends FakeFox40 {
-
- public Integer[] getFox401() {
- return null;
- }
-
- public void setFox401(String[] value) {
-
- }
- }
-
- static class FakeFox50 {
-
- public String[] getFox501() {
- return null;
- }
- }
-
- static class FakeFox501 extends FakeFox50 {
-
- public String getFox501(int i) {
- return null;
- }
-
- public void setFox501(String[] value) {
-
- }
- }
-
- static class FakeFox502 extends FakeFox50 {
-
- public void setFox501(int i, String value) {
- return;
- }
- }
-
- static class FakeFox503 extends FakeFox50 {
-
- public void setFox501(int i, Integer value) {
- return;
- }
- }
-
- static class FakeFox500 {
-
- public String getFakeFox500(int i) {
- return null;
- }
- }
-
- static class FakeFox5001 extends FakeFox500 {
-
- public void setFakeFox500(int i, String value) {
-
- }
- }
-
- /*
- * The following classes are used to test introspect Event
- */
- static class FakeFox60 {
-
- }
-
- static class FakeFox601 {
-
- public void addFakeFox601Listener(FakeFox601Listener listener) {
-
- }
-
- public void removeFakeFox601Listener(FakeFox601Listener listener) {
-
- }
- }
-
- static class FakeFox602 extends FakeFox601 {
-
- @Override
- public void addFakeFox601Listener(FakeFox601Listener listener) {
-
- }
-
- @Override
- public void removeFakeFox601Listener(FakeFox601Listener listener) {
-
- }
-
- public FakeFox601Listener[] getFakeFox601Listeners() {
- return null;
- }
- }
-
- static class FakeFox603 extends FakeFox60 {
-
- public void addFakeFox601Listener(FakeFox601Listener listener) {
-
- }
- }
-
- static class FakeFox604 {
-
- public void addFakeFox601Listener(FakeFox601Listener listener)
- throws TooManyListenersException {
-
- }
-
- public void removeFakeFox601Listener(FakeFox601Listener listener) {
-
- }
- }
-
- static interface FakeFox601Listener extends EventListener {
-
- public void fakeFox601(FakeFox601Event event);
-
- public void fakeFox601(String event);
- }
-
- static class FakeFox601Event extends EventObject {
-
- /**
- * Comment for <code>serialVersionUID</code>
- */
- private static final long serialVersionUID = 1L;
-
- public FakeFox601Event(Object source) {
- super(source);
- }
- }
-
- static class FakeFox70 {
-
- int ddd;
-
- int bbb;
-
- int bc;
-
- Integer ff;
-
- String a;
-
- String bb;
-
- String aaa;
-
- public String getA() {
- return a;
- }
-
- public void setA(String a) {
- this.a = a;
- }
-
- public String getAaa() {
- return aaa;
- }
-
- public void setAaa(String aaa) {
- this.aaa = aaa;
- }
-
- public String getBb() {
- return bb;
- }
-
- public void setBb(String bb) {
- this.bb = bb;
- }
-
- public int getBbb() {
- return bbb;
- }
-
- public void setBbb(int bbb) {
- this.bbb = bbb;
- }
-
- public int getBc() {
- return bc;
- }
-
- public void setBc(int bc) {
- this.bc = bc;
- }
-
- public int getDdd() {
- return ddd;
- }
-
- public void setDdd(int ddd) {
- this.ddd = ddd;
- }
-
- public Integer getFf() {
- return ff;
- }
-
- public void setFf(Integer ff) {
- this.ff = ff;
- }
- }
-
- static class FakeFox80 {
-
- public String get() {
- return null;
- }
-
- public String get123() {
- return null;
- }
- }
-
- static class FakeFox90 {
-
- public String getFox(String value) {
- return null;
- }
-
- public void setFox(String value) {
-
- }
- }
-
- static class MockFoo23 {
-
- public String getName() {
- return null;
- }
- }
-
- public static class MockFoo23BeanInfo extends SimpleBeanInfo {
-
- @Override
- public PropertyDescriptor[] getPropertyDescriptors() {
- // System.out.println("MockFoo23BeanInfo is called");
- PropertyDescriptor pd = null;
- Class<MockFoo23> clazz = MockFoo23.class;
- try {
- Method getter = clazz.getMethod("getName", new Class[] {});
- pd = new PropertyDescriptor("name", getter, null);
- pd.setDisplayName(pd.getName() + ".beanInfo");
- } catch (IntrospectionException e) {
- e.printStackTrace();
- } catch (SecurityException e) {
- e.printStackTrace();
- } catch (NoSuchMethodException e) {
- e.printStackTrace();
- }
-
- return new PropertyDescriptor[] { pd };
- }
- }
-
- public static class MockFox00 {
-
- public String getLabel() {
- return null;
- }
-
- public void setName(String value) {
-
- }
- }
-
- public static class MockFox00BeanInfo extends SimpleBeanInfo {
-
- @Override
- public MethodDescriptor[] getMethodDescriptors() {
- MethodDescriptor md = null;
- try {
- Class<MockFox00> clz = MockFox00.class;
- Method method = clz.getMethod("getLabel", new Class[] {});
- md = new MethodDescriptor(method);
-
- } catch (Exception e) {
-
- }
-
- return new MethodDescriptor[] { md };
- }
- }
-
- public static class MockFox001 extends MockFox00 {
-
- public String getName() {
- return null;
- }
- }
-
- public static class MockFox001BeanInfo extends SimpleBeanInfo {
-
- @Override
- public PropertyDescriptor[] getPropertyDescriptors() {
- // System.out.println("MockFox001BeanInfo is called");
- PropertyDescriptor pd = null;
- Class<MockFox001> clazz = MockFox001.class;
- try {
- Method getter = clazz.getMethod("getName", new Class[] {});
- pd = new PropertyDescriptor("name", getter, null);
- pd.setDisplayName(pd.getName() + ".beaninfo");
- } catch (IntrospectionException e) {
- e.printStackTrace();
- } catch (SecurityException e) {
- e.printStackTrace();
- } catch (NoSuchMethodException e) {
- e.printStackTrace();
- }
-
- return new PropertyDescriptor[] { pd };
- }
-
- @Override
- public MethodDescriptor[] getMethodDescriptors() {
- MethodDescriptor md = null;
- try {
- Class<MockFox001> clz = MockFox001.class;
- Method method = clz.getMethod("getName", new Class[] {});
- md = new MethodDescriptor(method);
-
- } catch (Exception e) {
-
- }
-
- return new MethodDescriptor[] { md };
- }
- }
-
- public static class MockFox01 {
-
- public String getLabel() {
- return null;
- }
-
- public void setName(String value) {
-
- }
- }
-
- public static class MockFox011 extends MockFox01 {
-
- public String getName() {
- return null;
- }
- }
-
- public static class MockFox011BeanInfo extends SimpleBeanInfo {
-
- @Override
- public MethodDescriptor[] getMethodDescriptors() {
- MethodDescriptor md = null;
- try {
- Class<MockFox011> clz = MockFox011.class;
- Method m = clz.getMethod("getName", new Class[] {});
- md = new MethodDescriptor(m);
- } catch (Exception e) {
-
- }
- return new MethodDescriptor[] { md };
- }
- }
- public void testProperty() throws IntrospectionException {
- Class<MockSubClassForPorpertiesStandard> beanClass = MockSubClassForPorpertiesStandard.class;
- BeanInfo info = Introspector.getBeanInfo(beanClass);
- assertEquals(-1, info.getDefaultEventIndex());
- assertEquals(-1, info.getDefaultPropertyIndex());
- PropertyDescriptor[] pds = info.getPropertyDescriptors();
- for (PropertyDescriptor pd : pds) {
- assertFalse(pd.isBound());
- assertFalse(pd.isConstrained());
- assertFalse(pd.isExpert());
- assertFalse(pd.isHidden());
- assertFalse(pd.isPreferred());
- }
- assertEquals(2, info.getPropertyDescriptors().length);
-
- BeanInfo dummyInfo = Introspector.getBeanInfo(FakeFox041.class);
- PropertyDescriptor[] p = dummyInfo.getPropertyDescriptors();
- assertFalse(p[0].isBound());
- assertFalse(p[0].isConstrained());
- assertFalse(p[1].isBound());
- assertFalse(p[1].isConstrained());
- assertTrue(p[2].isBound());
- assertTrue(p[2].isConstrained());
-
- dummyInfo = Introspector.getBeanInfo(FakeFox0411.class);
- p = dummyInfo.getPropertyDescriptors();
- assertFalse(p[0].isBound());
- assertFalse(p[0].isConstrained());
- assertFalse(p[1].isBound());
- assertFalse(p[1].isConstrained());
- assertTrue(p[2].isBound());
- assertFalse(p[2].isConstrained());
- assertTrue(p[3].isBound());
- assertTrue(p[3].isConstrained());
-
- dummyInfo = Introspector.getBeanInfo(FakeFox0411.class, FakeFox041.class);
- p = dummyInfo.getPropertyDescriptors();
- assertFalse(p[0].isBound());
- assertFalse(p[0].isConstrained());
- }
-
- public void testDefaultEvent() throws IntrospectionException {
- Class beanClass = MockClassForDefaultEvent.class;
- BeanInfo info = Introspector.getBeanInfo(beanClass);
- assertEquals(-1, info.getDefaultEventIndex());
- assertEquals(-1, info.getDefaultPropertyIndex());
- EventSetDescriptor[] events = info.getEventSetDescriptors();
- for (EventSetDescriptor event : events) {
- assertFalse(event.isUnicast());
- assertTrue(event.isInDefaultEventSet());
- assertFalse(event.isExpert());
- assertFalse(event.isHidden());
- assertFalse(event.isPreferred());
- }
- }
-
- public void testDefaultIndex() throws IntrospectionException {
- Introspector
- .setBeanInfoSearchPath(new String[] { "org.apache.harmony.beans.tests.support" });
-
- BeanInfo dummyInfo = Introspector.getBeanInfo(FakeFox031.class);
- assertEquals(-1, dummyInfo.getDefaultPropertyIndex());
- assertEquals(-1, dummyInfo.getDefaultEventIndex());
- }
-
- static class MockBaseClassForPorpertiesStandard {
- int a = 0;
-
- int b = 1;
- }
-
- static class MockSubClassForPorpertiesStandard extends
- MockBaseClassForPorpertiesStandard {
- int a = 2;
-
- int b = 3;
-
- public int getName() {
- return a;
- }
-
- public void setName(int i) {
- a = i;
- }
- }
-
- static class MockClassForDefaultEvent {
- public void addPropertyChangeListener(PropertyChangeListener a) {
- }
-
- public void removePropertyChangeListener(PropertyChangeListener a) {
- }
- }
- static class MockBaseClassForPorperties {
- int a = 0;
-
- int b = 1;
- }
-
- static class MockSubClassForPorperties extends MockBaseClassForPorperties {
- int a = 2;
-
- int b = 3;
-
- int c = 3;
-
- public int getName() {
- return a;
- }
-
- public void setName(int i) {
- a = i;
- }
- }
-
- public void testGetIcon() throws IntrospectionException {
- Class<MockSubClassForPorperties> beanClass = MockSubClassForPorperties.class;
- BeanInfo info = Introspector.getBeanInfo(beanClass);
- assertNotNull(info.getIcon(BeanInfo.ICON_COLOR_16x16));
- }
-
- public static class MockBaseClassForPorpertiesBeanInfo extends
- SimpleBeanInfo {
-
- @Override
- public MethodDescriptor[] getMethodDescriptors() {
- MethodDescriptor md = null;
- try {
- Class<MockSubClassForPorperties> clz = MockSubClassForPorperties.class;
- Method m = clz.getMethod("getName", new Class[] {});
- md = new MethodDescriptor(m);
- } catch (Exception e) {
-
- }
- return new MethodDescriptor[] { md };
- }
-
- @Override
- public PropertyDescriptor[] getPropertyDescriptors() {
- PropertyDescriptor[] pds = new PropertyDescriptor[2];
- Class<MockSubClassForPorperties> clazz = MockSubClassForPorperties.class;
- try {
- Method getter = clazz.getMethod("getName");
- Method setter = clazz.getMethod("setName", Integer.TYPE);
- pds[0] = new PropertyDescriptor("a", getter, setter);
- pds[0].setConstrained(true);
- pds[0].setBound(true);
- pds[0].setExpert(true);
- pds[0].setHidden(true);
- pds[1] = new PropertyDescriptor("b", getter, setter);
- } catch (IntrospectionException e) {
- e.printStackTrace();
- } catch (SecurityException e) {
- e.printStackTrace();
- } catch (NoSuchMethodException e) {
- e.printStackTrace();
- }
-
- return pds;
- }
-
- public Image getIcon(int iconKind) {
- return null;
- }
- }
-
- public static class MockSubClassForPorpertiesBeanInfo extends
- SimpleBeanInfo {
-
- @Override
- public MethodDescriptor[] getMethodDescriptors() {
- MethodDescriptor md = null;
- try {
- Class<MockSubClassForPorperties> clz = MockSubClassForPorperties.class;
- Method m = clz.getMethod("getName", new Class[] {});
- md = new MethodDescriptor(m);
- } catch (Exception e) {
-
- }
- return new MethodDescriptor[] { md };
- }
-
- @Override
- public PropertyDescriptor[] getPropertyDescriptors() {
- PropertyDescriptor[] pds = new PropertyDescriptor[2];
- Class<MockSubClassForPorperties> clazz = MockSubClassForPorperties.class;
- try {
- Method getter = clazz.getMethod("getName");
- Method setter = clazz.getMethod("setName", Integer.TYPE);
- pds[0] = new PropertyDescriptor("a", getter, setter);
- pds[1] = new PropertyDescriptor("b", getter, setter);
- } catch (IntrospectionException e) {
- e.printStackTrace();
- } catch (SecurityException e) {
- e.printStackTrace();
- } catch (NoSuchMethodException e) {
- e.printStackTrace();
- }
- return pds;
- }
-
- public Image getIcon(int iconKind) {
- return new BufferedImage(16, 16, 1);
- }
-
- }
-
- /*
- * Regression test for HARMONY-4892
- */
- public static class MyBean {
-
- public static String invisble;
-
- public static String getInvisible() {
- return invisble;
- }
-
- public String visible;
-
- public String getVisible() {
- return visible;
- }
-
- public void setVisible(String a) {
- this.visible = a;
- }
- }
-
- public void testPropertyDescriptors() throws IntrospectionException {
- BeanInfo info = Introspector.getBeanInfo(MyBean.class);
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- assertFalse(pd.getName().equals("invisible"));
- }
- }
-
- /**
- * Tests tricky cases when several conflicting set/get methods are defined.
- * All these tests pass on RI.
- * This is a regression test for HARMONY-5675
- * @throws IntrospectionException
- */
- public void test5675() throws IntrospectionException {
- BeanInfo bInfo;
-
- for (Class clz: new Class[] {TstBean5675.class, TstBean5675_2.class}) {
-
- bInfo = Introspector.getBeanInfo(clz);
-
- for (PropertyDescriptor desc: bInfo.getPropertyDescriptors()) {
-
- if (desc.getName().equals("prop1")) {
- assertNotNull("invalid get method", desc.getReadMethod());
- assertEquals("get method has invalid return type",
- Integer.class, desc.getReadMethod().getReturnType());
- assertNotNull("invalid set method", desc.getWriteMethod());
- assertEquals("invalid set method",
- "setProp1", desc.getWriteMethod().getName());
- assertNotNull("set method don't have any parameters",
- desc.getWriteMethod().getParameterTypes());
- assertEquals("set method has invalid parameters",
- Integer.class,
- desc.getWriteMethod().getParameterTypes()[0]);
- }
- }
- }
-
- for (Class clz : new Class[] {TstBean5675_3.class, TstBean5675_5.class,
- TstBean5675_6.class}) {
-
- bInfo = Introspector.getBeanInfo(clz);
-
- for (PropertyDescriptor desc: bInfo.getPropertyDescriptors()) {
-
- if (desc.getName().equals("prop1")) {
- assertNull("Non-null get method", desc.getReadMethod());
- assertNull("Non-null set method", desc.getWriteMethod());
- }
- }
- }
-
- bInfo = Introspector.getBeanInfo(TstBean5675_4.class);
- for (PropertyDescriptor desc: bInfo.getPropertyDescriptors()) {
-
- if (desc.getName().equals("prop1")) {
- assertNotNull("invalid get method", desc.getReadMethod());
- assertEquals("get method has invalid return type",
- Integer.class, desc.getReadMethod().getReturnType());
- assertNull("Non-null set method", desc.getWriteMethod());
- }
- }
-
- bInfo = Introspector.getBeanInfo(TstBean5675_7.class);
- for (PropertyDescriptor desc: bInfo.getPropertyDescriptors()) {
-
- if (desc.getName().equals("prop1")) {
- assertNull("Non-null get method", desc.getReadMethod());
- assertEquals("invalid set method",
- "setProp1", desc.getWriteMethod().getName());
- assertNotNull("set method don't have any parameters",
- desc.getWriteMethod().getParameterTypes());
- assertEquals("set method has invalid parameters",
- Integer.class,
- desc.getWriteMethod().getParameterTypes()[0]);
- }
- }
-
- bInfo = Introspector.getBeanInfo(TstBean5675_8.class);
- for (PropertyDescriptor desc: bInfo.getPropertyDescriptors()) {
-
- if (desc.getName().equals("prop1")) {
- assertNotNull("invalid get method", desc.getReadMethod());
- assertEquals("get method has invalid return type",
- Integer[].class, desc.getReadMethod().getReturnType());
- assertNull("Non-null set method", desc.getWriteMethod());
- }
- }
-
- bInfo = Introspector.getBeanInfo(TstBean5675_9.class);
- for (PropertyDescriptor desc: bInfo.getPropertyDescriptors()) {
-
- if (desc.getName().equals("prop1")) {
- assertNull("Non-null get method", desc.getReadMethod());
- assertNotNull("invalid set method", desc.getWriteMethod());
- assertEquals("invalid set method",
- "setProp1", desc.getWriteMethod().getName());
- assertNotNull("set method don't have any parameters",
- desc.getWriteMethod().getParameterTypes());
- assertEquals("set method has invalid parameters",
- Integer[].class,
- desc.getWriteMethod().getParameterTypes()[0]);
- }
- }
-
- bInfo = Introspector.getBeanInfo(TstBean5675_10.class);
- for (PropertyDescriptor desc: bInfo.getPropertyDescriptors()) {
-
- if (desc.getName().equals("prop1")) {
- assertNotNull("invalid get method", desc.getReadMethod());
- assertEquals("get method has invalid return type",
- Integer[].class, desc.getReadMethod().getReturnType());
- assertNotNull("invalid set method", desc.getWriteMethod());
- assertEquals("invalid set method",
- "setProp1", desc.getWriteMethod().getName());
- assertNotNull("set method don't have any parameters",
- desc.getWriteMethod().getParameterTypes());
- assertEquals("set method has invalid parameters",
- Integer[].class,
- desc.getWriteMethod().getParameterTypes()[0]);
- }
- }
-
- }
-
- class TstBean5675 {
-
- public void setProp1(String uri) {}
-
- public void setProp1(Integer i) {}
-
-
- public Integer getProp1() {
- return null;
- }
-
- }
-
-
- class TstBean5675_2 {
-
- public Integer getProp1() {
- return null;
- }
-
- public String getProp1(int n) {
- return null;
- }
-
- public void setProp1(Integer val) {}
-
-
- }
-
- class TstBean5675_3 {
-
- public String getProp1(int n) {
- return null;
- }
-
- public void setProp1(int n, String uri) {}
-
- public void setProp1(Integer i) {}
-
- public Integer getProp1() {
- return null;
- }
-
- }
-
- class TstBean5675_4 {
-
- public void setProp1(String val) {}
-
- public Integer getProp1() {
- return null;
- }
-
- }
-
- class TstBean5675_5 {
-
- public Integer getProp1() {
- return null;
- }
-
-// public void setProp1(Integer val) {}
-
- public String getProp1(int n) {
- return null;
- }
-
- public void setProp1(int n, String uri) {}
-
-
- }
-
- class TstBean5675_6 {
-
- public Integer getProp1() {
- return null;
- }
-
-// public void setProp1(Integer val) {}
-//
-// public String getProp1(int n) {
-// return null;
-// }
-
- public void setProp1(int n, String uri) {}
-
-
- }
-
- class TstBean5675_7 {
- public void setProp1(String val) {}
- public void setProp1(Integer val) {}
- }
-
- class TstBean5675_8 {
- public Integer[] getProp1() {
- return null;
- }
-
- //public void setProp1(Integer[] val) {}
-
- public Integer getProp1(int n) {
- return null;
- }
-
- public void setProp1(int n, Integer val) {}
- }
-
- class TstBean5675_9 {
- public void setProp1(Integer[] val) {}
-
- public Integer getProp1(int n) {
- return null;
- }
-
- }
-
- class TstBean5675_10 {
- public Integer[] getProp1() {
- return null;
- }
-
- public void setProp1(Integer[] val) {}
-
- public Integer getProp1(int n) {
- return null;
- }
-
- public void setProp1(int n, Integer val) {}
- }
-
- /*
- * Introspector Mixed Testing Begin
- */
- private String propertyName = "list";
-
- public class MixedSimpleClass1 {
-
- public Object isList(int index) {
- return null;
- }
-
- public Object isList() {
- return null;
- }
- }
-
- public void test_MixedSimpleClass1() throws Exception {
- BeanInfo info = Introspector.getBeanInfo(MixedSimpleClass1.class);
- Method getter = MixedSimpleClass1.class.getDeclaredMethod("isList");
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertFalse(pd instanceof IndexedPropertyDescriptor);
- assertEquals(getter, pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- }
- }
- }
-
- public class MixedSimpleClass2 {
-
- public Object isList(int index) {
- return null;
- }
-
- public Object getList() {
- return null;
- }
-
- }
-
- public void test_MixedSimpleClass2() throws Exception {
- BeanInfo info = Introspector.getBeanInfo(MixedSimpleClass2.class);
- Method getter = MixedSimpleClass2.class.getDeclaredMethod("getList");
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertFalse(pd instanceof IndexedPropertyDescriptor);
- assertEquals(getter, pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- }
- }
- }
-
- public class MixedSimpleClass3 {
-
- public Object getList(int index) {
- return null;
- }
-
- public Object isList() {
- return null;
- }
-
- }
-
- public void test_MixedSimpleClass3() throws Exception {
- BeanInfo info = Introspector.getBeanInfo(MixedSimpleClass3.class);
- Method getter = MixedSimpleClass3.class.getDeclaredMethod("getList",
- int.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertTrue(pd instanceof IndexedPropertyDescriptor);
- assertNull(pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- assertEquals(getter, ((IndexedPropertyDescriptor) pd)
- .getIndexedReadMethod());
- assertNull(((IndexedPropertyDescriptor) pd)
- .getIndexedWriteMethod());
- }
- }
- }
-
- public class MixedSimpleClass4 {
-
- public Object getList(int index) {
- return null;
- }
-
- public Object getList() {
- return null;
- }
-
- }
-
- public void test_MixedSimpleClass4() throws Exception {
- BeanInfo info = Introspector.getBeanInfo(MixedSimpleClass4.class);
- Method getter = MixedSimpleClass4.class.getDeclaredMethod("getList",
- int.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertTrue(pd instanceof IndexedPropertyDescriptor);
- assertNull(pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- assertEquals(getter, ((IndexedPropertyDescriptor) pd)
- .getIndexedReadMethod());
- assertNull(((IndexedPropertyDescriptor) pd)
- .getIndexedWriteMethod());
- }
- }
- }
-
- public class MixedSimpleClass5 {
- public Object getList(int index) {
- return null;
- }
-
- public Object getList() {
- return null;
- }
-
- public void setList(Object obj) {
-
- }
- }
-
- public void test_MixedSimpleClass5() throws Exception {
- BeanInfo info = Introspector.getBeanInfo(MixedSimpleClass5.class);
- Method getter = MixedSimpleClass5.class.getDeclaredMethod("getList");
- Method setter = MixedSimpleClass5.class.getDeclaredMethod("setList",
- Object.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertFalse(pd instanceof IndexedPropertyDescriptor);
- assertEquals(getter, pd.getReadMethod());
- assertEquals(setter, pd.getWriteMethod());
- }
- }
- }
-
- public class MixedSimpleClass6 {
- public Object getList(int index) {
- return null;
- }
-
- public Object isList() {
- return null;
- }
-
- public void setList(Object obj) {
-
- }
- }
-
- public void test_MixedSimpleClass6() throws Exception {
- BeanInfo info = Introspector.getBeanInfo(MixedSimpleClass6.class);
- Method getter = MixedSimpleClass6.class.getDeclaredMethod("getList",
- int.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertTrue(pd instanceof IndexedPropertyDescriptor);
- assertNull(pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- assertEquals(getter, ((IndexedPropertyDescriptor) pd)
- .getIndexedReadMethod());
- assertNull(((IndexedPropertyDescriptor) pd)
- .getIndexedWriteMethod());
- }
- }
- }
-
- public class MixedSimpleClass7 {
- public Object isList(int index) {
- return null;
- }
-
- public Object getList() {
- return null;
- }
-
- public void setList(Object obj) {
-
- }
- }
-
- public void test_MixedSimpleClass7() throws Exception {
- BeanInfo info = Introspector.getBeanInfo(MixedSimpleClass7.class);
- Method getter = MixedSimpleClass7.class.getDeclaredMethod("getList");
- Method setter = MixedSimpleClass7.class.getDeclaredMethod("setList",
- Object.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertFalse(pd instanceof IndexedPropertyDescriptor);
- assertEquals(getter, pd.getReadMethod());
- assertEquals(setter, pd.getWriteMethod());
- }
- }
- }
-
- public class MixedSimpleClass8 {
- public Object isList(int index) {
- return null;
- }
-
- public Object isList() {
- return null;
- }
-
- public void setList(Object obj) {
-
- }
- }
-
- public void test_MixedSimpleClass8() throws Exception {
- BeanInfo info = Introspector.getBeanInfo(MixedSimpleClass8.class);
- Method setter = MixedSimpleClass8.class.getDeclaredMethod("setList",
- Object.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertFalse(pd instanceof IndexedPropertyDescriptor);
- assertNull(pd.getReadMethod());
- assertEquals(setter, pd.getWriteMethod());
- }
- }
- }
-
- public class MixedSimpleClass9 {
- public Object isList(int index) {
- return null;
- }
-
- public Object isList() {
- return null;
- }
-
- public void setList(int index, Object obj) {
-
- }
- }
-
- public void test_MixedSimpleClass9() throws Exception {
- BeanInfo info = Introspector.getBeanInfo(MixedSimpleClass9.class);
- Method setter = MixedSimpleClass9.class.getDeclaredMethod("setList",
- int.class, Object.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertTrue(pd instanceof IndexedPropertyDescriptor);
- assertNull(pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- assertNull(((IndexedPropertyDescriptor) pd)
- .getIndexedReadMethod());
- assertEquals(setter, ((IndexedPropertyDescriptor) pd)
- .getIndexedWriteMethod());
- }
- }
- }
-
- public class MixedSimpleClass10 {
- public Object isList(int index) {
- return null;
- }
-
- public Object getList() {
- return null;
- }
-
- public void setList(int index, Object obj) {
-
- }
- }
-
- public void test_MixedSimpleClass10() throws Exception {
- BeanInfo info = Introspector.getBeanInfo(MixedSimpleClass10.class);
- Method setter = MixedSimpleClass10.class.getDeclaredMethod("setList",
- int.class, Object.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertTrue(pd instanceof IndexedPropertyDescriptor);
- assertNull(pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- assertNull(((IndexedPropertyDescriptor) pd)
- .getIndexedReadMethod());
- assertEquals(setter, ((IndexedPropertyDescriptor) pd)
- .getIndexedWriteMethod());
- }
- }
- }
-
- public class MixedSimpleClass11 {
- public Object getList(int index) {
- return null;
- }
-
- public Object isList() {
- return null;
- }
-
- public void setList(int index, Object obj) {
-
- }
- }
-
- public void test_MixedSimpleClass11() throws Exception {
- BeanInfo info = Introspector.getBeanInfo(MixedSimpleClass11.class);
- Method getter = MixedSimpleClass11.class.getDeclaredMethod("getList",
- int.class);
- Method setter = MixedSimpleClass11.class.getDeclaredMethod("setList",
- int.class, Object.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertTrue(pd instanceof IndexedPropertyDescriptor);
- assertNull(pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- assertEquals(getter, ((IndexedPropertyDescriptor) pd)
- .getIndexedReadMethod());
- assertEquals(setter, ((IndexedPropertyDescriptor) pd)
- .getIndexedWriteMethod());
- }
- }
- }
-
- public class MixedSimpleClass12 {
- public Object getList(int index) {
- return null;
- }
-
- public Object getList() {
- return null;
- }
-
- public void setList(int index, Object obj) {
-
- }
- }
-
- public void test_MixedSimpleClass12() throws Exception {
- BeanInfo info = Introspector.getBeanInfo(MixedSimpleClass12.class);
- Method getter = MixedSimpleClass12.class.getDeclaredMethod("getList",
- int.class);
- Method setter = MixedSimpleClass12.class.getDeclaredMethod("setList",
- int.class, Object.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertTrue(pd instanceof IndexedPropertyDescriptor);
- assertNull(pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- assertEquals(getter, ((IndexedPropertyDescriptor) pd)
- .getIndexedReadMethod());
- assertEquals(setter, ((IndexedPropertyDescriptor) pd)
- .getIndexedWriteMethod());
- }
- }
- }
-
- public class MixedSimpleClass13 {
- public Object getList(int index) {
- return null;
- }
-
- public Object getList() {
- return null;
- }
-
- public void setList(int index, Object obj) {
-
- }
-
- public void setList(Object obj) {
-
- }
- }
-
- public void test_MixedSimpleClass13() throws Exception {
- BeanInfo info = Introspector.getBeanInfo(MixedSimpleClass13.class);
- Method getter = MixedSimpleClass13.class.getDeclaredMethod("getList",
- int.class);
- Method setter = MixedSimpleClass13.class.getDeclaredMethod("setList",
- int.class, Object.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertTrue(pd instanceof IndexedPropertyDescriptor);
- assertNull(pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- assertEquals(getter, ((IndexedPropertyDescriptor) pd)
- .getIndexedReadMethod());
- assertEquals(setter, ((IndexedPropertyDescriptor) pd)
- .getIndexedWriteMethod());
- }
- }
- }
-
- public class MixedSimpleClass14 {
- public Object getList(int index) {
- return null;
- }
-
- public Object isList() {
- return null;
- }
-
- public void setList(int index, Object obj) {
-
- }
-
- public void setList(Object obj) {
-
- }
- }
-
- public void test_MixedSimpleClass14() throws Exception {
- BeanInfo info = Introspector.getBeanInfo(MixedSimpleClass14.class);
- Method getter = MixedSimpleClass14.class.getDeclaredMethod("getList",
- int.class);
- Method setter = MixedSimpleClass14.class.getDeclaredMethod("setList",
- int.class, Object.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertTrue(pd instanceof IndexedPropertyDescriptor);
- assertNull(pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- assertEquals(getter, ((IndexedPropertyDescriptor) pd)
- .getIndexedReadMethod());
- assertEquals(setter, ((IndexedPropertyDescriptor) pd)
- .getIndexedWriteMethod());
- }
- }
- }
-
- public class MixedSimpleClass15 {
- public Object isList(int index) {
- return null;
- }
-
- public Object getList() {
- return null;
- }
-
- public void setList(int index, Object obj) {
-
- }
-
- public void setList(Object obj) {
-
- }
- }
-
- public void test_MixedSimpleClass15() throws Exception {
- BeanInfo info = Introspector.getBeanInfo(MixedSimpleClass15.class);
- Method getter = MixedSimpleClass15.class.getDeclaredMethod("getList");
- Method setter = MixedSimpleClass15.class.getDeclaredMethod("setList",
- Object.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertFalse(pd instanceof IndexedPropertyDescriptor);
- assertEquals(getter, pd.getReadMethod());
- assertEquals(setter, pd.getWriteMethod());
- }
- }
- }
-
- public class MixedSimpleClass16 {
- public Object isList(int index) {
- return null;
- }
-
- public Object isList() {
- return null;
- }
-
- public void setList(int index, Object obj) {
-
- }
-
- public void setList(Object obj) {
-
- }
- }
-
- public void test_MixedSimpleClass16() throws Exception {
- BeanInfo info = Introspector.getBeanInfo(MixedSimpleClass16.class);
- Method setter = MixedSimpleClass16.class.getDeclaredMethod("setList",
- int.class, Object.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertTrue(pd instanceof IndexedPropertyDescriptor);
- assertNull(pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- assertNull(((IndexedPropertyDescriptor) pd)
- .getIndexedReadMethod());
- assertEquals(setter, ((IndexedPropertyDescriptor) pd)
- .getIndexedWriteMethod());
- }
- }
- }
-
- public class MixedSimpleClass17 {
- public Object getList() {
- return null;
- }
-
- public void setList(int index, Object obj) {
-
- }
-
- public void setList(Object obj) {
-
- }
- }
-
- public void test_MixedSimpleClass17() throws Exception {
- BeanInfo info = Introspector.getBeanInfo(MixedSimpleClass17.class);
- Method getter = MixedSimpleClass17.class.getDeclaredMethod("getList");
- Method setter = MixedSimpleClass17.class.getDeclaredMethod("setList",
- Object.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertFalse(pd instanceof IndexedPropertyDescriptor);
- assertEquals(getter, pd.getReadMethod());
- assertEquals(setter, pd.getWriteMethod());
- }
- }
- }
-
- public class MixedSimpleClass18 {
- public Object isList() {
- return null;
- }
-
- public void setList(int index, Object obj) {
-
- }
-
- public void setList(Object obj) {
-
- }
- }
-
- public void test_MixedSimpleClass18() throws Exception {
- BeanInfo info = Introspector.getBeanInfo(MixedSimpleClass18.class);
- Method setter = MixedSimpleClass18.class.getDeclaredMethod("setList",
- int.class, Object.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertTrue(pd instanceof IndexedPropertyDescriptor);
- assertNull(pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- assertNull(((IndexedPropertyDescriptor) pd)
- .getIndexedReadMethod());
- assertEquals(setter, ((IndexedPropertyDescriptor) pd)
- .getIndexedWriteMethod());
- }
- }
- }
-
- public class MixedSimpleClass19 {
- public Object getList(int index) {
- return null;
- }
-
- public void setList(Object obj) {
-
- }
-
- public void setList(int index, Object obj) {
-
- }
- }
-
- public void test_MixedSimpleClass19() throws Exception {
- BeanInfo info = Introspector.getBeanInfo(MixedSimpleClass19.class);
- Method getter = MixedSimpleClass19.class.getDeclaredMethod("getList",
- int.class);
- Method setter = MixedSimpleClass19.class.getDeclaredMethod("setList",
- int.class, Object.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertTrue(pd instanceof IndexedPropertyDescriptor);
- assertNull(pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- assertEquals(getter, ((IndexedPropertyDescriptor) pd)
- .getIndexedReadMethod());
- assertEquals(setter, ((IndexedPropertyDescriptor) pd)
- .getIndexedWriteMethod());
- }
- }
- }
-
- public class MixedSimpleClass20 {
- public Object isList(int index) {
- return null;
- }
-
- public void setList(Object obj) {
-
- }
-
- public void setList(int index, Object obj) {
-
- }
- }
-
- public void test_MixedSimpleClass20() throws Exception {
- BeanInfo info = Introspector.getBeanInfo(MixedSimpleClass20.class);
- Method setter = MixedSimpleClass20.class.getDeclaredMethod("setList",
- int.class, Object.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertTrue(pd instanceof IndexedPropertyDescriptor);
- assertNull(pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- assertNull(((IndexedPropertyDescriptor) pd)
- .getIndexedReadMethod());
- assertEquals(setter, ((IndexedPropertyDescriptor) pd)
- .getIndexedWriteMethod());
- }
- }
- }
-
- public class MixedSimpleClass21 {
- public Object getList(int index) {
- return null;
- }
-
- public void setList(Object obj) {
- }
- }
-
- public void test_MixedSimpleClass21() throws Exception {
- BeanInfo info = Introspector.getBeanInfo(MixedSimpleClass21.class);
- Method getter = MixedSimpleClass21.class.getDeclaredMethod("getList",
- int.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertTrue(pd instanceof IndexedPropertyDescriptor);
- assertNull(pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- assertEquals(getter, ((IndexedPropertyDescriptor) pd)
- .getIndexedReadMethod());
- assertNull(((IndexedPropertyDescriptor) pd)
- .getIndexedWriteMethod());
- }
- }
- }
-
- public class MixedSimpleClass22 {
- public Object isList(int index) {
- return null;
- }
-
- public void setList(Object obj) {
- }
- }
-
- public void test_MixedSimpleClass22() throws Exception {
- BeanInfo info = Introspector.getBeanInfo(MixedSimpleClass22.class);
- Method setter = MixedSimpleClass22.class.getDeclaredMethod("setList",
- Object.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertFalse(pd instanceof IndexedPropertyDescriptor);
- assertNull(pd.getReadMethod());
- assertEquals(setter, pd.getWriteMethod());
- }
- }
- }
-
- public class MixedSimpleClass23 {
- public Object getList() {
- return null;
- }
-
- public void setList(int index, Object obj) {
- }
- }
-
- public void test_MixedSimpleClass23() throws Exception {
- BeanInfo info = Introspector.getBeanInfo(MixedSimpleClass23.class);
- Method setter = MixedSimpleClass23.class.getDeclaredMethod("setList",
- int.class, Object.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertTrue(pd instanceof IndexedPropertyDescriptor);
- assertNull(pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- assertNull(((IndexedPropertyDescriptor) pd)
- .getIndexedReadMethod());
- assertEquals(setter, ((IndexedPropertyDescriptor) pd)
- .getIndexedWriteMethod());
- }
- }
- }
-
- public class MixedSimpleClass24 {
- public Object isList() {
- return null;
- }
-
- public void setList(int index, Object obj) {
- }
- }
-
- public void test_MixedSimpleClass24() throws Exception {
- BeanInfo info = Introspector.getBeanInfo(MixedSimpleClass24.class);
- Method setter = MixedSimpleClass24.class.getDeclaredMethod("setList",
- int.class, Object.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertTrue(pd instanceof IndexedPropertyDescriptor);
- assertNull(pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- assertNull(((IndexedPropertyDescriptor) pd)
- .getIndexedReadMethod());
- assertEquals(setter, ((IndexedPropertyDescriptor) pd)
- .getIndexedWriteMethod());
- }
- }
- }
-
- public class MixedSimpleClass25 {
- public void setList(Object obj) {
-
- }
-
- public void setList(int index, Object obj) {
-
- }
- }
-
- public void test_MixedSimpleClass25() throws Exception {
- BeanInfo info = Introspector.getBeanInfo(MixedSimpleClass25.class);
- Method setter = MixedSimpleClass25.class.getDeclaredMethod("setList",
- int.class, Object.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertTrue(pd instanceof IndexedPropertyDescriptor);
- assertNull(pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- assertNull(((IndexedPropertyDescriptor) pd)
- .getIndexedReadMethod());
- assertEquals(setter, ((IndexedPropertyDescriptor) pd)
- .getIndexedWriteMethod());
- }
- }
- }
-
- public class MixedSimpleClass26 {
-
- public Object[] getList() {
- return null;
- }
-
- public Object getList(int i) {
- return null;
- }
- }
-
- public void test_MixedSimpleClass26() throws Exception {
- BeanInfo info = Introspector.getBeanInfo(MixedSimpleClass26.class);
- Method normalGetter = MixedSimpleClass26.class
- .getDeclaredMethod("getList");
- Method indexedGetter = MixedSimpleClass26.class.getDeclaredMethod(
- "getList", int.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertTrue(pd instanceof IndexedPropertyDescriptor);
- assertEquals(normalGetter, pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- assertEquals(indexedGetter, ((IndexedPropertyDescriptor) pd)
- .getIndexedReadMethod());
- assertNull(((IndexedPropertyDescriptor) pd)
- .getIndexedWriteMethod());
-
- }
- }
- }
-
- public class MixedSimpleClass27 {
-
- public Object[] isList() {
- return null;
- }
-
- public Object getList(int i) {
- return null;
- }
- }
-
- public void test_MixedSimpleClass27() throws Exception {
- BeanInfo info = Introspector.getBeanInfo(MixedSimpleClass27.class);
- Method indexedGetter = MixedSimpleClass27.class.getDeclaredMethod(
- "getList", int.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertTrue(pd instanceof IndexedPropertyDescriptor);
- assertNull(pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- assertEquals(indexedGetter, ((IndexedPropertyDescriptor) pd)
- .getIndexedReadMethod());
- assertNull(((IndexedPropertyDescriptor) pd)
- .getIndexedWriteMethod());
-
- }
- }
- }
-
- public class MixedSimpleClass28 {
-
- public Object[] getList() {
- return null;
- }
-
- public Object isList(int i) {
- return null;
- }
- }
-
- public void test_MixedSimpleClass28() throws Exception {
- BeanInfo info = Introspector.getBeanInfo(MixedSimpleClass28.class);
- Method getter = MixedSimpleClass28.class.getDeclaredMethod("getList");
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertFalse(pd instanceof IndexedPropertyDescriptor);
- assertEquals(getter, pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- }
- }
- }
-
- public class MixedSimpleClass29 {
-
- public Object[] isList() {
- return null;
- }
-
- public Object isList(int i) {
- return null;
- }
- }
-
- public void test_MixedSimpleClass29() throws Exception {
- BeanInfo info = Introspector.getBeanInfo(MixedSimpleClass29.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- assertFalse(propertyName.equals(pd.getName()));
- }
- }
-
- public class MixedSimpleClass30 {
-
- public Object getList() {
- return null;
- }
-
- public Object[] getList(int i) {
- return null;
- }
- }
-
- public void test_MixedSimpleClass30() throws Exception {
- BeanInfo info = Introspector.getBeanInfo(MixedSimpleClass30.class);
- Method indexedGetter = MixedSimpleClass30.class.getDeclaredMethod(
- "getList", int.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertTrue(pd instanceof IndexedPropertyDescriptor);
- assertNull(pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- assertEquals(indexedGetter, ((IndexedPropertyDescriptor) pd)
- .getIndexedReadMethod());
- assertNull(((IndexedPropertyDescriptor) pd)
- .getIndexedWriteMethod());
-
- }
- }
- }
-
- public class MixedSimpleClass31 {
-
- public Object isList() {
- return null;
- }
-
- public Object[] getList(int i) {
- return null;
- }
- }
-
- public void test_MixedSimpleClass31() throws Exception {
- BeanInfo info = Introspector.getBeanInfo(MixedSimpleClass31.class);
- Method indexedGetter = MixedSimpleClass31.class.getDeclaredMethod(
- "getList", int.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertTrue(pd instanceof IndexedPropertyDescriptor);
- assertNull(pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- assertEquals(indexedGetter, ((IndexedPropertyDescriptor) pd)
- .getIndexedReadMethod());
- assertNull(((IndexedPropertyDescriptor) pd)
- .getIndexedWriteMethod());
-
- }
- }
- }
-
- public class MixedSimpleClass32 {
-
- public Object getList() {
- return null;
- }
-
- public Object[] isList(int i) {
- return null;
- }
- }
-
- public void test_MixedSimpleClass32() throws Exception {
- BeanInfo info = Introspector.getBeanInfo(MixedSimpleClass32.class);
- Method getter = MixedSimpleClass32.class.getDeclaredMethod("getList");
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertFalse(pd instanceof IndexedPropertyDescriptor);
- assertEquals(getter, pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- }
- }
- }
-
- public class MixedSimpleClass33 {
-
- public Object isList() {
- return null;
- }
-
- public Object[] isList(int i) {
- return null;
- }
- }
-
- public void test_MixedSimpleClass33() throws Exception {
- BeanInfo info = Introspector.getBeanInfo(MixedSimpleClass33.class);
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- assertFalse(propertyName.equals(pd.getName()));
- }
- }
-
- public class MixedSimpleClass34 {
- public Object[] getList() {
- return null;
- }
-
- public Object[] getList(int index) {
- return null;
- }
- }
-
- public void test_MixedSimpleClass34() throws Exception {
- BeanInfo info = Introspector.getBeanInfo(MixedSimpleClass34.class);
- Method indexedGetter = MixedSimpleClass34.class.getDeclaredMethod(
- "getList", int.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertTrue(pd instanceof IndexedPropertyDescriptor);
- assertNull(pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- assertEquals(indexedGetter, ((IndexedPropertyDescriptor) pd)
- .getIndexedReadMethod());
- assertNull(((IndexedPropertyDescriptor) pd)
- .getIndexedWriteMethod());
-
- }
- }
- }
-
- public class MixedSimpleClass35 {
- public Object[] isList() {
- return null;
- }
-
- public Object[] getList(int index) {
- return null;
- }
- }
-
- public void test_MixedSimpleClass35() throws Exception {
- BeanInfo info = Introspector.getBeanInfo(MixedSimpleClass35.class);
- Method indexedGetter = MixedSimpleClass35.class.getDeclaredMethod(
- "getList", int.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertTrue(pd instanceof IndexedPropertyDescriptor);
- assertNull(pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- assertEquals(indexedGetter, ((IndexedPropertyDescriptor) pd)
- .getIndexedReadMethod());
- assertNull(((IndexedPropertyDescriptor) pd)
- .getIndexedWriteMethod());
-
- }
- }
- }
-
- public class MixedSimpleClass36 {
- public Object[] getList() {
- return null;
- }
-
- public Object[] isList(int index) {
- return null;
- }
- }
-
- public void test_MixedSimpleClass36() throws Exception {
- BeanInfo info = Introspector.getBeanInfo(MixedSimpleClass36.class);
- Method normalGetter = MixedSimpleClass36.class
- .getDeclaredMethod("getList");
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertFalse(pd instanceof IndexedPropertyDescriptor);
- assertEquals(normalGetter, pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- }
- }
- }
-
- public class MixedSimpleClass37 {
- public Object[] isList() {
- return null;
- }
-
- public Object[] isList(int index) {
- return null;
- }
- }
-
- public void test_MixedSimpleClass37() throws Exception {
- BeanInfo info = Introspector.getBeanInfo(MixedSimpleClass37.class);
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- assertFalse(propertyName.equals(pd.getName()));
- }
- }
-
- public class MixedSimpleClass38 {
- public Object[][] getList() {
- return null;
- }
-
- public Object[] getList(int index) {
- return null;
- }
- }
-
- public void test_MixedSimpleClass38() throws Exception {
- BeanInfo info = Introspector.getBeanInfo(MixedSimpleClass38.class);
- Method normalGetter = MixedSimpleClass38.class
- .getDeclaredMethod("getList");
- Method indexedGetter = MixedSimpleClass38.class.getDeclaredMethod(
- "getList", int.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertTrue(pd instanceof IndexedPropertyDescriptor);
- assertEquals(normalGetter, pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- assertEquals(indexedGetter, ((IndexedPropertyDescriptor) pd)
- .getIndexedReadMethod());
- assertNull(((IndexedPropertyDescriptor) pd)
- .getIndexedWriteMethod());
-
- }
- }
- }
-
- public class MixedSimpleClass39 {
- public boolean isList(int index) {
- return false;
- }
- }
-
- public void test_MixedSimpleClass39() throws Exception {
- BeanInfo info = Introspector.getBeanInfo(MixedSimpleClass39.class);
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- assertFalse(propertyName.equals(pd.getName()));
- }
- }
-
- public class MixedSimpleClass40 {
- public Object isList() {
- return null;
- }
- }
-
- public void test_MixedSimpleClass40() throws Exception {
- BeanInfo info = Introspector.getBeanInfo(MixedSimpleClass40.class);
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- assertFalse(propertyName.equals(pd.getName()));
- }
- }
-
- public class MixedSimpleClass41 {
- public Object getList() {
- return null;
- }
-
- public void setList(Object obj) {
- }
- }
-
- public void test_MixedSimpleClass41() throws Exception {
- BeanInfo info = Introspector.getBeanInfo(MixedSimpleClass41.class);
- Method getter = MixedSimpleClass41.class.getDeclaredMethod("getList");
- Method setter = MixedSimpleClass41.class.getDeclaredMethod("setList",
- Object.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertFalse(pd instanceof IndexedPropertyDescriptor);
- assertEquals(getter, pd.getReadMethod());
- assertEquals(setter, pd.getWriteMethod());
- }
- }
- }
-
- public class MixedSimpleClass42 {
- public Object isList() {
- return null;
- }
-
- public void setList(Object obj) {
- }
- }
-
- public void test_MixedSimpleClass42() throws Exception {
- BeanInfo info = Introspector.getBeanInfo(MixedSimpleClass42.class);
- Method setter = MixedSimpleClass42.class.getDeclaredMethod("setList",
- Object.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertFalse(pd instanceof IndexedPropertyDescriptor);
- assertNull(pd.getReadMethod());
- assertEquals(setter, pd.getWriteMethod());
- }
- }
- }
-
- public class MixedSimpleClass43 {
- public Object getList() {
- return null;
- }
- }
-
- public void test_MixedSimpleClass43() throws Exception {
- BeanInfo info = Introspector.getBeanInfo(MixedSimpleClass43.class);
- Method getter = MixedSimpleClass43.class.getDeclaredMethod("getList");
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertFalse(pd instanceof IndexedPropertyDescriptor);
- assertEquals(getter, pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- }
- }
- }
-
- public class MixedSimpleClass44 {
- public void setList(Object obj) {
-
- }
- }
-
- public void test_MixedSimpleClass44() throws Exception {
- BeanInfo info = Introspector.getBeanInfo(MixedSimpleClass44.class);
- Method setter = MixedSimpleClass44.class.getDeclaredMethod("setList",
- Object.class);
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertFalse(pd instanceof IndexedPropertyDescriptor);
- assertNull(pd.getReadMethod());
- assertEquals(setter, pd.getWriteMethod());
- }
- }
- }
-
- public class MixedSimpleClass45 {
- public boolean isList(int index) {
- return true;
- }
- }
-
- public void test_MixedSimpleClass45() throws Exception {
- BeanInfo beanInfo = Introspector.getBeanInfo(MixedSimpleClass45.class);
- assertEquals(1, beanInfo.getPropertyDescriptors().length);
- }
-
- public class MixedSimpleClass46 {
- public boolean getList() {
- return true;
- }
-
- public boolean isList(int index) {
- return true;
- }
- }
-
- public void test_MixedSimpleClass46() throws Exception {
- BeanInfo beanInfo = Introspector.getBeanInfo(MixedSimpleClass46.class);
- Method getter = MixedSimpleClass46.class.getMethod("getList",
- new Class<?>[] {});
- assertEquals(2, beanInfo.getPropertyDescriptors().length);
- for (PropertyDescriptor pd : beanInfo.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertEquals(getter, pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- assertFalse(pd instanceof IndexedPropertyDescriptor);
- }
- }
- }
-
- public class MixedSimpleClass47 {
- public boolean isList() {
- return true;
- }
-
- public boolean isList(int index) {
- return true;
- }
- }
-
- public void test_MixedSimpleClass47() throws Exception {
- BeanInfo beanInfo = Introspector.getBeanInfo(MixedSimpleClass47.class);
- Method getter = MixedSimpleClass47.class.getMethod("isList",
- new Class<?>[] {});
- assertEquals(2, beanInfo.getPropertyDescriptors().length);
- for (PropertyDescriptor pd : beanInfo.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertEquals(getter, pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- assertFalse(pd instanceof IndexedPropertyDescriptor);
- }
- }
- }
-
- public class MixedSimpleClass48 {
- public boolean getList(int index) {
- return true;
- }
-
- public boolean isList(int index) {
- return true;
- }
- }
-
- public void test_MixedSimpleClass48() throws Exception {
- BeanInfo beanInfo = Introspector.getBeanInfo(MixedSimpleClass48.class);
- Method getter = MixedSimpleClass48.class.getMethod("getList",
- new Class<?>[] { int.class });
- assertEquals(2, beanInfo.getPropertyDescriptors().length);
- for (PropertyDescriptor pd : beanInfo.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertNull(pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- assertTrue(pd instanceof IndexedPropertyDescriptor);
- assertEquals(getter,
- ((IndexedPropertyDescriptor) pd).getIndexedReadMethod());
- assertNull(((IndexedPropertyDescriptor) pd)
- .getIndexedWriteMethod());
- }
- }
- }
-
- public class MixedSimpleClass49 {
- public boolean isList(int index) {
- return true;
- }
-
- public void setList(boolean bool) {
- }
- }
-
- public void test_MixedSimpleClass49() throws Exception {
- BeanInfo beanInfo = Introspector.getBeanInfo(MixedSimpleClass49.class);
- Method setter = MixedSimpleClass49.class.getMethod("setList",
- new Class<?>[] { boolean.class });
- assertEquals(2, beanInfo.getPropertyDescriptors().length);
- for (PropertyDescriptor pd : beanInfo.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertNull(pd.getReadMethod());
- assertEquals(setter, pd.getWriteMethod());
- assertFalse(pd instanceof IndexedPropertyDescriptor);
- }
- }
- }
-
- public class MixedSimpleClass50 {
- public boolean isList(int index) {
- return true;
- }
-
- public void setList(int index, boolean bool) {
- }
- }
-
- public void test_MixedSimpleClass50() throws Exception {
- BeanInfo beanInfo = Introspector.getBeanInfo(MixedSimpleClass50.class);
- Method setter = MixedSimpleClass50.class.getMethod("setList",
- new Class<?>[] { int.class, boolean.class });
- assertEquals(2, beanInfo.getPropertyDescriptors().length);
- for (PropertyDescriptor pd : beanInfo.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertNull(pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- assertTrue(pd instanceof IndexedPropertyDescriptor);
- assertNull(((IndexedPropertyDescriptor) pd)
- .getIndexedReadMethod());
- assertEquals(setter,
- ((IndexedPropertyDescriptor) pd)
- .getIndexedWriteMethod());
- }
- }
- }
-
- public class MixedSimpleClass51 {
- public boolean getList() {
- return true;
- }
-
- public boolean isList(int index) {
- return true;
- }
-
- public void setList(boolean bool) {
- }
- }
-
- public void test_MixedSimpleClass51() throws Exception {
- BeanInfo beanInfo = Introspector.getBeanInfo(MixedSimpleClass51.class);
- Method getter = MixedSimpleClass51.class.getMethod("getList",
- new Class<?>[] {});
- Method setter = MixedSimpleClass51.class.getMethod("setList",
- new Class<?>[] { boolean.class });
- assertEquals(2, beanInfo.getPropertyDescriptors().length);
- for (PropertyDescriptor pd : beanInfo.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertEquals(getter, pd.getReadMethod());
- assertEquals(setter, pd.getWriteMethod());
- assertFalse(pd instanceof IndexedPropertyDescriptor);
- }
- }
- }
-
- public class MixedSimpleClass52 {
- public boolean getList() {
- return true;
- }
-
- public boolean isList(int index) {
- return true;
- }
-
- public void setList(int index, boolean bool) {
- }
- }
-
- public void test_MixedSimpleClass52() throws Exception {
- BeanInfo beanInfo = Introspector.getBeanInfo(MixedSimpleClass52.class);
- Method setter = MixedSimpleClass52.class.getMethod("setList",
- new Class<?>[] { int.class, boolean.class });
- assertEquals(2, beanInfo.getPropertyDescriptors().length);
- for (PropertyDescriptor pd : beanInfo.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertNull(pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- assertTrue(pd instanceof IndexedPropertyDescriptor);
- assertNull(((IndexedPropertyDescriptor) pd)
- .getIndexedReadMethod());
- assertEquals(setter,
- ((IndexedPropertyDescriptor) pd)
- .getIndexedWriteMethod());
- }
- }
- }
-
- public class MixedSimpleClass53 {
- public boolean isList() {
- return true;
- }
-
- public boolean isList(int index) {
- return true;
- }
-
- public void setList(boolean bool) {
- }
- }
-
- public void test_MixedSimpleClass53() throws Exception {
- BeanInfo beanInfo = Introspector.getBeanInfo(MixedSimpleClass53.class);
- Method getter = MixedSimpleClass53.class.getMethod("isList",
- new Class<?>[] {});
- Method setter = MixedSimpleClass53.class.getMethod("setList",
- new Class<?>[] { boolean.class });
- assertEquals(2, beanInfo.getPropertyDescriptors().length);
- for (PropertyDescriptor pd : beanInfo.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertEquals(getter, pd.getReadMethod());
- assertEquals(setter, pd.getWriteMethod());
- assertFalse(pd instanceof IndexedPropertyDescriptor);
- }
- }
- }
-
- public class MixedSimpleClass54 {
- public boolean isList() {
- return true;
- }
-
- public boolean isList(int index) {
- return true;
- }
-
- public void setList(int index, boolean bool) {
- }
- }
-
- public void test_MixedSimpleClass54() throws Exception {
- BeanInfo beanInfo = Introspector.getBeanInfo(MixedSimpleClass54.class);
- Method setter = MixedSimpleClass54.class.getMethod("setList",
- new Class<?>[] { int.class, boolean.class });
- assertEquals(2, beanInfo.getPropertyDescriptors().length);
- for (PropertyDescriptor pd : beanInfo.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertNull(pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- assertTrue(pd instanceof IndexedPropertyDescriptor);
- assertNull(((IndexedPropertyDescriptor) pd)
- .getIndexedReadMethod());
- assertEquals(setter,
- ((IndexedPropertyDescriptor) pd)
- .getIndexedWriteMethod());
- }
- }
- }
-
- public class MixedSimpleClass55 {
- public boolean getList(int index) {
- return true;
- }
-
- public boolean isList(int index) {
- return true;
- }
-
- public void setList(boolean bool) {
- }
- }
-
- public void test_MixedSimpleClass55() throws Exception {
- BeanInfo beanInfo = Introspector.getBeanInfo(MixedSimpleClass55.class);
- Method getter = MixedSimpleClass55.class.getMethod("getList",
- new Class<?>[] { int.class });
- for (PropertyDescriptor pd : beanInfo.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertNull(pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- assertTrue(pd instanceof IndexedPropertyDescriptor);
- assertEquals(getter,
- ((IndexedPropertyDescriptor) pd).getIndexedReadMethod());
- assertNull(((IndexedPropertyDescriptor) pd)
- .getIndexedWriteMethod());
- }
- }
- }
-
- public class MixedSimpleClass56 {
- public boolean getList(int index) {
- return true;
- }
-
- public boolean isList(int index) {
- return true;
- }
-
- public void setList(int index, boolean bool) {
- }
- }
-
- public void test_MixedSimpleClass56() throws Exception {
- BeanInfo beanInfo = Introspector.getBeanInfo(MixedSimpleClass56.class);
- Method getter = MixedSimpleClass56.class.getMethod("getList",
- new Class<?>[] { int.class });
- Method setter = MixedSimpleClass56.class.getMethod("setList",
- new Class<?>[] { int.class, boolean.class });
- assertEquals(2, beanInfo.getPropertyDescriptors().length);
- for (PropertyDescriptor pd : beanInfo.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertNull(pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- assertTrue(pd instanceof IndexedPropertyDescriptor);
- assertEquals(getter,
- ((IndexedPropertyDescriptor) pd).getIndexedReadMethod());
- assertEquals(setter,
- ((IndexedPropertyDescriptor) pd)
- .getIndexedWriteMethod());
- }
- }
- }
-
- public class MixedSimpleClass57 {
- public boolean isList(int index) {
- return true;
- }
-
- public void setList(boolean bool) {
-
- }
-
- public void setList(int index, boolean bool) {
- }
- }
-
- public void test_MixedSimpleClass57() throws Exception {
- BeanInfo beanInfo = Introspector.getBeanInfo(MixedSimpleClass57.class);
- Method setter = MixedSimpleClass57.class.getMethod("setList",
- new Class<?>[] { int.class, boolean.class });
- assertEquals(2, beanInfo.getPropertyDescriptors().length);
- for (PropertyDescriptor pd : beanInfo.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertNull(pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- assertTrue(pd instanceof IndexedPropertyDescriptor);
- assertNull(((IndexedPropertyDescriptor) pd)
- .getIndexedReadMethod());
- assertEquals(setter,
- ((IndexedPropertyDescriptor) pd)
- .getIndexedWriteMethod());
- }
- }
- }
-
- public class MixedSimpleClass58 {
- public boolean getList() {
- return true;
- }
-
- public boolean isList(int index) {
- return true;
- }
-
- public void setList(boolean bool) {
- }
-
- public void setList(int index, boolean bool) {
-
- }
- }
-
- public void test_MixedSimpleClass58() throws Exception {
- BeanInfo beanInfo = Introspector.getBeanInfo(MixedSimpleClass58.class);
- Method getter = MixedSimpleClass58.class.getMethod("getList",
- new Class<?>[] {});
- Method setter = MixedSimpleClass58.class.getMethod("setList",
- new Class<?>[] { boolean.class });
- assertEquals(2, beanInfo.getPropertyDescriptors().length);
- for (PropertyDescriptor pd : beanInfo.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertEquals(getter, pd.getReadMethod());
- assertEquals(setter, pd.getWriteMethod());
- assertFalse(pd instanceof IndexedPropertyDescriptor);
- }
- }
- }
-
- public class MixedSimpleClass59 {
- public boolean isList() {
- return true;
- }
-
- public boolean isList(int index) {
- return true;
- }
-
- public void setList(boolean bool) {
- }
-
- public void setList(int index, boolean bool) {
-
- }
- }
-
- public void test_MixedSimpleClass59() throws Exception {
- BeanInfo beanInfo = Introspector.getBeanInfo(MixedSimpleClass59.class);
- Method getter = MixedSimpleClass59.class.getMethod("isList",
- new Class<?>[] {});
- Method setter = MixedSimpleClass59.class.getMethod("setList",
- new Class<?>[] { boolean.class });
- assertEquals(2, beanInfo.getPropertyDescriptors().length);
- for (PropertyDescriptor pd : beanInfo.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertEquals(getter, pd.getReadMethod());
- assertEquals(setter, pd.getWriteMethod());
- assertFalse(pd instanceof IndexedPropertyDescriptor);
- }
- }
- }
-
- public class MixedSimpleClass60 {
- public boolean getList(int index) {
- return true;
- }
-
- public boolean isList(int index) {
- return true;
- }
-
- public void setList(boolean bool) {
- }
-
- public void setList(int index, boolean bool) {
-
- }
- }
-
- public void test_MixedSimpleClass60() throws Exception {
- BeanInfo beanInfo = Introspector.getBeanInfo(MixedSimpleClass60.class);
- Method getter = MixedSimpleClass60.class.getMethod("getList",
- new Class<?>[] { int.class });
- Method setter = MixedSimpleClass60.class.getMethod("setList",
- new Class<?>[] { int.class, boolean.class });
- assertEquals(2, beanInfo.getPropertyDescriptors().length);
- for (PropertyDescriptor pd : beanInfo.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertNull(pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- assertTrue(pd instanceof IndexedPropertyDescriptor);
- assertEquals(getter,
- ((IndexedPropertyDescriptor) pd).getIndexedReadMethod());
- assertEquals(setter,
- ((IndexedPropertyDescriptor) pd)
- .getIndexedWriteMethod());
- }
- }
- }
-
- public class MixedSimpleClass61 {
- public boolean getList() {
- return true;
- }
-
- public boolean getList(int index) {
- return true;
- }
-
- public boolean isList() {
- return true;
- }
-
- public boolean isList(int index) {
- return true;
- }
-
- public void setList(boolean bool) {
- }
-
- public void setList(int index, boolean bool) {
-
- }
- }
-
- public void test_MixedSimpleClass61() throws Exception {
- BeanInfo beanInfo = Introspector.getBeanInfo(MixedSimpleClass61.class);
- Method getter = MixedSimpleClass61.class.getMethod("getList",
- new Class<?>[] { int.class });
- Method setter = MixedSimpleClass61.class.getMethod("setList",
- new Class<?>[] { int.class, boolean.class });
- assertEquals(2, beanInfo.getPropertyDescriptors().length);
- for (PropertyDescriptor pd : beanInfo.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertNull(pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- assertTrue(pd instanceof IndexedPropertyDescriptor);
- assertEquals(getter,
- ((IndexedPropertyDescriptor) pd).getIndexedReadMethod());
- assertEquals(setter,
- ((IndexedPropertyDescriptor) pd)
- .getIndexedWriteMethod());
- }
- }
- }
-
- public class MixedExtendClass1 extends MixedSimpleClass4 {
- public void setList(Object a) {
-
- }
- }
-
- public void test_MixedExtendClass1() throws Exception {
- BeanInfo info = Introspector.getBeanInfo(MixedExtendClass1.class);
- Method getter = MixedSimpleClass4.class.getDeclaredMethod("getList");
- Method setter = MixedExtendClass1.class.getDeclaredMethod("setList",
- Object.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertFalse(pd instanceof IndexedPropertyDescriptor);
- assertEquals(getter, pd.getReadMethod());
- assertEquals(setter, pd.getWriteMethod());
- break;
- }
- }
- }
-
- public class MixedExtendClass2 extends MixedSimpleClass4 {
- public void setList(int index, Object a) {
-
- }
- }
-
- public void test_MixedExtendClass2() throws Exception {
- BeanInfo info = Introspector.getBeanInfo(MixedExtendClass2.class);
- Method getter = MixedSimpleClass4.class.getDeclaredMethod("getList",
- int.class);
- Method setter = MixedExtendClass2.class.getDeclaredMethod("setList",
- int.class, Object.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertTrue(pd instanceof IndexedPropertyDescriptor);
- assertNull(pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- assertEquals(getter, ((IndexedPropertyDescriptor) pd)
- .getIndexedReadMethod());
- assertEquals(setter, ((IndexedPropertyDescriptor) pd)
- .getIndexedWriteMethod());
- break;
- }
- }
- }
-
- public class MixedExtendClass3 extends MixedSimpleClass4 {
- public void setList(Object a) {
-
- }
-
- public void setList(int index, Object a) {
-
- }
- }
-
- public void test_MixedExtendClass3() throws Exception {
- BeanInfo info = Introspector.getBeanInfo(MixedExtendClass3.class);
- Method getter = MixedSimpleClass4.class.getDeclaredMethod("getList",
- int.class);
- Method setter = MixedExtendClass3.class.getDeclaredMethod("setList",
- int.class, Object.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertTrue(pd instanceof IndexedPropertyDescriptor);
- assertNull(pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- assertEquals(getter, ((IndexedPropertyDescriptor) pd)
- .getIndexedReadMethod());
- assertEquals(setter, ((IndexedPropertyDescriptor) pd)
- .getIndexedWriteMethod());
- break;
- }
- }
- }
-
- public class MixedExtendClass4 extends MixedSimpleClass4 {
- public Object getList() {
- return null;
- }
- }
-
- public void test_MixedExtendClass4() throws Exception {
- BeanInfo info = Introspector.getBeanInfo(MixedExtendClass4.class);
- Method getter = MixedExtendClass4.class.getDeclaredMethod("getList");
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertFalse(pd instanceof IndexedPropertyDescriptor);
- assertEquals(getter, pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- break;
- }
- }
- }
-
- public class MixedExtendClass5 extends MixedSimpleClass4 {
- public Object getList(int index) {
- return null;
- }
- }
-
- public void test_MixedExtendClass5() throws Exception {
- BeanInfo info = Introspector.getBeanInfo(MixedExtendClass5.class);
- Method getter = MixedExtendClass5.class.getDeclaredMethod("getList",
- int.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertTrue(pd instanceof IndexedPropertyDescriptor);
- assertNull(pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- assertEquals(getter, ((IndexedPropertyDescriptor) pd)
- .getIndexedReadMethod());
- assertNull(((IndexedPropertyDescriptor) pd)
- .getIndexedWriteMethod());
- break;
- }
- }
- }
-
- public class MixedExtendClass6 extends MixedSimpleClass25 {
- public Object getList() {
- return null;
- }
- }
-
- public void test_MixedExtendClass6() throws Exception {
- BeanInfo info = Introspector.getBeanInfo(MixedExtendClass6.class);
- Method getter = MixedExtendClass6.class.getDeclaredMethod("getList");
- Method setter = MixedSimpleClass25.class.getDeclaredMethod("setList",
- Object.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertFalse(pd instanceof IndexedPropertyDescriptor);
- assertEquals(getter, pd.getReadMethod());
- assertEquals(setter, pd.getWriteMethod());
- break;
- }
- }
- }
-
- public class MixedExtendClass7 extends MixedSimpleClass25 {
- public Object getList(int index) {
- return null;
- }
- }
-
- public void test_MixedExtendClass7() throws Exception {
- BeanInfo info = Introspector.getBeanInfo(MixedExtendClass7.class);
- Method getter = MixedExtendClass7.class.getDeclaredMethod("getList",
- int.class);
- Method setter = MixedSimpleClass25.class.getDeclaredMethod("setList",
- int.class, Object.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertTrue(pd instanceof IndexedPropertyDescriptor);
- assertNull(pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- assertEquals(getter, ((IndexedPropertyDescriptor) pd)
- .getIndexedReadMethod());
- assertEquals(setter, ((IndexedPropertyDescriptor) pd)
- .getIndexedWriteMethod());
- break;
- }
- }
- }
-
- public class MixedExtendClass8 extends MixedSimpleClass25 {
- public Object getList() {
- return null;
- }
-
- public Object getList(int index) {
- return null;
- }
- }
-
- public void test_MixedExtendClass8() throws Exception {
- BeanInfo info = Introspector.getBeanInfo(MixedExtendClass8.class);
- Method getter = MixedExtendClass8.class.getDeclaredMethod("getList",
- int.class);
- Method setter = MixedSimpleClass25.class.getDeclaredMethod("setList",
- int.class, Object.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertTrue(pd instanceof IndexedPropertyDescriptor);
- assertNull(pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- assertEquals(getter, ((IndexedPropertyDescriptor) pd)
- .getIndexedReadMethod());
- assertEquals(setter, ((IndexedPropertyDescriptor) pd)
- .getIndexedWriteMethod());
- break;
- }
- }
- }
-
- public class MixedExtendClass9 extends MixedSimpleClass25 {
- public void setList(Object obj) {
- }
- }
-
- public void test_MixedExtendClass9() throws Exception {
- BeanInfo info = Introspector.getBeanInfo(MixedExtendClass9.class);
- Method setter = MixedExtendClass9.class.getDeclaredMethod("setList",
- Object.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertFalse(pd instanceof IndexedPropertyDescriptor);
- assertNull(pd.getReadMethod());
- assertEquals(setter, pd.getWriteMethod());
- break;
- }
- }
- }
-
- public class MixedExtendClass10 extends MixedSimpleClass25 {
- public void setList(int index, Object obj) {
- }
- }
-
- public void test_MixedExtendClass10() throws Exception {
- BeanInfo info = Introspector.getBeanInfo(MixedExtendClass10.class);
- Method setter = MixedExtendClass10.class.getDeclaredMethod("setList",
- int.class, Object.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertTrue(pd instanceof IndexedPropertyDescriptor);
- assertNull(pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- assertNull(((IndexedPropertyDescriptor) pd)
- .getIndexedReadMethod());
- assertEquals(setter, ((IndexedPropertyDescriptor) pd)
- .getIndexedWriteMethod());
- break;
- }
- }
- }
-
- public class MixedExtendClass11 extends MixedSimpleClass41 {
- public void setList(String obj) {
- }
- }
-
- public void test_MixedExtendClass11() throws Exception {
- BeanInfo info = Introspector.getBeanInfo(MixedExtendClass11.class);
- Method getter = MixedSimpleClass41.class.getDeclaredMethod("getList");
- Method setter = MixedSimpleClass41.class.getDeclaredMethod("setList",
- Object.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertFalse(pd instanceof IndexedPropertyDescriptor);
- assertEquals(getter, pd.getReadMethod());
- assertEquals(setter, pd.getWriteMethod());
- }
- }
- }
-
- public class MixedExtendClass12 extends MixedSimpleClass41 {
- public String getList() {
- return null;
- }
- }
-
- public void test_MixedExtendClass12() throws Exception {
- BeanInfo info = Introspector.getBeanInfo(MixedExtendClass12.class);
- Method[] methods = MixedExtendClass12.class.getDeclaredMethods();
- Method getter = null;
- for (Method method : methods) {
- if (method.getName().equals("getList")
- && method.getReturnType() == Object.class
- && method.getParameterTypes().length == 0) {
- getter = method;
- break;
- }
- }
- Method setter = MixedSimpleClass41.class.getDeclaredMethod("setList",
- Object.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertFalse(pd instanceof IndexedPropertyDescriptor);
- assertEquals(getter, pd.getReadMethod());
- assertEquals(setter, pd.getWriteMethod());
- }
- }
- }
-
- public class MixedExtendClass13 extends MixedSimpleClass42 {
- public void setList(String obj) {
- }
- }
-
- public void test_MixedExtendClass13() throws Exception {
- BeanInfo info = Introspector.getBeanInfo(MixedExtendClass13.class);
- Method setter = MixedExtendClass13.class.getDeclaredMethod("setList",
- String.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertFalse(pd instanceof IndexedPropertyDescriptor);
- assertNull(pd.getReadMethod());
- assertEquals(setter, pd.getWriteMethod());
- }
- }
- }
-
- public class MixedExtendClass14 extends MixedSimpleClass43 {
- public String getList() {
- return null;
- }
- }
-
- public void test_MixedExtendClass14() throws Exception {
- BeanInfo info = Introspector.getBeanInfo(MixedExtendClass14.class);
- Method[] methods = MixedExtendClass14.class.getDeclaredMethods();
- Method getter = null;
- for (Method method : methods) {
- if (method.getName().equals("getList")
- && method.getReturnType() == Object.class
- && method.getParameterTypes().length == 0) {
- getter = method;
- break;
- }
- }
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertFalse(pd instanceof IndexedPropertyDescriptor);
- assertEquals(getter, pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- }
- }
- }
-
- public class MixedExtendClass15 extends MixedSimpleClass44 {
- public void setList(String obj) {
-
- }
- }
-
- public void test_MixedExtendClass15() throws Exception {
- BeanInfo info = Introspector.getBeanInfo(MixedExtendClass15.class);
- Method setter = MixedExtendClass15.class.getDeclaredMethod("setList",
- String.class);
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertFalse(pd instanceof IndexedPropertyDescriptor);
- assertNull(pd.getReadMethod());
- assertEquals(setter, pd.getWriteMethod());
- }
- }
- }
-
- public class MixedBooleanSimpleClass1 {
-
- public boolean isList(int index) {
- return false;
- }
-
- public boolean isList() {
- return false;
- }
- }
-
- public void test_MixedBooleanSimpleClass1() throws Exception {
- BeanInfo info = Introspector
- .getBeanInfo(MixedBooleanSimpleClass1.class);
- Method getter = MixedBooleanSimpleClass1.class
- .getDeclaredMethod("isList");
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertFalse(pd instanceof IndexedPropertyDescriptor);
- assertEquals(getter, pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- }
- }
- }
-
- public class MixedBooleanSimpleClass2 {
-
- public boolean isList(int index) {
- return false;
- }
-
- public boolean getList() {
- return false;
- }
-
- }
-
- public void test_MixedBooleanSimpleClass2() throws Exception {
- BeanInfo info = Introspector
- .getBeanInfo(MixedBooleanSimpleClass2.class);
- Method getter = MixedBooleanSimpleClass2.class
- .getDeclaredMethod("getList");
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertFalse(pd instanceof IndexedPropertyDescriptor);
- assertEquals(getter, pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- }
- }
- }
-
- public class MixedBooleanSimpleClass3 {
-
- public boolean getList(int index) {
- return false;
- }
-
- public boolean isList() {
- return false;
- }
-
- }
-
- public void test_MixedBooleanSimpleClass3() throws Exception {
- BeanInfo info = Introspector
- .getBeanInfo(MixedBooleanSimpleClass3.class);
- Method getter = MixedBooleanSimpleClass3.class.getDeclaredMethod(
- "getList", int.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertTrue(pd instanceof IndexedPropertyDescriptor);
- assertNull(pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- assertEquals(getter, ((IndexedPropertyDescriptor) pd)
- .getIndexedReadMethod());
- assertNull(((IndexedPropertyDescriptor) pd)
- .getIndexedWriteMethod());
- }
- }
- }
-
- public class MixedBooleanSimpleClass4 {
- public boolean getList(int index) {
- return false;
- }
-
- public boolean getList() {
- return false;
- }
- }
-
- public void test_MixedBooleanSimpleClass4() throws Exception {
- BeanInfo info = Introspector
- .getBeanInfo(MixedBooleanSimpleClass4.class);
- Method getter = MixedBooleanSimpleClass4.class.getDeclaredMethod(
- "getList", int.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertTrue(pd instanceof IndexedPropertyDescriptor);
- assertNull(pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- assertEquals(getter, ((IndexedPropertyDescriptor) pd)
- .getIndexedReadMethod());
- assertNull(((IndexedPropertyDescriptor) pd)
- .getIndexedWriteMethod());
- }
- }
- }
-
- public class MixedBooleanSimpleClass5 {
-
- public boolean isList(int index) {
- return false;
- }
-
- public boolean isList() {
- return false;
- }
-
- public void setList(boolean b) {
-
- }
-
- }
-
- public void test_MixedBooleanSimpleClass5() throws Exception {
- BeanInfo info = Introspector
- .getBeanInfo(MixedBooleanSimpleClass5.class);
- Method getter = MixedBooleanSimpleClass5.class
- .getDeclaredMethod("isList");
- Method setter = MixedBooleanSimpleClass5.class.getDeclaredMethod(
- "setList", boolean.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertFalse(pd instanceof IndexedPropertyDescriptor);
- assertEquals(getter, pd.getReadMethod());
- assertEquals(setter, pd.getWriteMethod());
- }
- }
- }
-
- public class MixedBooleanSimpleClass6 {
-
- public boolean isList(int index) {
- return false;
- }
-
- public boolean getList() {
- return false;
- }
-
- public void setList(boolean b) {
-
- }
-
- }
-
- public void test_MixedBooleanSimpleClass6() throws Exception {
- BeanInfo info = Introspector
- .getBeanInfo(MixedBooleanSimpleClass6.class);
- Method getter = MixedBooleanSimpleClass6.class
- .getDeclaredMethod("getList");
- Method setter = MixedBooleanSimpleClass6.class.getDeclaredMethod(
- "setList", boolean.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertFalse(pd instanceof IndexedPropertyDescriptor);
- assertEquals(getter, pd.getReadMethod());
- assertEquals(setter, pd.getWriteMethod());
- }
- }
- }
-
- public class MixedBooleanSimpleClass7 {
-
- public boolean getList(int index) {
- return false;
- }
-
- public boolean isList() {
- return false;
- }
-
- public void setList(boolean b) {
-
- }
-
- }
-
- public void test_MixedBooleanSimpleClass7() throws Exception {
- BeanInfo info = Introspector
- .getBeanInfo(MixedBooleanSimpleClass7.class);
- Method getter = MixedBooleanSimpleClass7.class
- .getDeclaredMethod("isList");
- Method setter = MixedBooleanSimpleClass7.class.getDeclaredMethod(
- "setList", boolean.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertFalse(pd instanceof IndexedPropertyDescriptor);
- assertEquals(getter, pd.getReadMethod());
- assertEquals(setter, pd.getWriteMethod());
- }
- }
- }
-
- public class MixedBooleanSimpleClass8 {
-
- public boolean getList(int index) {
- return false;
- }
-
- public boolean getList() {
- return false;
- }
-
- public void setList(boolean b) {
-
- }
-
- }
-
- public void test_MixedBooleanSimpleClass8() throws Exception {
- BeanInfo info = Introspector
- .getBeanInfo(MixedBooleanSimpleClass8.class);
- Method getter = MixedBooleanSimpleClass8.class
- .getDeclaredMethod("getList");
- Method setter = MixedBooleanSimpleClass8.class.getDeclaredMethod(
- "setList", boolean.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertFalse(pd instanceof IndexedPropertyDescriptor);
- assertEquals(getter, pd.getReadMethod());
- assertEquals(setter, pd.getWriteMethod());
- }
- }
- }
-
- public class MixedBooleanSimpleClass9 {
-
- public boolean getList(int index) {
- return false;
- }
-
- public boolean getList() {
- return false;
- }
-
- public void setList(int index, boolean b) {
-
- }
-
- }
-
- public void test_MixedBooleanSimpleClass9() throws Exception {
- BeanInfo info = Introspector
- .getBeanInfo(MixedBooleanSimpleClass9.class);
- Method getter = MixedBooleanSimpleClass9.class.getDeclaredMethod(
- "getList", int.class);
- Method setter = MixedBooleanSimpleClass9.class.getDeclaredMethod(
- "setList", int.class, boolean.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertTrue(pd instanceof IndexedPropertyDescriptor);
- assertNull(pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- assertEquals(getter, ((IndexedPropertyDescriptor) pd)
- .getIndexedReadMethod());
- assertEquals(setter, ((IndexedPropertyDescriptor) pd)
- .getIndexedWriteMethod());
- }
- }
- }
-
- public class MixedBooleanSimpleClass10 {
-
- public boolean getList(int index) {
- return false;
- }
-
- public boolean isList() {
- return false;
- }
-
- public void setList(int index, boolean b) {
-
- }
-
- }
-
- public void test_MixedBooleanSimpleClass10() throws Exception {
- BeanInfo info = Introspector
- .getBeanInfo(MixedBooleanSimpleClass10.class);
- Method getter = MixedBooleanSimpleClass10.class.getDeclaredMethod(
- "getList", int.class);
- Method setter = MixedBooleanSimpleClass10.class.getDeclaredMethod(
- "setList", int.class, boolean.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertTrue(pd instanceof IndexedPropertyDescriptor);
- assertNull(pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- assertEquals(getter, ((IndexedPropertyDescriptor) pd)
- .getIndexedReadMethod());
- assertEquals(setter, ((IndexedPropertyDescriptor) pd)
- .getIndexedWriteMethod());
- }
- }
- }
-
- public class MixedBooleanSimpleClass11 {
-
- public boolean isList(int index) {
- return false;
- }
-
- public boolean getList() {
- return false;
- }
-
- public void setList(int index, boolean b) {
-
- }
-
- }
-
- public void test_MixedBooleanSimpleClass11() throws Exception {
- BeanInfo info = Introspector
- .getBeanInfo(MixedBooleanSimpleClass11.class);
- Method setter = MixedBooleanSimpleClass11.class.getDeclaredMethod(
- "setList", int.class, boolean.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertTrue(pd instanceof IndexedPropertyDescriptor);
- assertNull(pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- assertNull(((IndexedPropertyDescriptor) pd)
- .getIndexedReadMethod());
- assertEquals(setter, ((IndexedPropertyDescriptor) pd)
- .getIndexedWriteMethod());
- }
- }
- }
-
- public class MixedBooleanSimpleClass12 {
-
- public boolean isList(int index) {
- return false;
- }
-
- public boolean isList() {
- return false;
- }
-
- public void setList(int index, boolean b) {
-
- }
-
- }
-
- public void test_MixedBooleanSimpleClass12() throws Exception {
- BeanInfo info = Introspector
- .getBeanInfo(MixedBooleanSimpleClass12.class);
- Method setter = MixedBooleanSimpleClass12.class.getDeclaredMethod(
- "setList", int.class, boolean.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertTrue(pd instanceof IndexedPropertyDescriptor);
- assertNull(pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- assertNull(((IndexedPropertyDescriptor) pd)
- .getIndexedReadMethod());
- assertEquals(setter, ((IndexedPropertyDescriptor) pd)
- .getIndexedWriteMethod());
- }
- }
- }
-
- public class MixedBooleanSimpleClass13 {
-
- public boolean isList(int index) {
- return false;
- }
-
- public boolean isList() {
- return false;
- }
-
- public void setList(boolean b) {
-
- }
-
- public void setList(int index, boolean b) {
-
- }
-
- }
-
- public void test_MixedBooleanSimpleClass13() throws Exception {
- BeanInfo info = Introspector
- .getBeanInfo(MixedBooleanSimpleClass13.class);
- Method getter = MixedBooleanSimpleClass13.class
- .getDeclaredMethod("isList");
- Method setter = MixedBooleanSimpleClass13.class.getDeclaredMethod(
- "setList", boolean.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertFalse(pd instanceof IndexedPropertyDescriptor);
- assertEquals(getter, pd.getReadMethod());
- assertEquals(setter, pd.getWriteMethod());
- }
- }
- }
-
- public class MixedBooleanSimpleClass14 {
-
- public boolean isList(int index) {
- return false;
- }
-
- public boolean getList() {
- return false;
- }
-
- public void setList(boolean b) {
-
- }
-
- public void setList(int index, boolean b) {
-
- }
- }
-
- public void test_MixedBooleanSimpleClass14() throws Exception {
- BeanInfo info = Introspector
- .getBeanInfo(MixedBooleanSimpleClass14.class);
- Method getter = MixedBooleanSimpleClass14.class
- .getDeclaredMethod("getList");
- Method setter = MixedBooleanSimpleClass14.class.getDeclaredMethod(
- "setList", boolean.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertFalse(pd instanceof IndexedPropertyDescriptor);
- assertEquals(getter, pd.getReadMethod());
- assertEquals(setter, pd.getWriteMethod());
- }
- }
- }
-
- public class MixedBooleanSimpleClass15 {
-
- public boolean getList(int index) {
- return false;
- }
-
- public boolean isList() {
- return false;
- }
-
- public void setList(boolean b) {
-
- }
-
- public void setList(int index, boolean b) {
-
- }
- }
-
- public void test_MixedBooleanSimpleClass15() throws Exception {
- BeanInfo info = Introspector
- .getBeanInfo(MixedBooleanSimpleClass15.class);
- Method getter = MixedBooleanSimpleClass15.class.getDeclaredMethod(
- "getList", int.class);
- Method setter = MixedBooleanSimpleClass15.class.getDeclaredMethod(
- "setList", int.class, boolean.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertTrue(pd instanceof IndexedPropertyDescriptor);
- assertNull(pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- assertEquals(getter, ((IndexedPropertyDescriptor) pd)
- .getIndexedReadMethod());
- assertEquals(setter, ((IndexedPropertyDescriptor) pd)
- .getIndexedWriteMethod());
- }
- }
- }
-
- public class MixedBooleanSimpleClass16 {
-
- public boolean getList(int index) {
- return false;
- }
-
- public boolean getList() {
- return false;
- }
-
- public void setList(boolean b) {
-
- }
-
- public void setList(int index, boolean b) {
-
- }
- }
-
- public void test_MixedBooleanSimpleClass16() throws Exception {
- BeanInfo info = Introspector
- .getBeanInfo(MixedBooleanSimpleClass16.class);
- Method getter = MixedBooleanSimpleClass16.class.getDeclaredMethod(
- "getList", int.class);
- Method setter = MixedBooleanSimpleClass16.class.getDeclaredMethod(
- "setList", int.class, boolean.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertTrue(pd instanceof IndexedPropertyDescriptor);
- assertNull(pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- assertEquals(getter, ((IndexedPropertyDescriptor) pd)
- .getIndexedReadMethod());
- assertEquals(setter, ((IndexedPropertyDescriptor) pd)
- .getIndexedWriteMethod());
- }
- }
- }
-
- public class MixedBooleanSimpleClass17 {
- public boolean getList() {
- return false;
- }
-
- public void setList(int index, boolean obj) {
-
- }
-
- public void setList(boolean obj) {
-
- }
- }
-
- public void test_MixedBooleanSimpleClass17() throws Exception {
- BeanInfo info = Introspector
- .getBeanInfo(MixedBooleanSimpleClass17.class);
- Method getter = MixedBooleanSimpleClass17.class
- .getDeclaredMethod("getList");
- Method setter = MixedBooleanSimpleClass17.class.getDeclaredMethod(
- "setList", boolean.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertFalse(pd instanceof IndexedPropertyDescriptor);
- assertEquals(getter, pd.getReadMethod());
- assertEquals(setter, pd.getWriteMethod());
- }
- }
- }
-
- public class MixedBooleanSimpleClass18 {
- public boolean isList() {
- return false;
- }
-
- public void setList(int index, boolean obj) {
-
- }
-
- public void setList(boolean obj) {
-
- }
- }
-
- public void test_MixedBooleanSimpleClass18() throws Exception {
- BeanInfo info = Introspector
- .getBeanInfo(MixedBooleanSimpleClass18.class);
- Method getter = MixedBooleanSimpleClass18.class
- .getDeclaredMethod("isList");
- Method setter = MixedBooleanSimpleClass18.class.getDeclaredMethod(
- "setList", boolean.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertFalse(pd instanceof IndexedPropertyDescriptor);
- assertEquals(getter, pd.getReadMethod());
- assertEquals(setter, pd.getWriteMethod());
- }
- }
- }
-
- public class MixedBooleanSimpleClass19 {
-
- public boolean getList(int index) {
- return false;
- }
-
- public void setList(boolean obj) {
-
- }
-
- public void setList(int index, boolean obj) {
-
- }
- }
-
- public void test_MixedBooleanSimpleClass19() throws Exception {
- BeanInfo info = Introspector
- .getBeanInfo(MixedBooleanSimpleClass19.class);
- Method getter = MixedBooleanSimpleClass19.class.getDeclaredMethod(
- "getList", int.class);
- Method setter = MixedBooleanSimpleClass19.class.getDeclaredMethod(
- "setList", int.class, boolean.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertTrue(pd instanceof IndexedPropertyDescriptor);
- assertNull(pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- assertEquals(getter, ((IndexedPropertyDescriptor) pd)
- .getIndexedReadMethod());
- assertEquals(setter, ((IndexedPropertyDescriptor) pd)
- .getIndexedWriteMethod());
- }
- }
- }
-
- public class MixedBooleanSimpleClass20 {
- public boolean isList(int index) {
- return false;
- }
-
- public void setList(boolean obj) {
-
- }
-
- public void setList(int index, boolean obj) {
-
- }
- }
-
- public void test_MixedBooleanSimpleClass20() throws Exception {
- BeanInfo info = Introspector
- .getBeanInfo(MixedBooleanSimpleClass20.class);
- Method setter = MixedBooleanSimpleClass20.class.getDeclaredMethod(
- "setList", int.class, boolean.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertTrue(pd instanceof IndexedPropertyDescriptor);
- assertNull(pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- assertNull(((IndexedPropertyDescriptor) pd)
- .getIndexedReadMethod());
- assertEquals(setter, ((IndexedPropertyDescriptor) pd)
- .getIndexedWriteMethod());
- }
- }
- }
-
- public class MixedBooleanSimpleClass21 {
- public boolean getList(int index) {
- return false;
- }
-
- public void setList(boolean obj) {
- }
- }
-
- public void test_MixedBooleanSimpleClass21() throws Exception {
- BeanInfo info = Introspector
- .getBeanInfo(MixedBooleanSimpleClass21.class);
- Method getter = MixedBooleanSimpleClass21.class.getDeclaredMethod(
- "getList", int.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertTrue(pd instanceof IndexedPropertyDescriptor);
- assertNull(pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- assertEquals(getter, ((IndexedPropertyDescriptor) pd)
- .getIndexedReadMethod());
- assertNull(((IndexedPropertyDescriptor) pd)
- .getIndexedWriteMethod());
- }
- }
- }
-
- public class MixedBooleanSimpleClass22 {
- public boolean isList(int index) {
- return false;
- }
-
- public void setList(boolean obj) {
- }
- }
-
- public void test_MixedBooleanSimpleClass22() throws Exception {
- BeanInfo info = Introspector
- .getBeanInfo(MixedBooleanSimpleClass22.class);
- Method setter = MixedBooleanSimpleClass22.class.getDeclaredMethod(
- "setList", boolean.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertFalse(pd instanceof IndexedPropertyDescriptor);
- assertNull(pd.getReadMethod());
- assertEquals(setter, pd.getWriteMethod());
- }
- }
- }
-
- public class MixedBooleanSimpleClass23 {
- public boolean getList() {
- return false;
- }
-
- public void setList(int index, boolean obj) {
- }
- }
-
- public void test_MixedBooleanSimpleClass23() throws Exception {
- BeanInfo info = Introspector
- .getBeanInfo(MixedBooleanSimpleClass23.class);
- Method setter = MixedBooleanSimpleClass23.class.getDeclaredMethod(
- "setList", int.class, boolean.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertTrue(pd instanceof IndexedPropertyDescriptor);
- assertNull(pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- assertNull(((IndexedPropertyDescriptor) pd)
- .getIndexedReadMethod());
- assertEquals(setter, ((IndexedPropertyDescriptor) pd)
- .getIndexedWriteMethod());
- }
- }
- }
-
- public class MixedBooleanSimpleClass24 {
- public boolean isList() {
- return false;
- }
-
- public void setList(int index, boolean obj) {
- }
- }
-
- public void test_MixedBooleanSimpleClass24() throws Exception {
- BeanInfo info = Introspector
- .getBeanInfo(MixedBooleanSimpleClass24.class);
- Method setter = MixedBooleanSimpleClass24.class.getDeclaredMethod(
- "setList", int.class, boolean.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertTrue(pd instanceof IndexedPropertyDescriptor);
- assertNull(pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- assertNull(((IndexedPropertyDescriptor) pd)
- .getIndexedReadMethod());
- assertEquals(setter, ((IndexedPropertyDescriptor) pd)
- .getIndexedWriteMethod());
- }
- }
- }
-
- public class MixedBooleanSimpleClass25 {
- public void setList(boolean obj) {
-
- }
-
- public void setList(int index, boolean obj) {
-
- }
- }
-
- public void test_MixedBooleanSimpleClass25() throws Exception {
- BeanInfo info = Introspector
- .getBeanInfo(MixedBooleanSimpleClass25.class);
- Method setter = MixedBooleanSimpleClass25.class.getDeclaredMethod(
- "setList", int.class, boolean.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertTrue(pd instanceof IndexedPropertyDescriptor);
- assertNull(pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- assertNull(((IndexedPropertyDescriptor) pd)
- .getIndexedReadMethod());
- assertEquals(setter, ((IndexedPropertyDescriptor) pd)
- .getIndexedWriteMethod());
- }
- }
- }
-
- public class MixedBooleanSimpleClass26 {
-
- public boolean[] getList() {
- return null;
- }
-
- public boolean getList(int i) {
- return false;
- }
- }
-
- public void test_MixedBooleanSimpleClass26() throws Exception {
- BeanInfo info = Introspector
- .getBeanInfo(MixedBooleanSimpleClass26.class);
- Method normalGetter = MixedBooleanSimpleClass26.class
- .getDeclaredMethod("getList");
- Method indexedGetter = MixedBooleanSimpleClass26.class
- .getDeclaredMethod("getList", int.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertTrue(pd instanceof IndexedPropertyDescriptor);
- assertEquals(normalGetter, pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- assertEquals(indexedGetter, ((IndexedPropertyDescriptor) pd)
- .getIndexedReadMethod());
- assertNull(((IndexedPropertyDescriptor) pd)
- .getIndexedWriteMethod());
-
- }
- }
- }
-
- public class MixedBooleanSimpleClass27 {
-
- public boolean[] isList() {
- return null;
- }
-
- public boolean getList(int i) {
- return false;
- }
- }
-
- public void test_MixedBooleanSimpleClass27() throws Exception {
- BeanInfo info = Introspector
- .getBeanInfo(MixedBooleanSimpleClass27.class);
- Method indexedGetter = MixedBooleanSimpleClass27.class
- .getDeclaredMethod("getList", int.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertTrue(pd instanceof IndexedPropertyDescriptor);
- assertNull(pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- assertEquals(indexedGetter, ((IndexedPropertyDescriptor) pd)
- .getIndexedReadMethod());
- assertNull(((IndexedPropertyDescriptor) pd)
- .getIndexedWriteMethod());
-
- }
- }
- }
-
- public class MixedBooleanSimpleClass28 {
-
- public boolean[] getList() {
- return null;
- }
-
- public boolean isList(int i) {
- return false;
- }
- }
-
- public void test_MixedBooleanSimpleClass28() throws Exception {
- BeanInfo info = Introspector
- .getBeanInfo(MixedBooleanSimpleClass28.class);
- Method getter = MixedBooleanSimpleClass28.class
- .getDeclaredMethod("getList");
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertFalse(pd instanceof IndexedPropertyDescriptor);
- assertEquals(getter, pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- }
- }
- }
-
- public class MixedBooleanSimpleClass29 {
-
- public boolean[] isList() {
- return null;
- }
-
- public boolean isList(int i) {
- return false;
- }
- }
-
- public void test_MixedBooleanSimpleClass29() throws Exception {
- BeanInfo info = Introspector
- .getBeanInfo(MixedBooleanSimpleClass29.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- assertFalse(propertyName.equals(pd.getName()));
- }
- }
-
- public class MixedBooleanSimpleClass30 {
-
- public boolean getList() {
- return false;
- }
-
- public boolean[] getList(int i) {
- return null;
- }
- }
-
- public void test_MixedBooleanSimpleClass30() throws Exception {
- BeanInfo info = Introspector
- .getBeanInfo(MixedBooleanSimpleClass30.class);
- Method indexedGetter = MixedBooleanSimpleClass30.class
- .getDeclaredMethod("getList", int.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertTrue(pd instanceof IndexedPropertyDescriptor);
- assertNull(pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- assertEquals(indexedGetter, ((IndexedPropertyDescriptor) pd)
- .getIndexedReadMethod());
- assertNull(((IndexedPropertyDescriptor) pd)
- .getIndexedWriteMethod());
-
- }
- }
- }
-
- public class MixedBooleanSimpleClass31 {
-
- public boolean isList() {
- return false;
- }
-
- public boolean[] getList(int i) {
- return null;
- }
- }
-
- public void test_MixedBooleanSimpleClass31() throws Exception {
- BeanInfo info = Introspector
- .getBeanInfo(MixedBooleanSimpleClass31.class);
- Method indexedGetter = MixedBooleanSimpleClass31.class
- .getDeclaredMethod("getList", int.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertTrue(pd instanceof IndexedPropertyDescriptor);
- assertNull(pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- assertEquals(indexedGetter, ((IndexedPropertyDescriptor) pd)
- .getIndexedReadMethod());
- assertNull(((IndexedPropertyDescriptor) pd)
- .getIndexedWriteMethod());
-
- }
- }
- }
-
- public class MixedBooleanSimpleClass32 {
-
- public boolean getList() {
- return false;
- }
-
- public boolean[] isList(int i) {
- return null;
- }
- }
-
- public void test_MixedBooleanSimpleClass32() throws Exception {
- BeanInfo info = Introspector
- .getBeanInfo(MixedBooleanSimpleClass32.class);
- Method getter = MixedBooleanSimpleClass32.class
- .getDeclaredMethod("getList");
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertFalse(pd instanceof IndexedPropertyDescriptor);
- assertEquals(getter, pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- }
- }
- }
-
- public class MixedBooleanSimpleClass33 {
-
- public boolean isList() {
- return false;
- }
-
- public boolean[] isList(int i) {
- return null;
- }
- }
-
- public void test_MixedBooleanSimpleClass33() throws Exception {
- BeanInfo info = Introspector
- .getBeanInfo(MixedBooleanSimpleClass33.class);
- Method getter = MixedBooleanSimpleClass33.class
- .getDeclaredMethod("isList");
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertFalse(pd instanceof IndexedPropertyDescriptor);
- assertEquals(getter, pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- }
- }
- }
-
- public class MixedBooleanSimpleClass34 {
- public boolean[] getList() {
- return null;
- }
-
- public boolean[] getList(int index) {
- return null;
- }
- }
-
- public void test_MixedBooleanSimpleClass34() throws Exception {
- BeanInfo info = Introspector
- .getBeanInfo(MixedBooleanSimpleClass34.class);
- Method indexedGetter = MixedBooleanSimpleClass34.class
- .getDeclaredMethod("getList", int.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertTrue(pd instanceof IndexedPropertyDescriptor);
- assertNull(pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- assertEquals(indexedGetter, ((IndexedPropertyDescriptor) pd)
- .getIndexedReadMethod());
- assertNull(((IndexedPropertyDescriptor) pd)
- .getIndexedWriteMethod());
-
- }
- }
- }
-
- public class MixedBooleanSimpleClass35 {
- public boolean[] isList() {
- return null;
- }
-
- public boolean[] getList(int index) {
- return null;
- }
- }
-
- public void test_MixedBooleanSimpleClass35() throws Exception {
- BeanInfo info = Introspector
- .getBeanInfo(MixedBooleanSimpleClass35.class);
- Method indexedGetter = MixedBooleanSimpleClass35.class
- .getDeclaredMethod("getList", int.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertTrue(pd instanceof IndexedPropertyDescriptor);
- assertNull(pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- assertEquals(indexedGetter, ((IndexedPropertyDescriptor) pd)
- .getIndexedReadMethod());
- assertNull(((IndexedPropertyDescriptor) pd)
- .getIndexedWriteMethod());
-
- }
- }
- }
-
- public class MixedBooleanSimpleClass36 {
- public boolean[] getList() {
- return null;
- }
-
- public boolean[] isList(int index) {
- return null;
- }
- }
-
- public void test_MixedBooleanSimpleClass36() throws Exception {
- BeanInfo info = Introspector
- .getBeanInfo(MixedBooleanSimpleClass36.class);
- Method normalGetter = MixedBooleanSimpleClass36.class
- .getDeclaredMethod("getList");
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertFalse(pd instanceof IndexedPropertyDescriptor);
- assertEquals(normalGetter, pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- }
- }
- }
-
- public class MixedBooleanSimpleClass37 {
- public boolean[] isList() {
- return null;
- }
-
- public boolean[] isList(int index) {
- return null;
- }
- }
-
- public void test_MixedBooleanSimpleClass37() throws Exception {
- BeanInfo info = Introspector
- .getBeanInfo(MixedBooleanSimpleClass37.class);
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- assertFalse(propertyName.equals(pd.getName()));
- }
- }
-
- public class MixedBooleanSimpleClass38 {
- public boolean[][] getList() {
- return null;
- }
-
- public boolean[] getList(int index) {
- return null;
- }
- }
-
- public void test_MixedBooleanSimpleClass38() throws Exception {
- BeanInfo info = Introspector
- .getBeanInfo(MixedBooleanSimpleClass38.class);
- Method normalGetter = MixedBooleanSimpleClass38.class
- .getDeclaredMethod("getList");
- Method indexedGetter = MixedBooleanSimpleClass38.class
- .getDeclaredMethod("getList", int.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertTrue(pd instanceof IndexedPropertyDescriptor);
- assertEquals(normalGetter, pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- assertEquals(indexedGetter, ((IndexedPropertyDescriptor) pd)
- .getIndexedReadMethod());
- assertNull(((IndexedPropertyDescriptor) pd)
- .getIndexedWriteMethod());
-
- }
- }
- }
-
- public class MixedBooleanSimpleClass39 {
- public void setList(boolean a) {
-
- }
- }
-
- public void test_MixedBooleanSimpleClass39() throws Exception {
- BeanInfo info = Introspector
- .getBeanInfo(MixedBooleanSimpleClass39.class);
- Method setter = MixedBooleanSimpleClass39.class.getDeclaredMethod(
- "setList", boolean.class);
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertFalse(pd instanceof IndexedPropertyDescriptor);
- assertNull(pd.getReadMethod());
- assertEquals(setter, pd.getWriteMethod());
- break;
- }
- }
- }
-
- public class MixedBooleanSimpleClass40 {
- public void setList(int index, boolean a) {
-
- }
- }
-
- public void test_MixedBooleanSimpleClass40() throws Exception {
- BeanInfo info = Introspector
- .getBeanInfo(MixedBooleanSimpleClass40.class);
- Method setter = MixedBooleanSimpleClass40.class.getDeclaredMethod(
- "setList", int.class, boolean.class);
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertTrue(pd instanceof IndexedPropertyDescriptor);
- assertNull(pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- assertNull(((IndexedPropertyDescriptor) pd)
- .getIndexedReadMethod());
- assertEquals(setter, ((IndexedPropertyDescriptor) pd)
- .getIndexedWriteMethod());
- break;
- }
- }
- }
-
- public class MixedBooleanSimpleClass41 {
- public boolean getList() {
- return false;
- }
-
- public void setList(boolean bool) {
- }
- }
-
- public void test_MixedBooleanSimpleClass41() throws Exception {
- BeanInfo info = Introspector
- .getBeanInfo(MixedBooleanSimpleClass41.class);
- Method getter = MixedBooleanSimpleClass41.class
- .getDeclaredMethod("getList");
- Method setter = MixedBooleanSimpleClass41.class.getDeclaredMethod(
- "setList", boolean.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertFalse(pd instanceof IndexedPropertyDescriptor);
- assertEquals(getter, pd.getReadMethod());
- assertEquals(setter, pd.getWriteMethod());
- }
- }
- }
-
- public class MixedBooleanSimpleClass42 {
- public boolean isList() {
- return false;
- }
-
- public void setList(boolean bool) {
- }
- }
-
- public void test_MixedBooleanSimpleClass42() throws Exception {
- BeanInfo info = Introspector
- .getBeanInfo(MixedBooleanSimpleClass42.class);
- Method getter = MixedBooleanSimpleClass42.class
- .getDeclaredMethod("isList");
- Method setter = MixedBooleanSimpleClass42.class.getDeclaredMethod(
- "setList", boolean.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertFalse(pd instanceof IndexedPropertyDescriptor);
- assertEquals(getter, pd.getReadMethod());
- assertEquals(setter, pd.getWriteMethod());
- }
- }
- }
-
- public class MixedBooleanSimpleClass43 {
- public boolean isList() {
- return false;
- }
- }
-
- public void test_MixedBooleanSimpleClass43() throws Exception {
- BeanInfo info = Introspector
- .getBeanInfo(MixedBooleanSimpleClass43.class);
- Method getter = MixedBooleanSimpleClass43.class
- .getDeclaredMethod("isList");
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertFalse(pd instanceof IndexedPropertyDescriptor);
- assertEquals(getter, pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- }
- }
- }
-
- public class MixedBooleanExtendClass1 extends MixedBooleanSimpleClass1 {
- public void setList(boolean a) {
-
- }
- }
-
- public void test_MixedBooleanExtendClass1() throws Exception {
- BeanInfo info = Introspector
- .getBeanInfo(MixedBooleanExtendClass1.class);
- Method getter = MixedBooleanSimpleClass1.class
- .getDeclaredMethod("isList");
- Method setter = MixedBooleanExtendClass1.class.getDeclaredMethod(
- "setList", boolean.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertFalse(pd instanceof IndexedPropertyDescriptor);
- assertEquals(getter, pd.getReadMethod());
- assertEquals(setter, pd.getWriteMethod());
- break;
- }
- }
- }
-
- public class MixedBooleanExtendClass2 extends MixedBooleanSimpleClass1 {
- public void setList(int index, boolean a) {
-
- }
- }
-
- public void test_MixedBooleanExtendClass2() throws Exception {
- BeanInfo info = Introspector
- .getBeanInfo(MixedBooleanExtendClass2.class);
- Method setter = MixedBooleanExtendClass2.class.getDeclaredMethod(
- "setList", int.class, boolean.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertTrue(pd instanceof IndexedPropertyDescriptor);
- assertNull(pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- assertNull(((IndexedPropertyDescriptor) pd)
- .getIndexedReadMethod());
- assertEquals(setter, ((IndexedPropertyDescriptor) pd)
- .getIndexedWriteMethod());
- break;
- }
- }
- }
-
- public class MixedBooleanExtendClass3 extends MixedBooleanSimpleClass1 {
- public void setList(boolean a) {
-
- }
-
- public void setList(int index, boolean a) {
-
- }
- }
-
- public void test_MixedBooleanExtendClass3() throws Exception {
- BeanInfo info = Introspector
- .getBeanInfo(MixedBooleanExtendClass3.class);
- Method getter = MixedBooleanSimpleClass1.class
- .getDeclaredMethod("isList");
- Method setter = MixedBooleanExtendClass3.class.getDeclaredMethod(
- "setList", boolean.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertFalse(pd instanceof IndexedPropertyDescriptor);
- assertEquals(getter, pd.getReadMethod());
- assertEquals(setter, pd.getWriteMethod());
- break;
- }
- }
- }
-
- public class MixedBooleanExtendClass4 extends MixedBooleanSimpleClass1 {
- public boolean isList() {
- return false;
- }
- }
-
- public void test_MixedBooleanExtendClass4() throws Exception {
- BeanInfo info = Introspector
- .getBeanInfo(MixedBooleanExtendClass4.class);
- Method getter = MixedBooleanSimpleClass1.class
- .getDeclaredMethod("isList");
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertFalse(pd instanceof IndexedPropertyDescriptor);
- assertEquals(getter, pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- break;
- }
- }
- }
-
- public class MixedBooleanExtendClass5 extends MixedBooleanSimpleClass1 {
- public boolean isList(int index) {
- return false;
- }
- }
-
- public void test_MixedBooleanExtendClass5() throws Exception {
- BeanInfo info = Introspector
- .getBeanInfo(MixedBooleanExtendClass5.class);
- Method getter = MixedBooleanSimpleClass1.class
- .getDeclaredMethod("isList");
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertFalse(pd instanceof IndexedPropertyDescriptor);
- assertEquals(getter, pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- break;
- }
- }
- }
-
- public class MixedBooleanExtendClass6 extends MixedBooleanSimpleClass25 {
- public boolean isList() {
- return false;
- }
- }
-
- public void test_MixedBooleanExtendClass6() throws Exception {
- BeanInfo info = Introspector
- .getBeanInfo(MixedBooleanExtendClass6.class);
- Method getter = MixedBooleanExtendClass6.class
- .getDeclaredMethod("isList");
- Method setter = MixedBooleanSimpleClass25.class.getDeclaredMethod(
- "setList", boolean.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertFalse(pd instanceof IndexedPropertyDescriptor);
- assertEquals(getter, pd.getReadMethod());
- assertEquals(setter, pd.getWriteMethod());
- break;
- }
- }
- }
-
- public class MixedBooleanExtendClass7 extends MixedBooleanSimpleClass25 {
- public boolean isList(int index) {
- return false;
- }
- }
-
- public void test_MixedBooleanExtendClass7() throws Exception {
- BeanInfo info = Introspector
- .getBeanInfo(MixedBooleanExtendClass7.class);
- Method setter = MixedBooleanSimpleClass25.class.getDeclaredMethod(
- "setList", int.class, boolean.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertTrue(pd instanceof IndexedPropertyDescriptor);
- assertNull(pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- assertNull(((IndexedPropertyDescriptor) pd)
- .getIndexedReadMethod());
- assertEquals(setter, ((IndexedPropertyDescriptor) pd)
- .getIndexedWriteMethod());
- break;
- }
- }
- }
-
- public class MixedBooleanExtendClass8 extends MixedBooleanSimpleClass25 {
- public boolean isList() {
- return false;
- }
-
- public boolean isList(int index) {
- return false;
- }
- }
-
- public void test_MixedBooleanExtendClass8() throws Exception {
- BeanInfo info = Introspector
- .getBeanInfo(MixedBooleanExtendClass8.class);
- Method getter = MixedBooleanExtendClass8.class
- .getDeclaredMethod("isList");
- Method setter = MixedBooleanSimpleClass25.class.getDeclaredMethod(
- "setList", boolean.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertFalse(pd instanceof IndexedPropertyDescriptor);
- assertEquals(getter, pd.getReadMethod());
- assertEquals(setter, pd.getWriteMethod());
- break;
- }
- }
- }
-
- public class MixedBooleanExtendClass9 extends MixedBooleanSimpleClass25 {
- public void setList(boolean obj) {
- }
- }
-
- public void test_MixedBooleanExtendClass9() throws Exception {
- BeanInfo info = Introspector
- .getBeanInfo(MixedBooleanExtendClass9.class);
- Method setter = MixedBooleanExtendClass9.class.getDeclaredMethod(
- "setList", boolean.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertFalse(pd instanceof IndexedPropertyDescriptor);
- assertNull(pd.getReadMethod());
- assertEquals(setter, pd.getWriteMethod());
- break;
- }
- }
- }
-
- public class MixedBooleanExtendClass10 extends MixedBooleanSimpleClass25 {
- public void setList(int index, boolean obj) {
- }
- }
-
- public void test_MixedBooleanExtendClass10() throws Exception {
- BeanInfo info = Introspector
- .getBeanInfo(MixedBooleanExtendClass10.class);
- Method setter = MixedBooleanExtendClass10.class.getDeclaredMethod(
- "setList", int.class, boolean.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertTrue(pd instanceof IndexedPropertyDescriptor);
- assertNull(pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- assertNull(((IndexedPropertyDescriptor) pd)
- .getIndexedReadMethod());
- assertEquals(setter, ((IndexedPropertyDescriptor) pd)
- .getIndexedWriteMethod());
- break;
- }
- }
- }
-
- public class MixedBooleanExtendClass11 extends MixedBooleanSimpleClass41 {
- public void setList(Object obj) {
-
- }
- }
-
- public void test_MixedBooleanExtendClass11() throws Exception {
- BeanInfo info = Introspector
- .getBeanInfo(MixedBooleanExtendClass11.class);
- Method getter = MixedBooleanSimpleClass41.class
- .getDeclaredMethod("getList");
- Method setter = MixedBooleanSimpleClass41.class.getDeclaredMethod(
- "setList", boolean.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertFalse(pd instanceof IndexedPropertyDescriptor);
- assertEquals(getter, pd.getReadMethod());
- assertEquals(setter, pd.getWriteMethod());
- }
- }
- }
-
- public class MixedBooleanExtendClass12 extends MixedBooleanSimpleClass41 {
- public void setList(Boolean obj) {
-
- }
- }
-
- public void test_MixedBooleanExtendClass12() throws Exception {
- BeanInfo info = Introspector
- .getBeanInfo(MixedBooleanExtendClass12.class);
- Method getter = MixedBooleanSimpleClass41.class
- .getDeclaredMethod("getList");
- Method setter = MixedBooleanSimpleClass41.class.getDeclaredMethod(
- "setList", boolean.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertFalse(pd instanceof IndexedPropertyDescriptor);
- assertEquals(getter, pd.getReadMethod());
- assertEquals(setter, pd.getWriteMethod());
- }
- }
- }
-
- public class MixedBooleanExtendClass13 extends MixedBooleanSimpleClass42 {
- public void setList(Object obj) {
-
- }
- }
-
- public void test_MixedBooleanExtendClass13() throws Exception {
- BeanInfo info = Introspector
- .getBeanInfo(MixedBooleanExtendClass13.class);
- Method getter = MixedBooleanSimpleClass42.class
- .getDeclaredMethod("isList");
- Method setter = MixedBooleanSimpleClass42.class.getDeclaredMethod(
- "setList", boolean.class);
-
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertFalse(pd instanceof IndexedPropertyDescriptor);
- assertEquals(getter, pd.getReadMethod());
- assertEquals(setter, pd.getWriteMethod());
- }
- }
- }
-
- public class MixedBooleanExtendClass14 extends MixedBooleanSimpleClass43 {
- public boolean isList() {
- return false;
- }
- }
-
- public void test_MixedBooleanExtendClass14() throws Exception {
- BeanInfo info = Introspector
- .getBeanInfo(MixedBooleanExtendClass14.class);
- Method getter = MixedBooleanSimpleClass43.class
- .getDeclaredMethod("isList");
- for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
- if (propertyName.equals(pd.getName())) {
- assertFalse(pd instanceof IndexedPropertyDescriptor);
- assertEquals(getter, pd.getReadMethod());
- assertNull(pd.getWriteMethod());
- }
- }
- }
- /*
- * Introspector Mixed Testing End
- */
-
-}
diff --git a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/MethodDescriptorTest.java b/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/MethodDescriptorTest.java
deleted file mode 100644
index 0c5e0f0..0000000
--- a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/MethodDescriptorTest.java
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- * 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.java.beans;
-
-import java.beans.MethodDescriptor;
-import java.beans.ParameterDescriptor;
-import java.lang.reflect.Method;
-
-import junit.framework.TestCase;
-
-import org.apache.harmony.beans.tests.support.mock.MockJavaBean;
-
-/**
- * Unit test for MethodDescriptor
- */
-public class MethodDescriptorTest extends TestCase {
-
- /*
- * @see TestCase#setUp()
- */
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- }
-
- /*
- * @see TestCase#tearDown()
- */
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-
- /*
- * Class under test for void MethodDescriptor(Method)
- */
- public void testMethodDescriptorMethod() throws SecurityException,
- NoSuchMethodException {
- String beanName = "MethodDescriptorTest.bean";
- MockJavaBean bean = new MockJavaBean(beanName);
- Method method = bean.getClass()
- .getMethod("getBeanName", (Class[]) null);
- MethodDescriptor md = new MethodDescriptor(method);
-
- assertSame(method, md.getMethod());
- assertNull(md.getParameterDescriptors());
-
- assertEquals(method.getName(), md.getDisplayName());
- assertEquals(method.getName(), md.getName());
- assertEquals(method.getName(), md.getShortDescription());
-
- assertNotNull(md.attributeNames());
-
- assertFalse(md.isExpert());
- assertFalse(md.isHidden());
- assertFalse(md.isPreferred());
- }
-
- public void testMethodDescriptorMethod_Null() {
- Method method = null;
- try {
- new MethodDescriptor(method);
- fail("Should throw NullPointerException.");
- } catch (NullPointerException e) {
- }
-
- }
-
- /*
- * Class under test for void MethodDescriptor(Method, ParameterDescriptor[])
- */
- public void testMethodDescriptorMethodParameterDescriptorArray()
- throws SecurityException, NoSuchMethodException {
- String beanName = "MethodDescriptorTest.bean";
- MockJavaBean bean = new MockJavaBean(beanName);
- Method method = bean.getClass().getMethod("setPropertyOne",
- new Class[] { String.class });
- ParameterDescriptor[] pds = new ParameterDescriptor[1];
- pds[0] = new ParameterDescriptor();
- pds[0].setValue(method.getName(), method.getReturnType());
- MethodDescriptor md = new MethodDescriptor(method, pds);
-
- assertSame(method, md.getMethod());
- assertSame(pds, md.getParameterDescriptors());
- assertEquals(pds[0].getValue(method.getName()), md
- .getParameterDescriptors()[0].getValue(method.getName()));
-
- assertEquals(method.getName(), md.getDisplayName());
- assertEquals(method.getName(), md.getName());
- assertEquals(method.getName(), md.getShortDescription());
-
- assertNotNull(md.attributeNames());
-
- assertFalse(md.isExpert());
- assertFalse(md.isHidden());
- assertFalse(md.isPreferred());
- }
-
- public void testMethodDescriptorMethodParameterDescriptorArray_MethodNull() {
- Method method = null;
- ParameterDescriptor[] pds = new ParameterDescriptor[1];
- pds[0] = new ParameterDescriptor();
- try {
- new MethodDescriptor(method, pds);
- fail("Should throw NullPointerException.");
- } catch (NullPointerException e) {
- }
- }
-
- public void testMethodDescriptorMethodParameterDescriptorArray_PDNull()
- throws SecurityException, NoSuchMethodException {
- String beanName = "MethodDescriptorTest.bean";
- MockJavaBean bean = new MockJavaBean(beanName);
- Method method = bean.getClass().getMethod("setPropertyOne",
- new Class[] { String.class });
- MethodDescriptor md = new MethodDescriptor(method, null);
-
- assertSame(method, md.getMethod());
- assertNull(md.getParameterDescriptors());
-
- assertEquals(method.getName(), md.getDisplayName());
- assertEquals(method.getName(), md.getName());
- assertEquals(method.getName(), md.getShortDescription());
-
- assertNotNull(md.attributeNames());
-
- assertFalse(md.isExpert());
- assertFalse(md.isHidden());
- assertFalse(md.isPreferred());
- }
-
- /**
- * @tests java.beans.MethodDescriptor#MethodDescriptor(
- * java.lang.reflect.Method)
- */
- public void test_Ctor1_NullPointerException() {
- try {
- // Regression for HARMONY-226
- new MethodDescriptor(null);
- fail("No expected NullPointerException");
- } catch (NullPointerException e) {
- }
- }
-
- /**
- * @tests java.beans.MethodDescriptor#MethodDescriptor(
- * java.lang.reflect.Method, java.beans.ParameterDescriptor[])
- */
- public void test_Ctor2_NullPointerException() {
- try {
- // Regression for HARMONY-226
- new MethodDescriptor(null, new ParameterDescriptor[0]);
- fail("No expected NullPointerException");
- } catch (NullPointerException e) {
- }
- }
-}
diff --git a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/ParameterDescriptorTest.java b/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/ParameterDescriptorTest.java
deleted file mode 100644
index f6ab082..0000000
--- a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/ParameterDescriptorTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * 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.java.beans;
-
-import java.beans.ParameterDescriptor;
-
-import junit.framework.TestCase;
-
-/**
- * Unit test for ParameterDescriptor.
- */
-public class ParameterDescriptorTest extends TestCase {
-
- public void testParameterDescriptor() {
- ParameterDescriptor pd = new ParameterDescriptor();
- assertNull(pd.getDisplayName());
- assertNull(pd.getName());
- assertNull(pd.getShortDescription());
-
- assertNotNull(pd.attributeNames());
-
- assertFalse(pd.isExpert());
- assertFalse(pd.isHidden());
- assertFalse(pd.isPreferred());
- }
-
-}
diff --git a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PersistenceDelegateTest.java b/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PersistenceDelegateTest.java
deleted file mode 100644
index 77778d5..0000000
--- a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PersistenceDelegateTest.java
+++ /dev/null
@@ -1,1479 +0,0 @@
-/*
- * 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.java.beans;
-
-import java.awt.*;
-import java.awt.event.*;
-import java.awt.font.TextAttribute;
-import java.awt.dnd.DropTarget;
-import java.beans.*;
-import java.beans.beancontext.BeanContextSupport;
-import java.io.*;
-import java.lang.reflect.*;
-import java.util.*;
-
-import javax.swing.*;
-import javax.swing.plaf.basic.BasicComboBoxUI;
-import javax.swing.plaf.basic.BasicComboBoxUI.ListDataHandler;
-import javax.swing.tree.DefaultMutableTreeNode;
-
-import junit.framework.TestCase;
-
-import org.apache.harmony.beans.tests.support.mock.MockFoo;
-import org.apache.harmony.beans.tests.support.mock.MockFooStop;
-
-/**
- * Test java.beans.PersistenceDelegate
- */
-public class PersistenceDelegateTest extends TestCase {
-
- /*
- * Test the constructor.
- */
- public void testConstructor() {
- new DummyPersistenceDelegate();
- }
-
- /*
- * Tests writeObject() under normal condition when mutatesTo() returns True.
- */
- public void testWriteObject_NormalMutatesToTrue() {
- MockPersistenceDelegate2 pd = new MockPersistenceDelegate2(true);
- MockEncoder2 enc = new MockEncoder2();
- MockFoo foo = new MockFoo();
-
- pd.writeObject(foo, enc);
-
- assertEquals("initialize", pd.popMethod());
- assertEquals("mutatesTo", pd.popMethod());
- }
-
- /*
- * Tests writeObject() under normal condition when mutatesTo() returns
- * false.
- */
- public void testWriteObject_NormalMutatesToFalse() {
- MockPersistenceDelegate2 pd = new MockPersistenceDelegate2(false);
- MockEncoder2 enc = new MockEncoder2();
- MockFoo foo = new MockFoo();
-
- pd.writeObject(foo, enc);
-
- assertEquals("instantiate", pd.popMethod());
- assertEquals("mutatesTo", pd.popMethod());
- assertWasAdded(MockFoo.class.getClass(), "new", null, enc);
- }
-
- /*
- * Tests writeObject() when object is null.
- */
- public void testWriteObject_NullObject() {
- MockPersistenceDelegate2 pd = new MockPersistenceDelegate2();
- Encoder enc = new Encoder();
-
- try {
- pd.writeObject(null, enc);
- fail("Should throw NullPointerException!");
- } catch (NullPointerException ex) {
- // expected
- }
- }
-
- /*
- * Tests writeObject() when encoder is null.
- */
- public void testWriteObject_NullEncoder() {
- MockPersistenceDelegate2 pd = new MockPersistenceDelegate2();
-
- try {
- pd.writeObject(new MockFoo(), null);
- fail("Should throw NullPointerException!");
- } catch (NullPointerException ex) {
- // expected
- }
- }
-
- /*
- * Tests initialize() under normal conditions.
- */
- public void testInitialize_Normal() {
- DummyPersistenceDelegate pd = new DummyPersistenceDelegate();
- MockPersistenceDelegate3 pd3 = new MockPersistenceDelegate3();
- Encoder enc = new Encoder();
-
- enc.setPersistenceDelegate(MockFooStop.class, pd3);
- pd.initialize(MockFoo.class, new MockFoo(), new MockFoo(), enc);
- assertEquals("initialize", pd3.popMethod());
- assertFalse("Extra statement has been detected", pd3.hasMoreMethods());
-
- // test interface
- pd3 = new MockPersistenceDelegate3();
- enc.setPersistenceDelegate(MockInterface.class, pd3);
- pd
- .initialize(MockObject.class, new MockObject(),
- new MockObject(), enc);
- assertFalse("Extra statement has been detected", pd3.hasMoreMethods());
- }
-
- /*
- * Tests initialize() with null class.
- */
- public void testInitialize_NullClass() {
- DummyPersistenceDelegate pd = new DummyPersistenceDelegate();
- Encoder enc = new Encoder();
-
- enc.setPersistenceDelegate(MockFooStop.class,
- new DummyPersistenceDelegate());
-
- try {
- pd.initialize(null, new Object(), new Object(), enc);
- fail("Should throw NullPointerException!");
- } catch (NullPointerException ex) {
- // expected
- }
- }
-
- /*
- * Tests initialize() with null old and new instances.
- */
- public void testInitialize_NullInstances() {
- DummyPersistenceDelegate pd = new DummyPersistenceDelegate();
- MockPersistenceDelegate3 pd3 = new MockPersistenceDelegate3();
- Encoder enc = new Encoder();
-
- enc.setPersistenceDelegate(MockFooStop.class, pd3);
- pd.initialize(MockFoo.class, null, null, enc);
- assertEquals("initialize", pd3.popMethod());
- }
-
- /*
- * Tests initialize() with null encoder.
- */
- public void testInitialize_NullEncoder() {
- DummyPersistenceDelegate pd = new DummyPersistenceDelegate();
-
- try {
- pd.initialize(MockFoo.class, new Object(), new Object(), null);
- fail("Should throw NullPointerException!");
- } catch (NullPointerException ex) {
- // expected
- }
- }
-
- /**
- * Circular redundancy check. Should not hang. Regression test for
- * HARMONY-2073
- */
- public void testInitialize_circularRedundancy() {
- Encoder enc = new Encoder();
- DummyPersistenceDelegate pd = new DummyPersistenceDelegate();
-
- enc.setPersistenceDelegate(MockFooStop.class, pd);
- pd.initialize(MockFoo.class, new MockFoo(), new MockFoo(), enc);
- }
-
- /*
- * Tests mutatesTo() under normal conditions.
- */
- public void testMutatesTo_Normal() {
- DummyPersistenceDelegate pd = new DummyPersistenceDelegate();
- assertTrue(pd.mutatesTo("test1", "test2"));
- assertFalse(pd.mutatesTo(new Object(), new Object() {
- @Override
- public int hashCode() {
- return super.hashCode();
- }
- }));
- assertFalse(pd.mutatesTo(new MockFoo(), new MockFooStop()));
- }
-
- /*
- * Tests mutatesTo() with null parameters.
- */
- public void testMutatesTo_Null() {
- DummyPersistenceDelegate pd = new DummyPersistenceDelegate();
-
- assertFalse(pd.mutatesTo("test", null));
- assertFalse(pd.mutatesTo(null, null));
- assertFalse(pd.mutatesTo(null, "test"));
- }
-
- public void test_writeObject_LInteger_LXMLEncoder() {
- ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
- XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(
- byteArrayOutputStream));
-
- encoder.writeObject(1);
- encoder.writeObject(Integer.SIZE);
- encoder.writeObject(Integer.MAX_VALUE);
- encoder.writeObject(Integer.MIN_VALUE);
- encoder.close();
-
- DataInputStream stream = new DataInputStream(new ByteArrayInputStream(
- byteArrayOutputStream.toByteArray()));
- XMLDecoder decoder = new XMLDecoder(stream);
- Integer one = (Integer) decoder.readObject();
- Integer size = (Integer) decoder.readObject();
- Integer max = (Integer) decoder.readObject();
- Integer min = (Integer) decoder.readObject();
- assertEquals(new Integer(1), one);
- assertEquals(new Integer(Integer.SIZE), size);
- assertEquals(new Integer(Integer.MAX_VALUE), max);
- assertEquals(new Integer(Integer.MIN_VALUE), min);
-
- stream = new DataInputStream(
- PersistenceDelegateTest.class
- .getResourceAsStream("/xml/Integer.xml"));
- decoder = new XMLDecoder(stream);
- one = (Integer) decoder.readObject();
- size = (Integer) decoder.readObject();
- max = (Integer) decoder.readObject();
- min = (Integer) decoder.readObject();
- assertEquals(new Integer(1), one);
- assertEquals(new Integer(Integer.SIZE), size);
- assertEquals(new Integer(Integer.MAX_VALUE), max);
- assertEquals(new Integer(Integer.MIN_VALUE), min);
- }
-
- public void test_writeObject_Null_LXMLEncoder() throws Exception {
- ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
- XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(
- byteArrayOutputStream));
- encoder.writeObject(null);
- encoder.close();
-
- DataInputStream stream = new DataInputStream(new ByteArrayInputStream(
- byteArrayOutputStream.toByteArray()));
- XMLDecoder decoder = new XMLDecoder(stream);
- assertNull(decoder.readObject());
- stream = new DataInputStream(PersistenceDelegateTest.class
- .getResourceAsStream("/xml/null.xml"));
- decoder = new XMLDecoder(stream);
- assertNull(decoder.readObject());
- }
-
- public void test_writeObject_LArray_LXMLEncoder() {
- ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
- XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(
- byteArrayOutputStream));
- int[] intArray = new int[2];
- intArray[0] = 1;
-
- encoder.writeObject(intArray);
- encoder.close();
-
- DataInputStream stream = new DataInputStream(new ByteArrayInputStream(
- byteArrayOutputStream.toByteArray()));
-
- XMLDecoder decoder = new XMLDecoder(stream);
- int[] array = (int[]) decoder.readObject();
- assertEquals(2, array.length);
- assertEquals(1, array[0]);
-
- stream = new DataInputStream(PersistenceDelegateTest.class
- .getResourceAsStream("/xml/Array.xml"));
-
- decoder = new XMLDecoder(stream);
- array = (int[]) decoder.readObject();
- assertEquals(2, array.length);
- assertEquals(1, array[0]);
- }
-
- public static interface Foo {
- void say();
- String toString();
- };
-
- public void test_writeObject_Ljava_Lang_reflect_Proxy() {
- InvocationHandler handler = new InvocationHandler() {
-
- public Object invoke(Object proxy, Method method, Object[] params)
- throws Throwable {
- if(method.getName().contains("toString")) {
- return "FooProxy";
- }
- System.out.println(method.getName());
- return null;
- }
-
- };
- Foo f = (Foo) Proxy.newProxyInstance(Foo.class.getClassLoader(),
- new Class[] { Foo.class }, handler);
- ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
- XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(
- byteArrayOutputStream));
-
- encoder.writeObject(f);
- encoder.close();
-
- DataInputStream stream = new DataInputStream(new ByteArrayInputStream(
- byteArrayOutputStream.toByteArray()));
-
- XMLDecoder decoder = new XMLDecoder(stream);
- try {
- decoder.readObject();
- fail("Should throw Exception");
- } catch (Exception ex) {
- // expected
- }
-
- stream = new DataInputStream(PersistenceDelegateTest.class
- .getResourceAsStream("/xml/Proxy.xml"));
-
- decoder = new XMLDecoder(stream);
- try {
- decoder.readObject();
- fail("Should throw Exception");
- } catch (Exception ex) {
- // expected
- }
- }
-
- public void test_writeObject_java_lang_string(){
- ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
- XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(
- byteArrayOutputStream));
-
- encoder.writeObject("test");
- encoder.close();
- DataInputStream stream = new DataInputStream(new ByteArrayInputStream(
- byteArrayOutputStream.toByteArray()));
- XMLDecoder decoder = new XMLDecoder(stream);
- Object object = decoder.readObject();
- assertEquals("test", object);
- }
-
- public void test_writeObject_java_lang_class(){
- ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
- XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(
- byteArrayOutputStream));
-
- encoder.writeObject(Class.class);
- encoder.writeObject(2);
- encoder.close();
- DataInputStream stream = new DataInputStream(new ByteArrayInputStream(
- byteArrayOutputStream.toByteArray()));
- XMLDecoder decoder = new XMLDecoder(stream);
- Class clz = (Class) decoder.readObject();
- assertEquals(Class.class, clz);
- Integer number = (Integer) decoder.readObject();
- assertEquals(new Integer(2), number);
- }
-
- class Bar {
- public int value;
-
- public void barTalk() {
- System.out.println("Bar is coming!");
- }
- }
-
- public void test_writeObject_java_lang_reflect_Field()
- throws SecurityException, NoSuchFieldException {
- ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
- XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(
- byteArrayOutputStream));
- Field value = Bar.class.getField("value");
- encoder.writeObject(value);
- encoder.close();
-
- DataInputStream stream = new DataInputStream(new ByteArrayInputStream(
- byteArrayOutputStream.toByteArray()));
-
- XMLDecoder decoder = new XMLDecoder(stream);
- Field field = (Field) decoder.readObject();
-
- assertEquals(value, field);
- assertEquals(value.getName(), field.getName());
- }
-
- public void test_writeObject_java_lang_reflect_Method()
- throws SecurityException, NoSuchMethodException {
- ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
- XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(
- byteArrayOutputStream));
- Method method = Bar.class.getMethod("barTalk", (Class[]) null);
-
- encoder.writeObject(method);
- encoder.close();
- DataInputStream stream = new DataInputStream(new ByteArrayInputStream(
- byteArrayOutputStream.toByteArray()));
- XMLDecoder decoder = new XMLDecoder(stream);
- Method aMethod = (Method) decoder.readObject();
- assertEquals(method, aMethod);
- assertEquals(method.getName(), aMethod.getName());
- assertEquals("barTalk", aMethod.getName());
- }
-
- @SuppressWarnings("unchecked")
- public void test_writeObject_java_util_Collection() {
- ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
- XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(
- byteArrayOutputStream));
- LinkedList<Integer> list = new LinkedList<Integer>();
- list.add(10);
- list.addFirst(2);
-
- encoder.writeObject(list);
- encoder.close();
- DataInputStream stream = new DataInputStream(new ByteArrayInputStream(
- byteArrayOutputStream.toByteArray()));
- XMLDecoder decoder = new XMLDecoder(stream);
- LinkedList<Integer> l = (LinkedList<Integer>) decoder.readObject();
- assertEquals(list, l);
- assertEquals(2, l.size());
- assertEquals(new Integer(10), l.get(1));
-
- }
-
- public void test_writeObject_java_awt_Choice() {
- ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
- XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(
- byteArrayOutputStream));
- Choice choice = new Choice();
- choice.setBackground(Color.blue);
- choice.setFocusTraversalKeysEnabled(true);
- choice.setBounds(0, 0, 10, 10);
- choice.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
- choice.setCursor(new Cursor(Cursor.WAIT_CURSOR));
- choice.setFocusTraversalKeysEnabled(true);
- choice.setFocusable(true);
- choice.setFont(new Font("Arial Bold", Font.ITALIC, 0));
- choice.setForeground(Color.green);
- choice.setIgnoreRepaint(true);
- choice.setLocation(1, 2);
- choice.setName("choice");
- choice.setSize(new Dimension(200, 100));
- choice.addItem("addItem");
- choice.add("add");
-
- ComponentListener cl = new ComponentAdapter() {
- };
- choice.addComponentListener(cl);
- FocusListener fl = new FocusAdapter() {
- };
- choice.addFocusListener(fl);
- HierarchyBoundsListener hbl = new HierarchyBoundsAdapter() {
- };
- choice.addHierarchyBoundsListener(hbl);
- HierarchyListener hl = new HierarchyListener() {
- public void hierarchyChanged(HierarchyEvent e) {
- }
- };
- choice.addHierarchyListener(hl);
- InputMethodListener il = new InputMethodListener() {
- public void caretPositionChanged(InputMethodEvent e) {
- }
-
- public void inputMethodTextChanged(InputMethodEvent e) {
- }
- };
- choice.addInputMethodListener(il);
- ItemListener il2 = new ItemListener() {
- public void itemStateChanged(ItemEvent e) {
- }
- };
- choice.addItemListener(il2);
- KeyListener kl = new KeyAdapter() {
- };
- choice.addKeyListener(kl);
- MouseListener ml = new MouseAdapter() {
- };
- choice.addMouseListener(ml);
- MouseMotionListener mml = new MouseMotionAdapter() {
- };
- choice.addMouseMotionListener(mml);
- MouseWheelListener mwl = new MouseWheelListener() {
- public void mouseWheelMoved(MouseWheelEvent e) {
- }
- };
- choice.addMouseWheelListener(mwl);
- PropertyChangeListener pcl = new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent event) {
- }
- };
- choice.addPropertyChangeListener(pcl);
-
- encoder.writeObject(choice);
- encoder.close();
- DataInputStream stream = new DataInputStream(new ByteArrayInputStream(
- byteArrayOutputStream.toByteArray()));
- XMLDecoder decoder = new XMLDecoder(stream);
- Choice aChoice = (Choice) decoder.readObject();
- assertEquals(choice.getFocusTraversalKeysEnabled(), aChoice
- .getFocusTraversalKeysEnabled());
- assertEquals(Color.blue, aChoice.getBackground());
- assertEquals(new Rectangle(1, 2, 200, 100), aChoice.getBounds());
- // ComponentOrientation is not persistent
- assertTrue(aChoice.getComponentOrientation().isLeftToRight());
-
- // Cursor will not be persisted
- assertEquals(Cursor.DEFAULT_CURSOR, aChoice.getCursor().getType());
- // DropTarget will not be persisted
- assertNull(aChoice.getDropTarget());
-
- assertEquals(choice.getName(), aChoice.getName());
-
- assertEquals(choice.getItem(0), aChoice.getItem(0));
- assertEquals(1, choice.getComponentListeners().length);
- assertEquals(0, aChoice.getComponentListeners().length);
- assertEquals(1, choice.getFocusListeners().length);
- assertEquals(0, aChoice.getFocusListeners().length);
- assertEquals(1, choice.getHierarchyBoundsListeners().length);
- assertEquals(0, aChoice.getHierarchyBoundsListeners().length);
- assertEquals(1, choice.getInputMethodListeners().length);
- assertEquals(0, aChoice.getInputMethodListeners().length);
- assertEquals(1, choice.getItemListeners().length);
- assertEquals(0, aChoice.getItemListeners().length);
- assertEquals(1, choice.getKeyListeners().length);
- assertEquals(0, aChoice.getKeyListeners().length);
- assertEquals(1, choice.getMouseListeners().length);
- assertEquals(0, aChoice.getMouseListeners().length);
- assertEquals(1, choice.getMouseMotionListeners().length);
- assertEquals(0, aChoice.getMouseMotionListeners().length);
- assertEquals(1, choice.getMouseWheelListeners().length);
- assertEquals(0, aChoice.getMouseWheelListeners().length);
- assertEquals(1, choice.getPropertyChangeListeners().length);
- assertEquals(0, aChoice.getPropertyChangeListeners().length);
-
- stream = new DataInputStream(PersistenceDelegateTest.class
- .getResourceAsStream("/xml/Choice.xml"));
-
- decoder = new XMLDecoder(stream);
- aChoice = (Choice) decoder.readObject();
- assertEquals(choice.getFocusTraversalKeysEnabled(), aChoice
- .getFocusTraversalKeysEnabled());
- assertEquals(Color.blue, aChoice.getBackground());
- assertEquals(new Rectangle(1, 2, 200, 100), aChoice.getBounds());
- // ComponentOrientation is not persistent
- assertTrue(aChoice.getComponentOrientation().isLeftToRight());
-
- // Cursor will not be persisted
- assertEquals(Cursor.DEFAULT_CURSOR, aChoice.getCursor().getType());
- // DropTarget will not be persisted
- assertNull(aChoice.getDropTarget());
-
- assertEquals(choice.getName(), aChoice.getName());
-
- assertEquals(choice.getItem(0), aChoice.getItem(0));
- }
-
-
- public void test_writeObject_java_util_HashTable(){
- ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
- XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(
- byteArrayOutputStream));
-
- Hashtable<Integer, String> hTable = new Hashtable<Integer, String>();
- hTable.put(1, "1");
-
- encoder.writeObject(hTable);
- encoder.close();
- DataInputStream stream = new DataInputStream(new ByteArrayInputStream(
- byteArrayOutputStream.toByteArray()));
- XMLDecoder decoder = new XMLDecoder(stream);
- Hashtable aHtable = (Hashtable) decoder.readObject();
- assertEquals(hTable.size(), aHtable.size());
- assertEquals(hTable.get(1), aHtable.get(1));
- }
-
- public void test_writeObject_java_beans_beancontext_BeanContextSupport() throws PropertyVetoException{
- ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
- XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(
- byteArrayOutputStream));
- BeanContextSupport support = new BeanContextSupport();
-
- encoder.writeObject(support);
- encoder.close();
- DataInputStream stream = new DataInputStream(new ByteArrayInputStream(
- byteArrayOutputStream.toByteArray()));
- XMLDecoder decoder = new XMLDecoder(stream);
- BeanContextSupport aSupport = (BeanContextSupport) decoder.readObject();
- assertEquals(Locale.getDefault(), aSupport.getLocale());
- }
-
- public void test_writeObject_java_awt_SystemColor() {
- ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
- XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(
- byteArrayOutputStream));
-
- encoder.writeObject(SystemColor.activeCaption);
- encoder.close();
- DataInputStream stream = new DataInputStream(new ByteArrayInputStream(
- byteArrayOutputStream.toByteArray()));
- XMLDecoder decoder = new XMLDecoder(stream);
- SystemColor color = (SystemColor) decoder.readObject();
- assertEquals(SystemColor.activeCaption, color);
- }
-
- public void test_writeObject_java_awt_font_TextAttribute() {
- ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
- XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(
- byteArrayOutputStream));
-
- encoder.writeObject(TextAttribute.BACKGROUND);
- encoder.close();
- DataInputStream stream = new DataInputStream(new ByteArrayInputStream(
- byteArrayOutputStream.toByteArray()));
- XMLDecoder decoder = new XMLDecoder(stream);
- TextAttribute attribute = (TextAttribute) decoder.readObject();
- assertEquals(TextAttribute.BACKGROUND, attribute);
- }
-
- public void test_writeObject_java_awt_MenuShortcut() {
- ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
- XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(
- byteArrayOutputStream));
- MenuShortcut shortCut = new MenuShortcut(2);
-
- encoder.writeObject(shortCut);
- encoder.close();
- DataInputStream stream = new DataInputStream(new ByteArrayInputStream(
- byteArrayOutputStream.toByteArray()));
- XMLDecoder decoder = new XMLDecoder(stream);
- MenuShortcut aMenuShortcut = (MenuShortcut) decoder.readObject();
- assertEquals(shortCut, aMenuShortcut);
- assertEquals(shortCut.getKey(), aMenuShortcut.getKey());
- }
-
- public static class MockComponent extends Component {
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- }
- public void test_writeObject_java_awt_Component() {
- ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
- XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(
- byteArrayOutputStream));
-
- Component component = new MockComponent();
- component.add(new PopupMenu("PopupMenu"));
- component.setBackground(Color.black);
- component.setBounds(new Rectangle(1, 1, 10, 10));
- component.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
- component.setEnabled(true);
- component.setFocusable(true);
- component.setFont(new Font("Arial", 1, 1));
- component.setForeground(Color.blue);
- component.setIgnoreRepaint(true);
- component.setLocale(Locale.CANADA);
- component.setName("MockComponent");
- component.setVisible(true);
- component.setCursor(new Cursor(Cursor.TEXT_CURSOR));
- component.setDropTarget(new DropTarget());
-
- encoder.writeObject(component);
- encoder.close();
- DataInputStream stream = new DataInputStream(new ByteArrayInputStream(
- byteArrayOutputStream.toByteArray()));
- XMLDecoder decoder = new XMLDecoder(stream);
- Component aComponent = (Component) decoder.readObject();
- assertEquals(component.getBackground(), aComponent.getBackground());
- assertEquals(component.getForeground(), aComponent.getForeground());
- assertEquals(component.getFont().getFamily(), aComponent.getFont().getFamily());
- assertEquals(component.getFont().getStyle(), aComponent.getFont().getStyle());
- assertEquals(component.getFont().getSize(), aComponent.getFont().getSize());
- assertEquals(component.getName(), aComponent.getName());
- assertEquals(component.getBounds(), aComponent.getBounds());
- }
-
- public void test_writeObject_java_awt_Container() {
- ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
- XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(
- byteArrayOutputStream));
- Container container = new Container();
- container.setBackground(Color.blue);
- container.setFocusTraversalKeysEnabled(true);
- container.setBounds(0, 0, 10, 10);
- container.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
- container.setComponentZOrder(new Label("label"), 0);
- container.setComponentZOrder(new JTabbedPane(), 1);
- container.setCursor(new Cursor(Cursor.WAIT_CURSOR));
- container.setFocusTraversalKeysEnabled(true);
- container.setFocusable(true);
- container.setFocusTraversalPolicyProvider(true);
- container.setFocusTraversalPolicy(new LayoutFocusTraversalPolicy());
- container.setFont(new Font("Arial Bold", Font.ITALIC, 0));
- container.setForeground(Color.green);
- container.setIgnoreRepaint(true);
- container.setLocation(1, 2);
- container.setName("container");
- container.setSize(new Dimension(200, 100));
- container.setEnabled(true);
- container.setFocusCycleRoot(true);
- container.setLayout(new BorderLayout());
- container.setLocale(Locale.CANADA);
- container.setVisible(true);
- container.add(new Label("label"));
- container.add(new JTabbedPane());
-
- encoder.writeObject(container);
- encoder.close();
- DataInputStream stream = new DataInputStream(new ByteArrayInputStream(
- byteArrayOutputStream.toByteArray()));
- XMLDecoder decoder = new XMLDecoder(stream);
- Container aContainer = (Container) decoder.readObject();
- assertEquals(container.getFocusTraversalKeysEnabled(), aContainer
- .getFocusTraversalKeysEnabled());
- assertEquals(Color.blue, aContainer.getBackground());
- assertEquals(new Rectangle(1, 2, 200, 100), aContainer.getBounds());
-
- // ComponentOrientation is not persistent
- assertTrue(aContainer.getComponentOrientation().isLeftToRight());
- Component [] components = aContainer.getComponents();
- assertTrue(components[0] instanceof Label);
- assertEquals(0, aContainer.getComponentZOrder(components[0]));
- assertTrue(components[1] instanceof JTabbedPane);
- assertEquals(1, aContainer.getComponentZOrder(components[1]));
-
- // Cursor will not be persisted
- assertEquals(Cursor.DEFAULT_CURSOR, aContainer.getCursor().getType());
- // DropTarget will not be persisted
- assertNull(aContainer.getDropTarget());
-
- assertEquals(container.getFocusTraversalPolicy().getClass(), aContainer
- .getFocusTraversalPolicy().getClass());
- assertEquals(container.getName(), aContainer.getName());
-
- container = new Container();
- container.setFocusCycleRoot(true);
- byteArrayOutputStream = new ByteArrayOutputStream();
- encoder = new XMLEncoder(new BufferedOutputStream(
- byteArrayOutputStream));
- encoder.writeObject(container);
- encoder.close();
- stream = new DataInputStream(new ByteArrayInputStream(
- byteArrayOutputStream.toByteArray()));
- decoder = new XMLDecoder(stream);
- aContainer = (Container) decoder.readObject();
- assertTrue(aContainer.isFocusCycleRoot());
-
- }
-
- public void test_writeObject_java_awt_Menu() {
- ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
- XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(
- byteArrayOutputStream));
- Menu menu = new Menu();
- String action = "menu action command";
- menu.setActionCommand(action);
- menu.setEnabled(true);
- menu.setFont(new Font("Arial Black", Font.BOLD, 10));
- menu.setLabel("menu");
- menu.setName("menu");
- menu.setShortcut(new MenuShortcut(10));
- menu.insertSeparator(1);
-
- encoder.writeObject(menu);
- encoder.close();
- DataInputStream stream = new DataInputStream(new ByteArrayInputStream(
- byteArrayOutputStream.toByteArray()));
- XMLDecoder decoder = new XMLDecoder(stream);
- Menu aMenu = (Menu) decoder.readObject();
- assertTrue(aMenu.isEnabled());
- assertEquals(action, aMenu.getActionCommand());
- assertEquals(menu.getFont().getSize(), aMenu.getFont().getSize());
- assertEquals(menu.getFont().getStyle(), aMenu.getFont().getStyle());
- assertEquals(menu.getLabel(), aMenu.getLabel());
- assertEquals(menu.getName(), aMenu.getName());
- assertEquals(menu.getShortcut().getKey(), aMenu.getShortcut().getKey());
- assertEquals(1, menu.getItemCount());
- assertEquals(menu.getItem(0).getLabel(), aMenu.getItem(0).getLabel());
- assertEquals(menu.getItem(0).getName(), aMenu.getItem(0).getName());
- assertEquals(menu.getItem(0).getFont().getStyle(), aMenu.getItem(0).getFont().getStyle());
- assertEquals(menu.getFont().getSize(), aMenu.getItem(0).getFont().getSize());
-
- }
-
- public void test_writeObject_java_awt_MenuBar() {
- ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
- XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(
- byteArrayOutputStream));
-
- MenuBar bar = new MenuBar();
- bar.add(new Menu("menu1"));
-
- encoder.writeObject(bar);
- encoder.close();
- DataInputStream stream = new DataInputStream(new ByteArrayInputStream(
- byteArrayOutputStream.toByteArray()));
- XMLDecoder decoder = new XMLDecoder(stream);
- MenuBar aBar = (MenuBar) decoder.readObject();
- assertEquals(bar.getMenu(0).getName(), aBar.getMenu(0).getName());
-
- }
-
- public void test_writeObject_java_awt_List() {
- ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
- XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(
- byteArrayOutputStream));
-
- java.awt.List list = new java.awt.List();
- list.setBounds(0, 0, 10, 10);
- list.add(new PopupMenu("popupMenu"));
- list.add("1");
- list.add("2", 2);
- list.setBackground(Color.BLUE);
- encoder.writeObject(list);
- encoder.close();
- DataInputStream stream = new DataInputStream(new ByteArrayInputStream(
- byteArrayOutputStream.toByteArray()));
- XMLDecoder decoder = new XMLDecoder(stream);
- java.awt.List aList = (java.awt.List) decoder.readObject();
- assertEquals(list.getItem(0), aList.getItem(0));
- assertEquals(list.getHeight(), aList.getHeight());
- assertEquals(list.getBackground(), aList.getBackground());
- }
-
- public void test_writeObject_java_awt_BorderLayout(){
- ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
- XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(
- byteArrayOutputStream));
-
- BorderLayout layout = new BorderLayout();
- layout.setHgap(2);
- layout.setVgap(3);
- encoder.writeObject(layout);
- encoder.close();
- DataInputStream stream = new DataInputStream(new ByteArrayInputStream(
- byteArrayOutputStream.toByteArray()));
- XMLDecoder decoder = new XMLDecoder(stream);
- BorderLayout aLayout = (BorderLayout) decoder.readObject();
- assertEquals(layout.getHgap(), aLayout.getHgap());
- assertEquals(layout.getVgap(), aLayout.getVgap());
- }
-
- public void test_writeObject_java_awt_CardLayout(){
- ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
- XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(
- byteArrayOutputStream));
-
- CardLayout layout = new CardLayout();
- layout.addLayoutComponent(new Label("label"), "constraints");
- layout.setHgap(2);
- layout.setVgap(3);
- encoder.writeObject(layout);
- encoder.close();
- DataInputStream stream = new DataInputStream(new ByteArrayInputStream(
- byteArrayOutputStream.toByteArray()));
- XMLDecoder decoder = new XMLDecoder(stream);
- CardLayout aLayout = (CardLayout) decoder.readObject();
- assertEquals(layout.getHgap(), aLayout.getHgap());
- assertEquals(layout.getVgap(), aLayout.getVgap());
- }
-
- public void test_writeObject_java_awt_GridBagLayout() {
- ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
- XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(
- byteArrayOutputStream));
-
- GridBagLayout layout = new GridBagLayout();
- layout.addLayoutComponent(new Label("label"), new GridBagConstraints(0,
- 0, 100, 60, 0.1, 0.1, GridBagConstraints.WEST,
- GridBagConstraints.NONE, new Insets(0,0, 99, 59), 0, 0));
- encoder.writeObject(layout);
- encoder.close();
- DataInputStream stream = new DataInputStream(new ByteArrayInputStream(
- byteArrayOutputStream.toByteArray()));
- XMLDecoder decoder = new XMLDecoder(stream);
- GridBagLayout aLayout = (GridBagLayout) decoder.readObject();
- assertEquals(layout.getConstraints(new Label("label")).weightx, aLayout
- .getConstraints(new Label("label")).weightx);
- assertEquals(layout.getConstraints(new Label("label")).insets.left, aLayout
- .getConstraints(new Label("label")).insets.left);
- }
-
- public void test_writeObject_java_awt_Cursor() {
- ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
- XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(
- byteArrayOutputStream));
- Cursor cursor = new Cursor(Cursor.CROSSHAIR_CURSOR);
-
- encoder.writeObject(cursor);
- encoder.close();
- DataInputStream stream = new DataInputStream(new ByteArrayInputStream(
- byteArrayOutputStream.toByteArray()));
- XMLDecoder decoder = new XMLDecoder(stream);
- Cursor aCursor = (Cursor) decoder.readObject();
- assertEquals(cursor.getName(), aCursor
- .getName());
- assertEquals(cursor.getType(), aCursor.getType());
- }
-
- public void test_writeObject_java_awt_Insets() {
- ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
- XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(
- byteArrayOutputStream));
- Insets inset = new Insets(0, 0, 10, 10);
-
- encoder.writeObject(inset);
- encoder.close();
- DataInputStream stream = new DataInputStream(new ByteArrayInputStream(
- byteArrayOutputStream.toByteArray()));
- XMLDecoder decoder = new XMLDecoder(stream);
- Insets aInset = (Insets) decoder.readObject();
- assertEquals(inset.left, aInset.left);
- assertEquals(inset.top, aInset.top);
- }
-
- public void test_writeObject_java_awt_point() {
- ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
- XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(
- byteArrayOutputStream));
- Point point = new Point(10, 20);
-
- encoder.writeObject(point);
- encoder.close();
-
- DataInputStream stream = new DataInputStream(new ByteArrayInputStream(
- byteArrayOutputStream.toByteArray()));
- XMLDecoder decoder = new XMLDecoder(stream);
- Point aPoint = (Point) decoder.readObject();
- assertEquals(point, aPoint);
- }
-
- public void test_writeObject_java_awt_ScrollPane() {
- ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
- XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(
- byteArrayOutputStream));
- ScrollPane scrollPane = new ScrollPane();
-
- encoder.writeObject(scrollPane);
- encoder.close();
-
- DataInputStream stream = new DataInputStream(new ByteArrayInputStream(
- byteArrayOutputStream.toByteArray()));
- XMLDecoder decoder = new XMLDecoder(stream);
- ScrollPane aScrollPane = (ScrollPane) decoder.readObject();
- assertEquals(scrollPane.getAlignmentX(), aScrollPane.getAlignmentX());
- assertEquals(scrollPane.getAlignmentY(), aScrollPane.getAlignmentY());
- assertEquals(scrollPane.getScrollbarDisplayPolicy(), aScrollPane
- .getScrollbarDisplayPolicy());
- }
-
- public void test_writeObject_java_util_Map(){
- ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
- XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(
- byteArrayOutputStream));
- TreeMap<Integer, String> map = new TreeMap<Integer, String>();
- map.put(new Integer(10), "first element");
-
- encoder.writeObject(map);
- encoder.close();
- DataInputStream stream = new DataInputStream(new ByteArrayInputStream(
- byteArrayOutputStream.toByteArray()));
- XMLDecoder decoder = new XMLDecoder(stream);
- TreeMap aMap = (TreeMap) decoder.readObject();
- assertEquals(map.size(), aMap.size());
- assertEquals(map.get(10), aMap.get(10));
- }
-
- public void test_writeObject_java_util_List() {
- ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
- XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(
- byteArrayOutputStream));
- Vector vector = new Vector();
- vector.add("test");
- vector.add(1);
-
- encoder.writeObject(vector);
- encoder.close();
- DataInputStream stream = new DataInputStream(new ByteArrayInputStream(
- byteArrayOutputStream.toByteArray()));
- XMLDecoder decoder = new XMLDecoder(stream);
- Vector aVector = (Vector) decoder.readObject();
- assertEquals(vector, aVector);
- assertEquals(2, aVector.size());
- assertEquals(vector.get(0), aVector.get(0));
- assertEquals(1, aVector.get(1));
-
- Vector v = new Vector();
- v.add("The first item.");
- v.add("The second item.");
- Vector v2 = new Vector();
- v2.add("A nested item.");
- v.add(v2);
-
- byteArrayOutputStream = new ByteArrayOutputStream();
- encoder = new XMLEncoder(byteArrayOutputStream);
- encoder.writeObject(v);
- encoder.flush();
- encoder.close();
-
- stream = new DataInputStream(new ByteArrayInputStream(
- byteArrayOutputStream.toByteArray()));
- decoder = new XMLDecoder(stream);
- aVector = (Vector) decoder.readObject();
- assertEquals(v, aVector);
- assertEquals(3, aVector.size());
- assertEquals(v.get(0), aVector.get(0));
- assertEquals(v.get(2), aVector.get(2));
- }
-
- public void test_writeObject_java_util_AbstractList(){
- ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
- XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(
- byteArrayOutputStream));
- ArrayList<Integer> arrayList = new ArrayList<Integer>();
- arrayList.add(10);
-
- encoder.writeObject(arrayList);
- encoder.close();
- DataInputStream stream = new DataInputStream(new ByteArrayInputStream(
- byteArrayOutputStream.toByteArray()));
- XMLDecoder decoder = new XMLDecoder(stream);
- ArrayList aList = (ArrayList) decoder.readObject();
- assertEquals(arrayList.size(), aList.size());
- assertEquals(arrayList.get(0), arrayList.get(0));
- }
-
- public void test_writeObject_java_util_AbstractMap() {
- ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
- XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(
- byteArrayOutputStream));
-
- HashMap<Integer, String> hMap = new HashMap<Integer, String>();
- hMap.put(1, "1");
- hMap.put(2, "test");
-
- encoder.writeObject(hMap);
- encoder.close();
- DataInputStream stream = new DataInputStream(new ByteArrayInputStream(
- byteArrayOutputStream.toByteArray()));
- XMLDecoder decoder = new XMLDecoder(stream);
- HashMap aHmap = (HashMap) decoder.readObject();
- assertEquals(hMap.size(), aHmap.size());
- assertEquals(hMap.get(1), aHmap.get(1));
- assertEquals("test", aHmap.get(2));
- }
-
- public void test_writeObject_javax_swing_JFrame() {
- ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
- XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(
- byteArrayOutputStream));
-
- JFrame frame = new JFrame("JFrame");
- frame.setAlwaysOnTop(true);
- frame.setBounds(1, 1, 100, 100);
- frame.add(new JMenu("JMenu"));
- encoder.writeObject(frame);
- encoder.close();
- DataInputStream stream = new DataInputStream(new ByteArrayInputStream(
- byteArrayOutputStream.toByteArray()));
- XMLDecoder decoder = new XMLDecoder(stream);
- JFrame aFrame = (JFrame) decoder.readObject();
- assertEquals(frame.getTitle(), aFrame.getTitle());
- assertEquals(frame.getBounds(), aFrame.getBounds());
- }
-
- public void test_writeObject_javax_swing_DefaultListModel() {
- ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
- XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(
- byteArrayOutputStream));
-
- DefaultListModel model = new DefaultListModel();
- model.add(0, 1);
- model.add(1, 2);
- ListDataHandler listDataHandler = new BasicComboBoxUI().new ListDataHandler();
- model.addListDataListener(listDataHandler);
-
- encoder.writeObject(model);
- encoder.close();
- DataInputStream stream = new DataInputStream(new ByteArrayInputStream(
- byteArrayOutputStream.toByteArray()));
- XMLDecoder decoder = new XMLDecoder(stream);
- DefaultListModel aModel = (DefaultListModel) decoder.readObject();
- assertEquals(model.getSize(), aModel.getSize());
- }
-
- public void test_writeObject_javax_swing_DefaultComboBoxModel() {
- ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
- XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(
- byteArrayOutputStream));
- Object a[] = {1, 2};
- DefaultComboBoxModel model = new DefaultComboBoxModel(a);
-
- encoder.writeObject(model);
- encoder.close();
- DataInputStream stream = new DataInputStream(new ByteArrayInputStream(
- byteArrayOutputStream.toByteArray()));
- XMLDecoder decoder = new XMLDecoder(stream);
- DefaultComboBoxModel aModel = (DefaultComboBoxModel) decoder.readObject();
- assertEquals(model.getSize(), aModel.getSize());
- assertEquals(model.getElementAt(0), aModel.getElementAt(0));
- assertEquals(model.getElementAt(1), aModel.getElementAt(1));
- }
-
- public void test_writeObject_javax_swing_tree_DefaultMutableTreeNode() {
- ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
- XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(
- byteArrayOutputStream));
- DefaultMutableTreeNode node = new DefaultMutableTreeNode(1);
-
- encoder.writeObject(node);
- encoder.close();
- DataInputStream stream = new DataInputStream(new ByteArrayInputStream(
- byteArrayOutputStream.toByteArray()));
- XMLDecoder decoder = new XMLDecoder(stream);
- DefaultMutableTreeNode aNode = (DefaultMutableTreeNode) decoder.readObject();
- assertEquals(node.getUserObject(), aNode.getUserObject());
- }
-
- public void test_writeObject_javax_swing_ToolTipManager() {
- ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
- XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(
- byteArrayOutputStream));
- ToolTipManager manager = ToolTipManager.sharedInstance();
- manager.setDismissDelay(10);
-
- encoder.writeObject(manager);
- encoder.close();
- DataInputStream stream = new DataInputStream(new ByteArrayInputStream(
- byteArrayOutputStream.toByteArray()));
- XMLDecoder decoder = new XMLDecoder(stream);
- ToolTipManager aManager = (ToolTipManager) decoder.readObject();
- assertEquals(manager, aManager);
- assertEquals(manager.getDismissDelay(), aManager.getDismissDelay());
- }
-
- public void test_writeObject_javax_swing_Box() {
- ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
- XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(
- byteArrayOutputStream));
- Box box = new Box(1);
- box.setAlignmentX(12.21f);
-
- encoder.writeObject(box);
- encoder.close();
- DataInputStream stream = new DataInputStream(new ByteArrayInputStream(
- byteArrayOutputStream.toByteArray()));
- XMLDecoder decoder = new XMLDecoder(stream);
- Box aBox = (Box) decoder.readObject();
- assertEquals(box.getAlignmentX(), aBox.getAlignmentX());
- }
-
- public void test_writeObject_javax_swing_JMenu(){
- ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
- XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(
- byteArrayOutputStream));
- JMenu menu = new JMenu("menu");
-
- encoder.writeObject(menu);
- encoder.close();
- DataInputStream stream = new DataInputStream(new ByteArrayInputStream(
- byteArrayOutputStream.toByteArray()));
- XMLDecoder decoder = new XMLDecoder(stream);
- JMenu aMenu = (JMenu) decoder.readObject();
- assertEquals(menu.getVerifyInputWhenFocusTarget(), aMenu
- .getVerifyInputWhenFocusTarget());
- assertEquals(menu.getName(), aMenu.getName());
- }
-
- public void test_writeObject_Integer_Class() {
-
- ByteArrayOutputStream os = new ByteArrayOutputStream();
-
- System.err.println("Test 5");
- Object[] objects5 = { Integer.class, Integer.TYPE };
- XMLEncoder xmlEnc5 = new XMLEncoder(os);
- for (int i = 0; i < objects5.length; i++) {
- xmlEnc5.writeObject(objects5[i]);
- }
- xmlEnc5.flush();
- xmlEnc5.close();
-
- DataInputStream stream = new DataInputStream(new ByteArrayInputStream(
- os.toByteArray()));
- XMLDecoder decoder = new XMLDecoder(stream);
- Class intClass = (Class) decoder.readObject();
- Class aIntClass = (Class) decoder.readObject();
- assertEquals(Integer.class, intClass);
- assertEquals(Integer.TYPE, aIntClass);
- }
-
- public static class DummyBean {
-
- private String value;
-
- public DummyBean() {
- }
-
- public DummyBean(String s) {
- value = s;
- }
-
- public String getDummyValue() {
- return value;
- }
-
- public void setDummyValue(String s) {
- value = s;
- }
-
- public boolean equals(Object bean) {
- if (!(bean instanceof DummyBean)) {
- return false;
- }
- DummyBean aBean = (DummyBean) bean;
-
- if (aBean.value == null && value != null || value != null
- && aBean.value == null) {
- return false;
- } else if(value != null && aBean.value != null){
- return value.equals(aBean.value);
- }
- return true;
- }
- }
- public void test_writeExpression_writeObject() throws Exception {
- ByteArrayOutputStream output = new ByteArrayOutputStream();
- XMLEncoder encoder = new XMLEncoder( output );
-
- Date date = new Date(2007, 06, 26);
- Expression expression = new Expression( date, "toString", null );
- String date_string = null;
- date_string = (String) expression.getValue();
-
- DummyBean bean = new DummyBean( date_string );
- // The expression knows about the date object.
- encoder.writeExpression( expression );
- encoder.writeObject( date );
- // The value for the bean is already part of the expression
- // so instead of writing the value we write a reference to
- // the expression.
- encoder.writeObject( bean );
-
- encoder.flush();
- encoder.close();
-
- DataInputStream stream = new DataInputStream(new ByteArrayInputStream(
- output.toByteArray()));
- XMLDecoder decoder = new XMLDecoder(stream);
- Date aDate = (Date) decoder.readObject();
- assertEquals(date, aDate);
-
- DummyBean aBean = (DummyBean) decoder.readObject();
- assertEquals(bean, aBean);
- }
-
- // <--
-
- private void assertWasAdded(Class<?> targetClass, String methodName,
- Object[] args, MockEncoder2 enc) {
- try {
- while (true) {
- Statement stmt = enc.pop();
-
- if (equals(stmt, targetClass, methodName, args)) {
- break;
- }
- }
- } catch (EmptyStackException e) {
- fail("Required statement was not found");
- }
- }
-
- private boolean equals(Statement stmt, Class<?> targetClass,
- String methodName, Object[] args) {
-
- if (stmt == null || !methodName.equals(stmt.getMethodName())) {
- return false;
- }
-
- if (targetClass != null) {
- // check if we have the object of the same class at least
- if (targetClass != stmt.getTarget().getClass()) {
- return false;
- }
- } else {
- if (stmt.getTarget() != null) {
- return false;
- }
- }
-
- if (args != null) {
- if (stmt.getArguments() == null
- || args.length != stmt.getArguments().length) {
- return false;
- }
-
- for (int i = 0; i < args.length; i++) {
-
- if (args[i] != null) {
- if (!args[i].equals(stmt.getArguments()[i])) {
- return false;
- }
- } else {
- if (stmt.getArguments()[i] != null) {
- return false;
- }
- }
- }
- } else {
- if (stmt.getArguments() != null && stmt.getArguments().length > 0) {
- return false;
- }
- }
-
- return true;
- }
-
- /*
- * Mock interface.
- */
- static interface MockInterface {
-
- }
-
- /*
- * Mock interface.
- */
- static class MockObject implements MockInterface {
-
- }
-
- static class MockEncoder2 extends Encoder {
- Stack<Statement> stmts = new Stack<Statement>();
-
- @Override
- public void writeExpression(Expression expr) {
- stmts.push(expr);
- super.writeExpression(expr);
- }
-
- @Override
- public void writeStatement(Statement stmt) {
- stmts.push(stmt);
- super.writeStatement(stmt);
- }
-
- @Override
- public void writeObject(Object obj) {
- super.writeObject(obj);
- }
-
- public Statement pop() {
- return stmts.pop();
- }
-
- }
-
- static class MockPersistenceDelegate2 extends PersistenceDelegate {
- private Boolean mutatesToFlag = null;
-
- Stack<String> methods = new Stack<String>();
-
- public MockPersistenceDelegate2() {
- }
-
- public MockPersistenceDelegate2(boolean mutatesToFlag) {
- this.mutatesToFlag = Boolean.valueOf(mutatesToFlag);
- }
-
- @Override
- public void initialize(Class<?> type, Object oldInstance,
- Object newInstance, Encoder enc) {
- methods.push("initialize");
- super.initialize(type, oldInstance, newInstance, enc);
- }
-
- @Override
- public Expression instantiate(Object oldInstance, Encoder out) {
- methods.push("instantiate");
- return new Expression(oldInstance.getClass(), "new", null);
- }
-
- @Override
- public boolean mutatesTo(Object oldInstance, Object newInstance) {
- methods.push("mutatesTo");
-
- if (mutatesToFlag != null) {
- return mutatesToFlag.booleanValue();
- }
- return super.mutatesTo(oldInstance, newInstance);
- }
-
- String popMethod() {
- return methods.pop();
- }
-
- boolean hasMoreMethods() {
- return !methods.empty();
- }
- }
-
- static class MockPersistenceDelegate3 extends PersistenceDelegate {
- Stack<String> methods = new Stack<String>();
-
- @Override
- public void initialize(Class<?> type, Object oldInstance,
- Object newInstance, Encoder enc) {
- methods.push("initialize");
- }
-
- @Override
- public Expression instantiate(Object oldInstance, Encoder out) {
- methods.push("instantiate");
- return null;
- }
-
- @Override
- public boolean mutatesTo(Object oldInstance, Object newInstance) {
- methods.push("mutatesTo");
- return true;
- }
-
- String popMethod() {
- return methods.pop();
- }
-
- boolean hasMoreMethods() {
- return !methods.empty();
- }
- }
-
- /*
- * Dummy PersistenceDelegate subclass.
- */
- static class DummyPersistenceDelegate extends PersistenceDelegate {
- @Override
- public Expression instantiate(Object oldInstance, Encoder out) {
- return new Expression(oldInstance.getClass(), "new", null);
- }
-
- @Override
- public void initialize(Class<?> type, Object oldInstance,
- Object newInstance, Encoder enc) {
- super.initialize(type, oldInstance, newInstance, enc);
- }
-
- @Override
- public boolean mutatesTo(Object oldInstance, Object newInstance) {
- return super.mutatesTo(oldInstance, newInstance);
- }
-
- @Override
- public void writeObject(Object oldInstance, Encoder enc) {
- super.writeObject(oldInstance, enc);
- }
-
- }
-
-}
diff --git a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PropertyDescriptorTest.java b/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PropertyDescriptorTest.java
deleted file mode 100644
index fbff42f..0000000
--- a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PropertyDescriptorTest.java
+++ /dev/null
@@ -1,1339 +0,0 @@
-/*
- * 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.java.beans;
-
-import java.beans.IntrospectionException;
-import java.beans.PropertyDescriptor;
-import java.beans.PropertyEditor;
-import java.beans.PropertyEditorSupport;
-import java.io.Serializable;
-import java.lang.reflect.Method;
-import java.util.Locale;
-
-import junit.framework.TestCase;
-
-import org.apache.harmony.beans.tests.support.mock.MockJavaBean;
-
-/**
- * Unit test for PropertyDescriptor.
- */
-public class PropertyDescriptorTest extends TestCase {
-
- public void testEquals() throws IntrospectionException, SecurityException,
- NoSuchMethodException {
- String propertyName = "PropertyOne";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
- PropertyDescriptor pd = new PropertyDescriptor(propertyName, beanClass);
-
- Method readMethod = beanClass.getMethod("get" + propertyName,
- (Class[]) null);
- Method writeMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { String.class });
- PropertyDescriptor pd2 = new PropertyDescriptor(propertyName,
- readMethod, writeMethod);
-
- pd.setName("different name");
- assertTrue(pd.equals(pd2));
- assertTrue(pd.equals(pd));
- assertTrue(pd2.equals(pd));
- assertFalse(pd.equals(null));
- }
-
- // Regression test for H-1763
- public void testEqualsRegression1763() throws IntrospectionException {
- String propertyName = "PropertyOne";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
- PropertyDescriptor pd = new PropertyDescriptor(propertyName, beanClass);
-
- try {
- pd.equals(propertyName);
- } catch (ClassCastException e) {
- fail("Equals throws ClassCastException");
- }
- }
-
- public void testEquals_ReadMethod() throws IntrospectionException,
- SecurityException, NoSuchMethodException {
- String propertyName = "PropertyOne";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
- Method readMethod = beanClass.getMethod("get" + propertyName,
- (Class[]) null);
- PropertyDescriptor pd = new PropertyDescriptor(propertyName,
- readMethod, null);
-
- String propertyName2 = "PropertyThree";
- Method readMethod2 = beanClass.getMethod("get" + propertyName2,
- (Class[]) null);
- PropertyDescriptor pd2 = new PropertyDescriptor(propertyName2,
- readMethod2, null);
-
- assertFalse(pd.equals(pd2));
- }
-
- public void testEquals_ReadMethod_Null() throws IntrospectionException,
- SecurityException, NoSuchMethodException {
- String propertyName = "PropertyOne";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
- Method readMethod = null;
- PropertyDescriptor pd = new PropertyDescriptor(propertyName,
- readMethod, null);
-
- String propertyName2 = "PropertyThree";
- Method readMethod2 = beanClass.getMethod("get" + propertyName2,
- (Class[]) null);
- PropertyDescriptor pd2 = new PropertyDescriptor(propertyName2,
- readMethod2, null);
-
- assertFalse(pd.equals(pd2));
- }
-
- public void testEquals_ReadMethod_Null_Null()
- throws IntrospectionException, SecurityException,
- NoSuchMethodException {
- String propertyName = "PropertyOne";
-
- Method readMethod = null;
- PropertyDescriptor pd = new PropertyDescriptor(propertyName,
- readMethod, null);
-
- String propertyName2 = "PropertyThree";
- Method readMethod2 = null;
- PropertyDescriptor pd2 = new PropertyDescriptor(propertyName2,
- readMethod2, null);
-
- assertTrue(pd.equals(pd2));
- }
-
- public void testEquals_WriteMethod() throws IntrospectionException,
- SecurityException, NoSuchMethodException {
- String propertyName = "PropertyOne";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
- Method writeMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { String.class });
- PropertyDescriptor pd = new PropertyDescriptor(propertyName, null,
- writeMethod);
-
- String propertyName2 = "PropertyThree";
- Method writeMethod2 = beanClass.getMethod("set" + propertyName2,
- new Class[] { String.class });
- PropertyDescriptor pd2 = new PropertyDescriptor(propertyName2, null,
- writeMethod2);
-
- assertFalse(pd.equals(pd2));
- }
-
- public void testEquals_WriteMethod_Null() throws IntrospectionException,
- SecurityException, NoSuchMethodException {
- String propertyName = "PropertyOne";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
- Method writeMethod = null;
- PropertyDescriptor pd = new PropertyDescriptor(propertyName, null,
- writeMethod);
-
- String propertyName2 = "PropertyThree";
- Method writeMethod2 = beanClass.getMethod("set" + propertyName2,
- new Class[] { String.class });
- PropertyDescriptor pd2 = new PropertyDescriptor(propertyName2, null,
- writeMethod2);
-
- assertFalse(pd.equals(pd2));
- }
-
- public void testEquals_Bound() throws IntrospectionException,
- SecurityException, NoSuchMethodException {
- String propertyName = "PropertyOne";
-
- PropertyDescriptor pd = new PropertyDescriptor(propertyName, null, null);
-
- String propertyName2 = "PropertyThree";
- PropertyDescriptor pd2 = new PropertyDescriptor(propertyName2, null,
- null);
- pd.setBound(true);
- assertFalse(pd.equals(pd2));
- }
-
- public void testEquals_Contrained() throws IntrospectionException,
- SecurityException, NoSuchMethodException {
- String propertyName = "PropertyOne";
-
- PropertyDescriptor pd = new PropertyDescriptor(propertyName, null, null);
-
- String propertyName2 = "PropertyThree";
- PropertyDescriptor pd2 = new PropertyDescriptor(propertyName2, null,
- null);
- pd.setConstrained(true);
- assertFalse(pd.equals(pd2));
- }
-
- public void testEquals_PropertyEditorClass() throws IntrospectionException,
- SecurityException, NoSuchMethodException {
- String propertyName = "PropertyOne";
-
- PropertyDescriptor pd = new PropertyDescriptor(propertyName, null, null);
-
- String propertyName2 = "PropertyThree";
- PropertyDescriptor pd2 = new PropertyDescriptor(propertyName2, null,
- null);
-
- pd.setPropertyEditorClass(String.class);
- assertFalse(pd.equals(pd2));
- }
-
- public void testEquals_PropertyType() throws IntrospectionException {
- String propertyName = "PropertyOne";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
- PropertyDescriptor pd = new PropertyDescriptor(propertyName, beanClass);
-
- Class<MockBeanPropertyDesc> beanClass2 = PropertyDescriptorTest.MockBeanPropertyDesc.class;
- PropertyDescriptor pd2 = new PropertyDescriptor(propertyName,
- beanClass2);
- assertFalse(pd.equals(pd2));
- }
-
- /*
- * Class under test for void PropertyDescriptor(String, Class)
- */
- public void testPropertyDescriptorStringClass()
- throws IntrospectionException {
- String propertyName = "propertyOne";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
- PropertyDescriptor pd = new PropertyDescriptor(propertyName, beanClass);
-
- String capitalName = propertyName.substring(0, 1).toUpperCase()
- + propertyName.substring(1);
- assertEquals(String.class, pd.getPropertyType());
- assertEquals("get" + capitalName, pd.getReadMethod().getName());
- assertEquals("set" + capitalName, pd.getWriteMethod().getName());
-
- assertFalse(pd.isBound());
- assertFalse(pd.isConstrained());
- assertNull(pd.getPropertyEditorClass());
-
- assertEquals(propertyName, pd.getDisplayName());
- assertEquals(propertyName, pd.getName());
- assertEquals(propertyName, pd.getShortDescription());
-
- assertNotNull(pd.attributeNames());
-
- assertFalse(pd.isExpert());
- assertFalse(pd.isHidden());
- assertFalse(pd.isPreferred());
-
- propertyName = "propertyWithoutGet";
- try{
- new PropertyDescriptor(propertyName, beanClass);
- fail("Should throw IntrospectionException");
- }catch(IntrospectionException e){
- }
-
- try{
- new PropertyDescriptor(propertyName, beanClass, "getPropertyWithoutGet", "setPropertyWithoutGet");
- fail("Should throw IntrospectionException");
- }catch(IntrospectionException e){
- }
-
- propertyName = "propertyWithoutSet";
- beanClass = MockJavaBean.class;
- try{
- new PropertyDescriptor(propertyName, beanClass);
- fail("Should throw IntrospectionException");
- }catch(IntrospectionException e){
- }
-
- propertyName = "propertyWithDifferentGetSet";
- try{
- new PropertyDescriptor(propertyName, beanClass);
- fail("Should throw IntrospectionException");
- }catch(IntrospectionException e){
- }
-
- propertyName = "propertyWithInvalidGet";
- new PropertyDescriptor(propertyName, beanClass);
-
- propertyName = "propertyWithoutPublicGet";
- try{
- new PropertyDescriptor(propertyName, beanClass);
- fail("Should throw IntrospectionException");
- }catch(IntrospectionException e){
- }
-
- propertyName = "propertyWithGet1Param";
- try{
- new PropertyDescriptor(propertyName, beanClass);
- fail("Should throw IntrospectionException");
- }catch(IntrospectionException e){
- }
-
- propertyName = "propertyWithIs1Param";
- PropertyDescriptor pd2 = new PropertyDescriptor(propertyName, beanClass);
- assertEquals("getPropertyWithIs1Param", pd2.getReadMethod().getName());
-
- propertyName = "propertyWithSet2Param";
- try {
- new PropertyDescriptor(propertyName, beanClass);
- fail("Should throw IntrospectionException");
- } catch (IntrospectionException e) {
- }
-
- propertyName = "propertyWithIsGet";
- PropertyDescriptor pd3 = new PropertyDescriptor(propertyName, beanClass);
- assertEquals("isPropertyWithIsGet", pd3.getReadMethod().getName());
-
- propertyName = "propertyWithVoidGet";
- try {
- new PropertyDescriptor(propertyName, beanClass);
- fail("Should throw IntrospectionException");
- } catch (IntrospectionException e) {
- }
- }
-
- public void testPropertyDescriptorStringClass_PropertyNameCapital()
- throws IntrospectionException {
- String propertyName = "PropertyOne";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
- PropertyDescriptor pd = new PropertyDescriptor(propertyName, beanClass);
- assertEquals(propertyName, pd.getName());
- }
-
- public void testPropertyDescriptorStringClass_PropertyNameEmpty()
- throws IntrospectionException {
- String propertyName = "";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
- try {
- new PropertyDescriptor(propertyName, beanClass);
- fail("Should throw IntrospectionException.");
- } catch (IntrospectionException exception) {
- }
- }
-
- public void testPropertyDescriptorStringClass_PropertyNameNull() {
- Class<MockJavaBean> beanClass = MockJavaBean.class;
- try {
- new PropertyDescriptor(null, beanClass);
- fail("Should throw IntrospectionException.");
- } catch (IntrospectionException exception) {
- }
- }
-
- public void testPropertyDescriptorStringClass_BeanClassNull()
- throws IntrospectionException {
- String propertyName = "propertyOne";
- try {
- new PropertyDescriptor(propertyName, null);
- fail("Should throw IntrospectionException.");
- } catch (IntrospectionException exception) {
- }
- }
-
- public void testPropertyDescriptorStringClass_PropertyNameInvalid() {
- String propertyName = "not a property name";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
- try {
- new PropertyDescriptor(propertyName, beanClass);
- fail("Should throw IntrospectionException.");
- } catch (IntrospectionException exception) {
- }
- }
-
- public void testPropertyDescriptorStringClass_ProtectedGetter() {
- String propertyName = "protectedProp";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
- try {
- new PropertyDescriptor(propertyName, beanClass);
- fail("Should throw IntrospectionException.");
- } catch (IntrospectionException exception) {
- }
- }
-
- /*
- * Class under test for void PropertyDescriptor(String, Class, String,
- * String)
- */
- public void testPropertyDescriptorStringClassStringString()
- throws IntrospectionException {
- String propertyName = "PropertyTwo";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
- PropertyDescriptor pd = new PropertyDescriptor(propertyName, beanClass,
- "get" + propertyName, "set" + propertyName);
-
- assertEquals(Integer.class, pd.getPropertyType());
- assertEquals("get" + propertyName, pd.getReadMethod().getName());
- assertEquals("set" + propertyName, pd.getWriteMethod().getName());
-
- assertFalse(pd.isBound());
- assertFalse(pd.isConstrained());
- assertNull(pd.getPropertyEditorClass());
-
- assertEquals(propertyName, pd.getDisplayName());
- assertEquals(propertyName, pd.getName());
- assertEquals(propertyName, pd.getShortDescription());
-
- assertNotNull(pd.attributeNames());
-
- assertFalse(pd.isExpert());
- assertFalse(pd.isHidden());
- assertFalse(pd.isPreferred());
- }
-
- public void testPropertyDescriptorStringClassStringString_PropertyNameNull() {
- String propertyName = "PropertyTwo";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
- try {
- new PropertyDescriptor(null, beanClass, "get" + propertyName, "set"
- + propertyName);
- fail("Should throw IntrospectionException.");
- } catch (IntrospectionException e) {
- }
- }
-
- public void testPropertyDescriptorStringClassStringString_BeanClassNull()
- throws IntrospectionException {
- String propertyName = "PropertyTwo";
- Class<?> beanClass = null;
- try {
- new PropertyDescriptor(propertyName, beanClass, "get"
- + propertyName, "set" + propertyName);
- fail("Should throw IntrospectionException.");
- } catch (IntrospectionException e) {
- }
- }
-
- public void testPropertyDescriptorStringClassStringString_ReadMethodNull()
- throws IntrospectionException {
- String propertyName = "PropertyTwo";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
- PropertyDescriptor pd = new PropertyDescriptor(propertyName, beanClass,
- null, "set" + propertyName);
-
- assertEquals(Integer.class, pd.getPropertyType());
- assertNull(pd.getReadMethod());
- assertEquals("set" + propertyName, pd.getWriteMethod().getName());
-
- assertFalse(pd.isBound());
- assertFalse(pd.isConstrained());
- assertNull(pd.getPropertyEditorClass());
-
- assertEquals(propertyName, pd.getDisplayName());
- assertEquals(propertyName, pd.getName());
- assertEquals(propertyName, pd.getShortDescription());
-
- assertNotNull(pd.attributeNames());
-
- assertFalse(pd.isExpert());
- assertFalse(pd.isHidden());
- assertFalse(pd.isPreferred());
-
- try{
- pd = new PropertyDescriptor(propertyName, beanClass,
- "", "set" + propertyName);
- fail("should throw exception");
- }catch(IntrospectionException e){
- }
- }
-
- public void testPropertyDescriptorStringClassStringString_ReadMethodInvalid()
- throws IntrospectionException {
- String propertyName = "booleanProperty";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
- PropertyDescriptor pd = new PropertyDescriptor(propertyName, beanClass, "getXX", "set"
- + propertyName);
- assertEquals("getBooleanProperty", pd.getReadMethod().getName());
- assertEquals("setbooleanProperty", pd.getWriteMethod().getName());
- }
-
- public void testPropertyDescriptorStringClassStringString_WriteMethodNull()
- throws IntrospectionException {
- String propertyName = "PropertyTwo";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
- PropertyDescriptor pd = new PropertyDescriptor(propertyName, beanClass,
- "get" + propertyName, null);
-
- assertEquals(Integer.class, pd.getPropertyType());
- assertEquals("get" + propertyName, pd.getReadMethod().getName());
- assertNull(pd.getWriteMethod());
-
- assertFalse(pd.isBound());
- assertFalse(pd.isConstrained());
- assertNull(pd.getPropertyEditorClass());
-
- assertEquals(propertyName, pd.getDisplayName());
- assertEquals(propertyName, pd.getName());
- assertEquals(propertyName, pd.getShortDescription());
-
- assertNotNull(pd.attributeNames());
-
- assertFalse(pd.isExpert());
- assertFalse(pd.isHidden());
- assertFalse(pd.isPreferred());
- }
-
- public void testPropertyDescriptorStringClassStringString_WriteMethodEmpty()
- throws IntrospectionException {
- String propertyName = "PropertyTwo";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
- try {
- new PropertyDescriptor(propertyName, beanClass, "get"
- + propertyName, "");
- fail("Should throw IntrospectionException.");
- } catch (IntrospectionException e) {
- }
-
- }
-
- public void testPropertyDescriptorStringClassStringString_WriteMethodInvalid()
- throws IntrospectionException {
- String propertyName = "PropertyTwo";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
- try {
- new PropertyDescriptor(propertyName, beanClass, "get"
- + propertyName, "setXXX");
- fail("Should throw IntrospectionException.");
- } catch (IntrospectionException e) {
- }
-
- }
-
- /*
- * Class under test for void PropertyDescriptor(String, Method, Method)
- */
- public void testPropertyDescriptorStringMethodMethod()
- throws SecurityException, NoSuchMethodException,
- IntrospectionException {
- String propertyName = "PropertyOne";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
- Method readMethod = beanClass.getMethod("get" + propertyName,
- (Class[]) null);
- Method writeMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { String.class });
- PropertyDescriptor pd = new PropertyDescriptor(propertyName,
- readMethod, writeMethod);
-
- assertEquals(String.class, pd.getPropertyType());
- assertEquals("get" + propertyName, pd.getReadMethod().getName());
- assertEquals("set" + propertyName, pd.getWriteMethod().getName());
-
- assertFalse(pd.isBound());
- assertFalse(pd.isConstrained());
- assertNull(pd.getPropertyEditorClass());
-
- assertEquals(propertyName, pd.getDisplayName());
- assertEquals(propertyName, pd.getName());
- assertEquals(propertyName, pd.getShortDescription());
-
- assertNotNull(pd.attributeNames());
-
- assertFalse(pd.isExpert());
- assertFalse(pd.isHidden());
- assertFalse(pd.isPreferred());
- }
-
- public void testPropertyDescriptorStringMethodMethod_PropertyNameNull()
- throws SecurityException, NoSuchMethodException,
- IntrospectionException {
- String propertyName = "PropertyOne";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
- Method readMethod = beanClass.getMethod("get" + propertyName,
- (Class[]) null);
- Method writeMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { String.class });
- try {
- new PropertyDescriptor(null, readMethod, writeMethod);
- fail("Should throw IntrospectionException.");
- } catch (IntrospectionException e) {
- }
-
- }
-
- public void testPropertyDescriptorStringMethodMethod_ReadMethodNull()
- throws SecurityException, NoSuchMethodException,
- IntrospectionException {
- String propertyName = "PropertyOne";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
- Method readMethod = null;
- Method writeMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { String.class });
- PropertyDescriptor pd = new PropertyDescriptor(propertyName,
- readMethod, writeMethod);
-
- assertEquals(String.class, pd.getPropertyType());
- assertNull(pd.getReadMethod());
- assertEquals("set" + propertyName, pd.getWriteMethod().getName());
-
- assertFalse(pd.isBound());
- assertFalse(pd.isConstrained());
- assertNull(pd.getPropertyEditorClass());
-
- assertEquals(propertyName, pd.getDisplayName());
- assertEquals(propertyName, pd.getName());
- assertEquals(propertyName, pd.getShortDescription());
-
- assertNotNull(pd.attributeNames());
-
- assertFalse(pd.isExpert());
- assertFalse(pd.isHidden());
- assertFalse(pd.isPreferred());
- }
-
- public void testPropertyDescriptorStringMethodMethod_ReadMethodInvalid()
- throws SecurityException, NoSuchMethodException,
- IntrospectionException {
- String propertyName = "PropertyOne";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
- String anotherProp = "PropertyTwo";
-
- Method readMethod = beanClass.getMethod("get" + anotherProp,
- (Class[]) null);
- Method writeMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { String.class });
- try {
- new PropertyDescriptor(propertyName, readMethod, writeMethod);
- fail("Should throw IntrospectionException.");
- } catch (IntrospectionException e) {
- }
-
- }
-
- public void testPropertyDescriptorStringMethodMethod_WriteMethodNull()
- throws SecurityException, NoSuchMethodException,
- IntrospectionException {
- String propertyName = "PropertyOne";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
- Method readMethod = beanClass.getMethod("get" + propertyName,
- (Class[]) null);
- Method writeMethod = null;
- PropertyDescriptor pd = new PropertyDescriptor(propertyName,
- readMethod, writeMethod);
-
- assertEquals(String.class, pd.getPropertyType());
- assertEquals("get" + propertyName, pd.getReadMethod().getName());
- assertNull(pd.getWriteMethod());
-
- assertFalse(pd.isBound());
- assertFalse(pd.isConstrained());
- assertNull(pd.getPropertyEditorClass());
-
- assertEquals(propertyName, pd.getDisplayName());
- assertEquals(propertyName, pd.getName());
- assertEquals(propertyName, pd.getShortDescription());
-
- assertNotNull(pd.attributeNames());
-
- assertFalse(pd.isExpert());
- assertFalse(pd.isHidden());
- assertFalse(pd.isPreferred());
- }
-
- public void testPropertyDescriptorStringMethodMethod_WriteMethodInvalid()
- throws SecurityException, NoSuchMethodException,
- IntrospectionException {
- String propertyName = "PropertyOne";
- Class<MockJavaBean> beanClass = MockJavaBean.class;
- String anotherProp = "PropertyTwo";
-
- Method readMethod = beanClass.getMethod("get" + propertyName,
- (Class[]) null);
- Method writeMethod = beanClass.getMethod("set" + anotherProp,
- new Class[] { Integer.class });
- try {
- new PropertyDescriptor(propertyName, readMethod, writeMethod);
- fail("Should throw IntrospectionException.");
- } catch (IntrospectionException e) {
- }
-
- }
-
- /**
- * @throws Exception
- */
- public void testPropertyDescriptorStringClassMethodMethod_SubClass()
- throws Exception {
- PropertyDescriptor pd = new PropertyDescriptor(
- "prop1", SubMockJavaBean.class, null, "setPropertyOne"); //$NON-NLS-1$ //$NON-NLS-2$
- assertNull(pd.getReadMethod());
- assertEquals("setPropertyOne", pd.getWriteMethod().getName()); //$NON-NLS-1$
-
- pd = new PropertyDescriptor(
- "prop1", SubMockJavaBean.class, "getPropertyOne", "setPropertyOne"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- assertEquals("getPropertyOne", pd.getReadMethod().getName()); //$NON-NLS-1$
- assertEquals("setPropertyOne", pd.getWriteMethod().getName()); //$NON-NLS-1$
-
- pd = new PropertyDescriptor(
- "prop1", SubMockJavaBean.class, "getPropertyOne", null); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals("getPropertyOne", pd.getReadMethod().getName()); //$NON-NLS-1$
- assertNull(pd.getWriteMethod());
- }
-
- public void testSetReadMethod() throws SecurityException,
- NoSuchMethodException, IntrospectionException {
- Class<MockJavaBean> beanClass = MockJavaBean.class;
- String propertyName = "PropertyOne";
- Method readMethod = beanClass.getMethod("get" + propertyName,
- (Class[]) null);
- PropertyDescriptor pd = new PropertyDescriptor(propertyName, null, null);
-
- assertNull(pd.getReadMethod());
- pd.setReadMethod(readMethod);
- assertSame(readMethod, pd.getReadMethod());
- }
-
- public void testSetReadMethod_Null() throws SecurityException,
- NoSuchMethodException, IntrospectionException {
- Class<MockJavaBean> beanClass = MockJavaBean.class;
- String propertyName = "PropertyOne";
- Method readMethod = beanClass.getMethod("get" + propertyName,
- (Class[]) null);
- PropertyDescriptor pd = new PropertyDescriptor(propertyName,
- readMethod, null);
-
- assertSame(readMethod, pd.getReadMethod());
- pd.setReadMethod(null);
- assertNull(pd.getReadMethod());
- }
-
- /**
- * Read method is incompatible with property name getPropertyTwo vs.
- * PropertyOne (writeMethod=null)
- */
- public void testSetReadMethod_Invalid() throws SecurityException,
- NoSuchMethodException, IntrospectionException {
- Class<MockJavaBean> beanClass = MockJavaBean.class;
- String propertyName = "PropertyOne";
- Method readMethod = beanClass.getMethod("get" + "PropertyTwo",
- (Class[]) null);
- PropertyDescriptor pd = new PropertyDescriptor(propertyName, null, null);
-
- assertNull(pd.getReadMethod());
- pd.setReadMethod(readMethod);
- assertSame(readMethod, pd.getReadMethod());
- }
-
- /**
- * String invalidGetMethod(String arg)
- */
- public void testSetReadMethod_Invalid_withArg() throws SecurityException,
- NoSuchMethodException, IntrospectionException {
- Class<MockJavaBean> beanClass = MockJavaBean.class;
- String propertyName = "PropertyOne";
- Method readMethod = beanClass.getMethod("invalidGetMethod",
- new Class[] { String.class });
- PropertyDescriptor pd = new PropertyDescriptor(propertyName, null, null);
-
- assertNull(pd.getReadMethod());
- try {
- pd.setReadMethod(readMethod);
- fail("Should throw IntrospectionException.");
- } catch (IntrospectionException e) {
- }
- }
-
- /**
- * String invalidGetMethod(String arg)
- */
- public void testSetReadMethod_Invalid_returnVoid()
- throws SecurityException, NoSuchMethodException,
- IntrospectionException {
- Class<MockJavaBean> beanClass = MockJavaBean.class;
- String propertyName = "PropertyOne";
- Method readMethod = beanClass.getMethod("invalidGetMethod",
- (Class[]) null);
- PropertyDescriptor pd = new PropertyDescriptor(propertyName, null, null);
-
- assertNull(pd.getReadMethod());
- try {
- pd.setReadMethod(readMethod);
- fail("Should throw IntrospectionException.");
- } catch (IntrospectionException e) {
- }
- }
-
- /**
- * Read method is incompatible with write method getPropertyOn vs.
- * setPropertyTow
- */
- public void testSetReadMethod_ReadWriteIncompatible()
- throws SecurityException, NoSuchMethodException,
- IntrospectionException {
- Class<MockJavaBean> beanClass = MockJavaBean.class;
- String propertyName = "PropertyOne";
- Method readMethod = beanClass.getMethod("get" + "PropertyOne",
- (Class[]) null);
- Method writeMethod = beanClass.getMethod("set" + "PropertyTwo",
- new Class[] { Integer.class });
-
- PropertyDescriptor pd = new PropertyDescriptor(propertyName, null,
- writeMethod);
-
- assertNull(pd.getReadMethod());
- try {
- pd.setReadMethod(readMethod);
- fail("Should throw IntrospectionException.");
- } catch (IntrospectionException e) {
- }
- }
-
- /**
- * normal input
- */
- public void testSetWriteMethod() throws SecurityException,
- NoSuchMethodException, IntrospectionException {
- Class<MockJavaBean> beanClass = MockJavaBean.class;
- String propertyName = "PropertyOne";
- Method writeMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { String.class });
- PropertyDescriptor pd = new PropertyDescriptor(propertyName, null, null);
-
- assertNull(pd.getWriteMethod());
- pd.setWriteMethod(writeMethod);
- assertSame(writeMethod, pd.getWriteMethod());
- }
-
- /**
- * setWriteMethod(null)
- */
- public void testSetWriteMethod_Null() throws SecurityException,
- NoSuchMethodException, IntrospectionException {
- Class<MockJavaBean> beanClass = MockJavaBean.class;
- String propertyName = "PropertyOne";
- Method writeMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { String.class });
- PropertyDescriptor pd = new PropertyDescriptor(propertyName, null,
- writeMethod);
-
- assertSame(writeMethod, pd.getWriteMethod());
- pd.setWriteMethod(null);
- assertNull(pd.getWriteMethod());
- }
-
- /**
- * write method is incompatible with property name (read method is null)
- */
- public void testSetWriteMethod_Invalid() throws SecurityException,
- NoSuchMethodException, IntrospectionException {
- Class<MockJavaBean> beanClass = MockJavaBean.class;
- String propertyName = "PropertyOne";
- Method writeMethod = beanClass.getMethod("set" + "PropertyTwo",
- new Class[] { Integer.class });
- PropertyDescriptor pd = new PropertyDescriptor(propertyName, null, null);
-
- assertNull(pd.getWriteMethod());
- pd.setWriteMethod(writeMethod);
- assertSame(writeMethod, pd.getWriteMethod());
- }
-
- /**
- * write method without argument
- */
- public void testSetWriteMethod_Invalid_NoArgs() throws SecurityException,
- NoSuchMethodException, IntrospectionException {
- Class<MockJavaBean> beanClass = MockJavaBean.class;
- String propertyName = "PropertyOne";
- Method writeMethod = beanClass.getMethod("get" + "PropertyTwo",
- (Class[]) null);
- PropertyDescriptor pd = new PropertyDescriptor(propertyName, null, null);
-
- assertNull(pd.getWriteMethod());
- try {
- pd.setWriteMethod(writeMethod);
- fail("Should throw IntrospectionException.");
- } catch (IntrospectionException e) {
- }
- }
-
- /**
- * write method is incompatible with read method
- */
- public void testSetWriteMethod_WriteReadIncompatible()
- throws SecurityException, NoSuchMethodException,
- IntrospectionException {
- Class<MockJavaBean> beanClass = MockJavaBean.class;
- String propertyName = "PropertyOne";
- Method readMethod = beanClass.getMethod("get" + "PropertyTwo",
- (Class[]) null);
- Method writeMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { String.class });
- PropertyDescriptor pd = new PropertyDescriptor(propertyName,
- readMethod, null);
-
- assertNull(pd.getWriteMethod());
- try {
- pd.setWriteMethod(writeMethod);
- fail("Should throw IntrospectionException.");
- } catch (IntrospectionException e) {
- }
- }
-
- class MockJSplitPane extends javax.swing.JSplitPane {
-
- private static final long serialVersionUID = 3109235561744543400L;
-
- public int getDividerLocation(int dividerLocation) {
- return super.getDividerLocation();
- }
-
- public void setDividerLocation(int dividerLocation) {
- super.setDividerLocation(dividerLocation);
- }
- }
-
- public void test_setReadMethod_MockJSplitPane() throws Exception {
- Class<?> beanClass = MockJSplitPane.class;
- String propertyName = "dividerLocation";
- String getterName = "getDividerLocation";
- PropertyDescriptor pd = new PropertyDescriptor(propertyName, beanClass,
- getterName, null);
- assertEquals(propertyName, pd.getName());
- assertNull(pd.getWriteMethod());
-
- Method expectedMethod = beanClass.getMethod(getterName, new Class[0]);
- assertEquals(expectedMethod, pd.getReadMethod());
-
- getterName = "notFoundGetter";
- pd = new PropertyDescriptor(propertyName, beanClass, getterName, null);
- assertEquals(propertyName, pd.getName());
- assertNull(pd.getWriteMethod());
- assertEquals(expectedMethod, pd.getReadMethod());
- }
-
- public void test_setWriteMethod_MockJSplitPane() throws Exception {
- Class<?> beanClass = MockJSplitPane.class;
- String propertyName = "dividerLocation";
- String setterName = "setDividerLocation";
- PropertyDescriptor pd = new PropertyDescriptor(propertyName, beanClass,
- null, setterName);
- assertEquals(propertyName, pd.getName());
- assertNull(pd.getReadMethod());
-
- Method expectedMethod = beanClass.getMethod(setterName,
- new Class[] { int.class });
- assertEquals(expectedMethod, pd.getWriteMethod());
-
- setterName = "notFoundSetter";
- try {
- new PropertyDescriptor(propertyName, beanClass, null, setterName);
- fail("should throw IntrospectionException");
- } catch (IntrospectionException e) {
- // Expected
- }
- }
-
- public void test_setRead$WriteMethod_MockJSplitPane() throws Exception {
- Class<?> beanClass = MockJSplitPane.class;
- String propertyName = "dividerLocation";
- String getterName = "getDividerLocation";
- String setterName = "setDividerLocation";
- PropertyDescriptor pd = new PropertyDescriptor(propertyName, beanClass,
- getterName, setterName);
- assertEquals(propertyName, pd.getName());
- Method expectedGetterMethod = beanClass.getMethod(getterName,
- new Class[0]);
- assertEquals(expectedGetterMethod, pd.getReadMethod());
-
- Method expectedSetterMethod = beanClass.getMethod(setterName,
- new Class[] { int.class });
- assertEquals(expectedSetterMethod, pd.getWriteMethod());
-
- new PropertyDescriptor(propertyName, beanClass, getterName + 1,
- setterName);
- assertEquals(expectedGetterMethod, pd.getReadMethod());
- assertEquals(expectedSetterMethod, pd.getWriteMethod());
-
- try {
- new PropertyDescriptor(propertyName, beanClass, getterName,
- setterName + 1);
- fail("should throw IntrospectionException");
- } catch (IntrospectionException e) {
- // Expected
- }
- try {
- new PropertyDescriptor(propertyName, beanClass, getterName + 1,
- setterName + 1);
- fail("should throw IntrospectionException");
- } catch (IntrospectionException e) {
- // Expected
- }
- }
-
- public void testSetBound_true() throws SecurityException,
- NoSuchMethodException, IntrospectionException {
- Class<MockJavaBean> beanClass = MockJavaBean.class;
- String propertyName = "PropertyOne";
- Method readMethod = beanClass.getMethod("get" + propertyName,
- (Class[]) null);
- Method writeMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { String.class });
- PropertyDescriptor pd = new PropertyDescriptor(propertyName,
- readMethod, writeMethod);
- pd.setBound(true);
-
- assertTrue(pd.isBound());
- assertFalse(pd.isConstrained());
- assertNull(pd.getPropertyEditorClass());
-
- assertEquals(propertyName, pd.getDisplayName());
- assertEquals(propertyName, pd.getName());
- assertEquals(propertyName, pd.getShortDescription());
-
- assertNotNull(pd.attributeNames());
-
- assertFalse(pd.isExpert());
- assertFalse(pd.isHidden());
- assertFalse(pd.isPreferred());
- }
-
- public void testSetBound_false() throws SecurityException,
- NoSuchMethodException, IntrospectionException {
- Class<MockJavaBean> beanClass = MockJavaBean.class;
- String propertyName = "PropertyOne";
- Method readMethod = beanClass.getMethod("get" + propertyName,
- (Class[]) null);
- Method writeMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { String.class });
- PropertyDescriptor pd = new PropertyDescriptor(propertyName,
- readMethod, writeMethod);
- pd.setBound(false);
-
- assertFalse(pd.isBound());
- assertFalse(pd.isConstrained());
- assertNull(pd.getPropertyEditorClass());
-
- assertEquals(propertyName, pd.getDisplayName());
- assertEquals(propertyName, pd.getName());
- assertEquals(propertyName, pd.getShortDescription());
-
- assertNotNull(pd.attributeNames());
-
- assertFalse(pd.isExpert());
- assertFalse(pd.isHidden());
- assertFalse(pd.isPreferred());
- }
-
- public void testSetConstrained_true() throws SecurityException,
- NoSuchMethodException, IntrospectionException {
- Class<MockJavaBean> beanClass = MockJavaBean.class;
- String propertyName = "PropertyOne";
- Method readMethod = beanClass.getMethod("get" + propertyName,
- (Class[]) null);
- Method writeMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { String.class });
- PropertyDescriptor pd = new PropertyDescriptor(propertyName,
- readMethod, writeMethod);
- pd.setConstrained(true);
-
- assertTrue(pd.isConstrained());
- assertFalse(pd.isBound());
- assertNull(pd.getPropertyEditorClass());
-
- assertEquals(propertyName, pd.getDisplayName());
- assertEquals(propertyName, pd.getName());
- assertEquals(propertyName, pd.getShortDescription());
-
- assertNotNull(pd.attributeNames());
-
- assertFalse(pd.isExpert());
- assertFalse(pd.isHidden());
- assertFalse(pd.isPreferred());
- }
-
- public void testSetConstrained_false() throws SecurityException,
- NoSuchMethodException, IntrospectionException {
- Class<MockJavaBean> beanClass = MockJavaBean.class;
- String propertyName = "PropertyOne";
- Method readMethod = beanClass.getMethod("get" + propertyName,
- (Class[]) null);
- Method writeMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { String.class });
- PropertyDescriptor pd = new PropertyDescriptor(propertyName,
- readMethod, writeMethod);
- pd.setConstrained(false);
-
- assertFalse(pd.isConstrained());
- assertFalse(pd.isBound());
- assertNull(pd.getPropertyEditorClass());
-
- assertEquals(propertyName, pd.getDisplayName());
- assertEquals(propertyName, pd.getName());
- assertEquals(propertyName, pd.getShortDescription());
-
- assertNotNull(pd.attributeNames());
-
- assertFalse(pd.isExpert());
- assertFalse(pd.isHidden());
- assertFalse(pd.isPreferred());
- }
-
- /**
- * PropertyDescriptor does not ensure if the editor class is valid or not.
- */
- public void testSetPropertyEditorClass() throws SecurityException,
- NoSuchMethodException, IntrospectionException {
- Class<MockJavaBean> beanClass = MockJavaBean.class;
- String propertyName = "PropertyOne";
- Method readMethod = beanClass.getMethod("get" + propertyName,
- (Class[]) null);
- Method writeMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { String.class });
- PropertyDescriptor pd = new PropertyDescriptor(propertyName,
- readMethod, writeMethod);
- Class<? extends String> editorClass = "This is an invalid editor class".getClass();
- pd.setPropertyEditorClass(editorClass);
- assertSame(editorClass, pd.getPropertyEditorClass());
- }
-
- public void testSetPropertyEditorClass_null() throws SecurityException,
- NoSuchMethodException, IntrospectionException {
- Class<MockJavaBean> beanClass = MockJavaBean.class;
- String propertyName = "PropertyOne";
- Method readMethod = beanClass.getMethod("get" + propertyName,
- (Class[]) null);
- Method writeMethod = beanClass.getMethod("set" + propertyName,
- new Class[] { String.class });
- PropertyDescriptor pd = new PropertyDescriptor(propertyName,
- readMethod, writeMethod);
-
- pd.setPropertyEditorClass(null);
- assertNull(pd.getPropertyEditorClass());
- }
-
- public void testConstructor_1() throws IntrospectionException {
- new PropertyDescriptor("fox01", FakeFox01.class);
- }
-
- // Regression test for HARMONY-237
- public void testIntrospectionExceptions() {
- try {
- new PropertyDescriptor(null, null);
- fail("Constructor PropertyDescriptor(null,null) should "
- + "throw IntrospectionException");
- } catch (IntrospectionException e) {
- assertEquals("Target Bean class is null", e.getMessage());
- }
- try {
- new PropertyDescriptor(null, String.class);
- fail("Constructor PropertyDescriptor(null,String.class) should "
- + "throw IntrospectionException");
- } catch (IntrospectionException e) {
- assertEquals("bad property name", e.getMessage());
- }
- try {
- new PropertyDescriptor(null, null, null, null);
- fail("Constructor PropertyDescriptor(null,null,null,null) should "
- + "throw IntrospectionException");
- } catch (IntrospectionException e) {
- assertEquals("Target Bean class is null", e.getMessage());
- }
- try {
- new PropertyDescriptor(null, String.class, null, null);
- fail("Constructor "
- + "PropertyDescriptor(null,String.class,null,null) should "
- + "throw IntrospectionException");
- } catch (IntrospectionException e) {
- assertEquals("bad property name", e.getMessage());
- }
- try {
- new PropertyDescriptor(null, null, null);
- fail("Constructor PropertyDescriptor(null,null,null) should "
- + "throw IntrospectionException");
- } catch (IntrospectionException e) {
- assertEquals("bad property name", e.getMessage());
- }
- try {
- new PropertyDescriptor("", null, null);
- fail("Constructor PropertyDescriptor(\"\",null,null) should "
- + "throw IntrospectionException");
- } catch (IntrospectionException e) {
- assertEquals("bad property name", e.getMessage());
- }
- }
-
- public void testCreatePropertyEditor() throws IntrospectionException {
- PropertyDescriptor pd = new PropertyDescriptor("propertyOne",
- MockJavaBean.class);
- PropertyEditor pe;
-
- pe = pd.createPropertyEditor(this);
- assertNull(pe);
-
- pd.setPropertyEditorClass(CoolPropertyEditor.class);
- pe = pd.createPropertyEditor(this);
- assertNotNull(pe);
- pe.setAsText("Harmony");
- assertEquals("Harmony is cool", pe.getAsText());
-
- pd.setPropertyEditorClass(VeryCoolPropertyEditor.class);
- pe = pd.createPropertyEditor(this);
- assertNotNull(pe);
- pe.setAsText("Harmony");
- assertEquals("Harmony is really cool", pe.getAsText());
-
- pd.setPropertyEditorClass(null);
- pe = pd.createPropertyEditor(this);
- assertNull(pe);
-
- }
-
- public void testCreatePropertyEditor_Invalid()
- throws IntrospectionException {
- PropertyDescriptor pd = new PropertyDescriptor("propertyOne",
- MockJavaBean.class);
-
- try {
- pd.setPropertyEditorClass(InvalidPropertyEditor.class);
- pd.createPropertyEditor(this);
- fail("RuntimeException expected");
- } catch (RuntimeException e) {
- // valid
- }
-
- try {
- pd.setPropertyEditorClass(InvalidPropertyEditor2.class);
- pd.createPropertyEditor(this);
- fail("ClassCastException expected");
- } catch (ClassCastException e) {
- // valid
- }
- }
-
- static class FakeFox01 {
-
- public String getFox01() {
- return null;
- }
-
- public void setFox01(String value) {
- }
- }
-
- class MockBeanPropertyDesc implements Serializable {
-
- /**
- * Comment for <code>serialVersionUID</code>
- */
- private static final long serialVersionUID = 1L;
-
- Integer propertyOne;
-
- /**
- * @return Returns the propertyOne.
- */
- public Integer getPropertyOne() {
- return propertyOne;
- }
-
- /**
- * @param propertyOne
- * The propertyOne to set.
- */
- public void setPropertyOne(Integer propertyOne) {
- this.propertyOne = propertyOne;
- }
- }
-
- class SubMockJavaBean extends MockJavaBean {
-
- /**
- * Comment for <code>serialVersionUID</code>
- */
- private static final long serialVersionUID = 7423254295680570566L;
- //
- }
-
- public static class CoolPropertyEditor extends PropertyEditorSupport {
- String str;
-
- String suffix;
-
- public CoolPropertyEditor() {
- suffix = " is cool";
- }
-
- @Override
- public void setAsText(String newVal) {
- str = newVal + suffix;
- }
-
- @Override
- public String getAsText() {
- return str;
- }
- };
-
- public static class VeryCoolPropertyEditor extends CoolPropertyEditor {
- public VeryCoolPropertyEditor() {
- super();
- }
-
- public VeryCoolPropertyEditor(Object obj) {
- suffix = " is really cool";
- }
- }
-
- public static class InvalidPropertyEditor extends PropertyEditorSupport {
- // there is no valid constructors
- public InvalidPropertyEditor(Object arg1, Object arg2) {
- }
- }
-
- public static class InvalidPropertyEditor2 {
- // is not assignable from PropertyEditor
- public InvalidPropertyEditor2() {
- }
- }
-
- //Regression Test
-
- private class MockBean {
- int a;
- public int getA() {
- return a;
- }
-
- public void setA(int a) {
- this.a = a;
- }
- }
-
- public void testHashCode() throws IntrospectionException,
- SecurityException, NoSuchMethodException {
- PropertyDescriptor pd1 = new PropertyDescriptor("a",MockBean.class);
- PropertyDescriptor pd2 = new PropertyDescriptor("a",MockBean.class);
- assertEquals(pd1, pd2);
- assertEquals(pd1.hashCode(), pd2.hashCode());
- }
-
- private class MockBeanForTR {
- int i;
-
- public int getI() {
- return i;
- }
-
- public void setI(int i) {
- this.i = i;
- }
- }
-
- public void testByLocale() throws IntrospectionException{
- Locale backup = Locale.getDefault();
- Locale.setDefault(new Locale("TR"));
- try {
- assertNotNull(new PropertyDescriptor("i", MockBeanForTR.class));
- } finally {
- Locale.setDefault(backup);
- }
- }
-}
diff --git a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PropertyEditorManagerRegressionTest.java b/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PropertyEditorManagerRegressionTest.java
deleted file mode 100644
index 6b8390d..0000000
--- a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PropertyEditorManagerRegressionTest.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * 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.java.beans;
-
-import java.awt.Color;
-import java.beans.PropertyEditor;
-import java.beans.PropertyEditorManager;
-import java.io.InputStream;
-import java.io.IOException;
-
-import junit.framework.TestCase;
-
-/**
- * Regression test for PropertyEditorManager
- */
-public class PropertyEditorManagerRegressionTest extends TestCase {
-
- static String origPath[] = PropertyEditorManager.getEditorSearchPath();
-
- private final String MOCK_TEST_CLASS_EDITOR = "testPackage.TestClassEditor";
-
- private final String MOCK_TEST_CLASS_EDITOR_FILE
- = "binary/java/beans/mock/TestClassEditor.bin";
-
- public void testFindEditorAccordingPath_1() throws Exception {
- // Regression Harmony-1205
- String newPath[] = new String[origPath.length + 1];
- newPath[0] = "org.apache.harmony.beans.tests.support";
- for (int i = 0; i < origPath.length; i++) {
- newPath[i + 1] = origPath[i];
- }
-
- PropertyEditorManager.setEditorSearchPath(newPath);
-
- PropertyEditor editor = PropertyEditorManager.findEditor(Class
- .forName("java.lang.String"));
-
- assertEquals(org.apache.harmony.beans.tests.support.StringEditor.class,
- editor.getClass());
- }
-
- public void testFindEditorAccordingPath_2() throws Exception {
- // Regression Harmony-1205
- String newPath[] = new String[origPath.length + 1];
- newPath[origPath.length] = "org.apache.harmony.beans.tests.support";
- for (int i = 0; i < origPath.length; i++) {
- newPath[i] = origPath[i];
- }
-
- PropertyEditorManager.setEditorSearchPath(newPath);
-
- PropertyEditor editor = PropertyEditorManager.findEditor(Class
- .forName("java.lang.String"));
-
- assertEquals(org.apache.harmony.beans.editors.StringEditor.class,
- editor.getClass());
- }
-
- public void testFindEditorAccordingPath_3() throws Exception {
- // Regression Harmony-5477
- class TestClassLoader extends ClassLoader {
- protected Class<?> findClass(String name) throws ClassNotFoundException {
- if (!MOCK_TEST_CLASS_EDITOR.equals(name)) {
- throw new ClassNotFoundException(name);
- }
-
- try {
- byte[] buf = new byte[1024];
- InputStream in = getResourceAsStream(MOCK_TEST_CLASS_EDITOR_FILE);
- int sz = 0;
- int read;
-
- while ((read = in.read(buf, sz, buf.length - sz)) >= 0) {
- sz += read;
- }
- return defineClass(MOCK_TEST_CLASS_EDITOR, buf, 0, sz);
- } catch (IOException e) {
- throw (ClassNotFoundException) new ClassNotFoundException(
- e.getMessage()).initCause(e);
- }
- }
- }
- PropertyEditorManager.setEditorSearchPath(new String[] { "testPackage" });
- ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
-
- try {
- Thread.currentThread().setContextClassLoader(new TestClassLoader());
- PropertyEditor editor = PropertyEditorManager.findEditor(TestClass.class);
- assertEquals(MOCK_TEST_CLASS_EDITOR, editor.getClass().getName());
- } finally {
- Thread.currentThread().setContextClassLoader(oldLoader);
- }
- }
-
- public void testStringEditor() throws Exception {
- // Regression Harmony-1199
- PropertyEditorManager.setEditorSearchPath(origPath);
- PropertyEditor editor = PropertyEditorManager.findEditor(Class
- .forName("java.lang.String"));
- String text = "A sample string";
-
- editor.setAsText(text);
- assertEquals(text, editor.getAsText());
- }
-
- // Regression Harmony-4062
- public void testColorEditor() {
- PropertyEditor propertyEditor = PropertyEditorManager
- .findEditor(Color.class);
- propertyEditor.setValue(new Color(0, 0, 0));
- propertyEditor.setAsText("1,2,3");
- Color newColor = new Color(1, 2, 3);
- assertEquals(newColor, propertyEditor.getValue());
-
- try {
- propertyEditor.setAsText(null);
- fail("should throw NullPointerException");
- } catch (NullPointerException e) {
- // expected.
- }
-
- try {
- propertyEditor.setAsText("illegalArugment");
- fail("should throw IllegalArgumentException");
- } catch (IllegalArgumentException e) {
- // expected.
- }
-
- try {
- propertyEditor.setAsText("1,2,3,4");
- fail("should throw IllegalArgumentException");
- } catch (IllegalArgumentException e) {
- //expected.
- }
- }
-
- String[] defaultSearchPath;
-
- public void setUp(){
- defaultSearchPath = PropertyEditorManager.getEditorSearchPath();
- }
-
- public void tearDown(){
- PropertyEditorManager.setEditorSearchPath(defaultSearchPath);
- }
-}
-
-class TestClass {}
diff --git a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PropertyEditorManagerTest.java b/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PropertyEditorManagerTest.java
deleted file mode 100644
index 86bb67f..0000000
--- a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PropertyEditorManagerTest.java
+++ /dev/null
@@ -1,897 +0,0 @@
-/*
- * 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.java.beans;
-
-import java.awt.Color;
-import java.awt.Component;
-import java.awt.Font;
-import java.awt.Graphics;
-import java.awt.Panel;
-import java.awt.Rectangle;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyEditor;
-import java.beans.PropertyEditorManager;
-import java.util.Arrays;
-
-import junit.framework.TestCase;
-
-import org.apache.harmony.beans.tests.support.AnotherSampleProperty;
-import org.apache.harmony.beans.tests.support.AnotherSamplePropertyEditor;
-import org.apache.harmony.beans.tests.support.OtherEditor;
-import org.apache.harmony.beans.tests.support.SampleProperty;
-import org.apache.harmony.beans.tests.support.SamplePropertyEditor;
-import org.apache.harmony.beans.tests.support.mock.Foz;
-import org.apache.harmony.beans.tests.support.mock.Fozz;
-import org.apache.harmony.beans.tests.support.mock.FozzEditor;
-import org.apache.harmony.beans.tests.support.mock.Fozzz;
-import org.apache.harmony.beans.tests.support.mock.MockButton;
-import org.apache.harmony.beans.tests.support.mock.MockFoo;
-
-/**
- * Unit test for PropertyEditorManager
- */
-public class PropertyEditorManagerTest extends TestCase {
-
- /*
- * Constructors
- */
- public void testPropertyEditorManager() {
- new PropertyEditorManager();
- }
-
- /*
- * find the editor which has been registered through registerEditor.
- */
- public void testFindEditor_registered() {
- Class<FozRegisteredEditor> editorClass = FozRegisteredEditor.class;
- Class<Foz> type = Foz.class;
- PropertyEditorManager.registerEditor(type, editorClass);
- PropertyEditor editor = PropertyEditorManager.findEditor(type);
- assertTrue(editor instanceof FozRegisteredEditor);
- assertEquals(editorClass, editor.getClass());
- }
-
- /*
- * Find editor of which name is XXXEditor in the same package
- */
- public void testFindEditor_SamePackage() {
- PropertyEditor editor = PropertyEditorManager.findEditor(Fozz.class);
- assertTrue(editor instanceof FozzEditor);
- assertEquals(FozzEditor.class, editor.getClass());
- }
-
- /*
- * Find editor in search path
- */
- public void testFindEditor_DifferentPackage() {
- String[] original = PropertyEditorManager.getEditorSearchPath();
- PropertyEditorManager
- .setEditorSearchPath(new String[] { "org.apache.harmony.beans.tests.java.beans" });
- PropertyEditor editor = PropertyEditorManager.findEditor(Fozzz.class);
- assertTrue(editor instanceof FozzzEditor);
- assertEquals(FozzzEditor.class, editor.getClass());
-
- PropertyEditorManager.setEditorSearchPath(original);
- }
-
- /*
- * Find editor for Java primitive types and java.lang.String.
- * java.awt.Color, and java.awt.Font
- */
- public void testFindEditor_DefaultType() {
- PropertyEditorManager.findEditor(Integer.TYPE);
- }
-
- // Regression test for HARMONY-258
- public void testFindEditor_TypeNull() {
- try {
- PropertyEditorManager.findEditor(null);
- fail("Should throw NullPointerException");
- } catch (NullPointerException e) {
- // Expected
- }
- }
-
- public void testFindEditor_TypeNoEditor() {
- assertNull(PropertyEditorManager.findEditor(MockFoo.class));
- }
-
- public void testGetEditorSearchPath_default() {
- String[] path = PropertyEditorManager.getEditorSearchPath();
- assertEquals(1, path.length);
- assertTrue(path[0].endsWith("beans.editors"));
- }
-
- public void testGetEditorSearchPath() {
- String[] original = PropertyEditorManager.getEditorSearchPath();
-
- String[] path = new String[] { "java.beans",
- "org.apache.harmony.beans.tests.java.beans.editor", "", };
- PropertyEditorManager.setEditorSearchPath(path);
- String[] newPath = PropertyEditorManager.getEditorSearchPath();
-
- assertTrue(Arrays.equals(path, newPath));
-
- PropertyEditorManager.setEditorSearchPath(original);
- }
-
- /*
- * RegisterEditor
- */
- public void testRegisterEditor() {
- Class<MockButton> type = MockButton.class;
-
- PropertyEditorManager.registerEditor(type, ButtonEditor.class);
- PropertyEditor editor = PropertyEditorManager.findEditor(type);
- assertEquals(ButtonEditor.class, editor.getClass());
-
- PropertyEditorManager.registerEditor(type, FozRegisteredEditor.class);
- editor = PropertyEditorManager.findEditor(type);
- assertEquals(FozRegisteredEditor.class, editor.getClass());
-
- PropertyEditorManager.registerEditor(type, null);
- editor = PropertyEditorManager.findEditor(type);
- assertNull(editor);
- }
-
- /*
- * registerEditor for type null Regression test for HARMONY-258
- */
- public void testRegisterEditorType_Null() {
- try {
- PropertyEditorManager.registerEditor(null, ButtonEditor.class);
- fail("Should throw NullPointerException");
- } catch (NullPointerException e) {
- // Expected
- }
- }
-
- /*
- * set search path as {null}
- */
- public void testSetEditorSearchPath_nullpath() {
- String[] original = PropertyEditorManager.getEditorSearchPath();
- PropertyEditorManager.setEditorSearchPath(new String[] { null });
- assertEquals(1, PropertyEditorManager.getEditorSearchPath().length);
- assertNull(PropertyEditorManager.getEditorSearchPath()[0]);
- assertNull(PropertyEditorManager.findEditor(PropertyEditorManagerTest.class));
- PropertyEditorManager.setEditorSearchPath(original);
- }
-
- /*
- * set search null
- */
- public void testSetEditorSearchPath_null() {
- String[] original = PropertyEditorManager.getEditorSearchPath();
- PropertyEditorManager.setEditorSearchPath(null);
- assertEquals(0, PropertyEditorManager.getEditorSearchPath().length);
- PropertyEditorManager.setEditorSearchPath(original);
- }
-
- // Test internal Editor
- public void testBoolEditor_setAsText() {
- PropertyEditor editor = PropertyEditorManager.findEditor(Boolean.TYPE);
- editor.setAsText("false");
- assertEquals("false", editor.getAsText().toLowerCase());
- assertEquals("false", editor.getJavaInitializationString());
- assertEquals("True", editor.getTags()[0]);
- assertEquals("False", editor.getTags()[1]);
- assertEquals(Boolean.FALSE, editor.getValue());
-
- editor.setAsText("TrUE");
- assertEquals("true", editor.getAsText().toLowerCase());
- assertEquals("true", editor.getJavaInitializationString());
- assertEquals(Boolean.TRUE, editor.getValue());
- }
-
- public void testBoolEditor_setAsText_null() {
- PropertyEditor editor = PropertyEditorManager.findEditor(Boolean.TYPE);
- try {
- editor.setAsText(null);
- fail("Should throw NullPointerException");
- } catch (NullPointerException e) {
- // Expected
- }
- }
-
- public void testBoolEditor_setAsText_Invalid() {
- PropertyEditor editor = PropertyEditorManager.findEditor(Boolean.TYPE);
- try {
- editor.setAsText("yes");
- fail("Should throw IllegalArgumentException");
- } catch (IllegalArgumentException e) {
- // Expected
- }
- try {
- editor.setAsText("***true***");
- fail("Should throw IllegalArgumentException");
- } catch (IllegalArgumentException e) {
- // Expected
- }
- }
-
- // Regression test for HARMONY-5711
- @SuppressWarnings("nls")
- public void testBooleanEditor() {
- PropertyEditor propertyEditor = PropertyEditorManager
- .findEditor(boolean.class);
- assertNotNull(propertyEditor);
- String tags[] = propertyEditor.getTags();
- assertEquals(2, tags.length);
- assertEquals("True", tags[0]);
- assertEquals("False", tags[1]);
-
- propertyEditor.setValue(Boolean.FALSE);
- assertEquals("False", propertyEditor.getAsText());
- assertEquals("false", propertyEditor.getJavaInitializationString());
- propertyEditor.setAsText("False");
- assertEquals("False", propertyEditor.getAsText());
- assertEquals("false", propertyEditor.getJavaInitializationString());
- propertyEditor.setAsText("false");
- assertEquals("False", propertyEditor.getAsText());
- assertEquals("false", propertyEditor.getJavaInitializationString());
-
- propertyEditor.setValue(Boolean.TRUE);
- assertEquals("True", propertyEditor.getAsText());
- assertEquals("true", propertyEditor.getJavaInitializationString());
- propertyEditor.setAsText("True");
- assertEquals("True", propertyEditor.getAsText());
- assertEquals("true", propertyEditor.getJavaInitializationString());
- propertyEditor.setAsText("true");
- assertEquals("True", propertyEditor.getAsText());
- assertEquals("true", propertyEditor.getJavaInitializationString());
- }
-
- public void testByteEditor() {
- PropertyEditor editor = PropertyEditorManager.findEditor(Byte.TYPE);
- byte b = (byte) 0x7F;
- editor.setAsText(Byte.toString(b));
- assertEquals(Byte.toString(b), editor.getAsText());
- assertEquals("((byte)127)", editor.getJavaInitializationString());
- assertEquals(new Byte(b), editor.getValue());
- assertNull(editor.getTags());
- }
-
- public void testByteEditor_null() {
- PropertyEditor editor = PropertyEditorManager.findEditor(Byte.TYPE);
- try {
- editor.setAsText(null);
- fail("Should throw NumberFormatException");
- } catch (NumberFormatException e) {
- // Expected
- }
- }
-
- public void testByteEditor_invalid() {
- PropertyEditor editor = PropertyEditorManager.findEditor(Byte.TYPE);
- try {
- editor.setAsText("invalid");
- fail("Should throw NumberFormatException");
- } catch (NumberFormatException e) {
- // Expected
- }
- }
-
- public void testByteEditor_invalid2() {
- PropertyEditor editor = PropertyEditorManager.findEditor(Byte.TYPE);
- try {
- editor.setAsText("128");
- fail("Should throw NumberFormatException");
- } catch (NumberFormatException e) {
- // Expected
- }
- }
-
- public void testDoubleEditor() {
- PropertyEditor editor = PropertyEditorManager.findEditor(Double.TYPE);
- double d = 12345.678;
- editor.setAsText(Double.toString(d));
- assertEquals(Double.toString(d), editor.getAsText());
- assertEquals(Double.toString(d), editor.getJavaInitializationString());
- assertEquals(new Double(d), editor.getValue());
- assertNull(editor.getTags());
- }
-
- public void testDoubleEditor_SetAsText_Null() {
- PropertyEditor editor = PropertyEditorManager.findEditor(Double.TYPE);
- try {
- editor.setAsText(null);
- fail("Should throw NullPointerException");
- } catch (NullPointerException e) {
- // Expected
- }
- }
-
- public void testDoubleEditor_SetAsText_Invalid() {
- PropertyEditor editor = PropertyEditorManager.findEditor(Double.TYPE);
- try {
- editor.setAsText("invalid");
- fail("Should throw NumberFormatException");
- } catch (NumberFormatException e) {
- // Expected
- }
- }
-
- public void testFloatEditor() {
- PropertyEditor editor = PropertyEditorManager.findEditor(Float.TYPE);
- float f = 12345.678f;
- String text = Float.toString(f);
- editor.setAsText(text);
- assertEquals(text, editor.getAsText());
- assertEquals(text + "F", editor.getJavaInitializationString());
- assertEquals(new Float(f), editor.getValue());
- assertNull(editor.getTags());
- }
-
- public void testFloatEditor_SetAsText_Null() {
- PropertyEditor editor = PropertyEditorManager.findEditor(Float.TYPE);
- try {
- editor.setAsText(null);
- fail("Should throw NullPointerException");
- } catch (NullPointerException e) {
- // Expected
- }
- }
-
- public void testFloatEditor_SetAsText_Invalid() {
- PropertyEditor editor = PropertyEditorManager.findEditor(Float.TYPE);
- try {
- editor.setAsText("invalid");
- fail("Should throw NumberFormatException");
- } catch (NumberFormatException e) {
- // Expected
- }
- }
-
- public void testLongEditor() {
- PropertyEditor editor = PropertyEditorManager.findEditor(Long.TYPE);
- long l = 123456789;
- String text = Long.toString(l);
- editor.setAsText(text);
- assertEquals(text, editor.getAsText());
- assertEquals(text + "L", editor.getJavaInitializationString());
- assertEquals(new Long(l), editor.getValue());
- assertNull(editor.getTags());
- }
-
- public void testLongEditor_SetAsText_Null() {
- PropertyEditor editor = PropertyEditorManager.findEditor(Long.TYPE);
- try {
- editor.setAsText(null);
- fail("Should throw NumberFormatException");
- } catch (NumberFormatException e) {
- // Expected
- }
- }
-
- public void testLongEditor_SetAsText_Invalid() {
- PropertyEditor editor = PropertyEditorManager.findEditor(Long.TYPE);
- try {
- editor.setAsText("invalid");
- fail("Should throw NumberFormatException");
- } catch (NumberFormatException e) {
- // Expected
- }
- }
-
- public void testShortEditor() {
- PropertyEditor editor = PropertyEditorManager.findEditor(Short.TYPE);
- short s = (short) 123456789;
- String text = Short.toString(s);
- editor.setAsText(text);
- assertEquals(text, editor.getAsText());
- assertEquals("((short)" + text + ")", editor
- .getJavaInitializationString());
- assertEquals(new Short(s), editor.getValue());
- assertNull(editor.getTags());
- }
-
- public void testShortEditor_SetAsText_Null() {
- PropertyEditor editor = PropertyEditorManager.findEditor(Short.TYPE);
- try {
- editor.setAsText(null);
- fail("Should throw NumberFormatException");
- } catch (NumberFormatException e) {
- // Expected
- }
- }
-
- public void testShortEditor_SetAsText_Invalid() {
- PropertyEditor editor = PropertyEditorManager.findEditor(Short.TYPE);
- try {
- editor.setAsText("invalid");
- fail("Should throw NumberFormatException");
- } catch (NumberFormatException e) {
- // Expected
- }
- }
-
- public void testIntegerEditor() {
- PropertyEditor editor = PropertyEditorManager.findEditor(Integer.TYPE);
- int i = 123456789;
- String text = Integer.toString(i);
- editor.setAsText(text);
- assertEquals(text, editor.getAsText());
- assertEquals(text, editor.getJavaInitializationString());
- assertEquals(new Integer(i), editor.getValue());
- assertNull(editor.getTags());
- }
-
- public void testIntegerEditor_SetAsText_Null() {
- PropertyEditor editor = PropertyEditorManager.findEditor(Integer.TYPE);
- try {
- editor.setAsText(null);
- fail("Should throw NumberFormatException");
- } catch (NumberFormatException e) {
- // Expected
- }
- }
-
- public void testIntegerEditor_SetAsText_Invalid() {
- PropertyEditor editor = PropertyEditorManager.findEditor(Integer.TYPE);
- try {
- editor.setAsText("invalid");
- fail("Should throw NumberFormatException");
- } catch (NumberFormatException e) {
- // Expected
- }
- }
-
- public void testStringEditor() {
- PropertyEditor editor = PropertyEditorManager.findEditor(String.class);
- String text = "A sample string";
- editor.setAsText(text);
- assertEquals(text, editor.getAsText());
- assertEquals("\"" + text + "\"", editor.getJavaInitializationString());
- assertEquals(text, editor.getValue());
- assertNull(editor.getTags());
- }
-
- public void testStringEditor_SetAsText_Null() {
- PropertyEditor editor = PropertyEditorManager.findEditor(String.class);
-
- editor.setAsText("null");
- assertEquals("null", editor.getAsText());
- assertEquals("\"null\"", editor.getJavaInitializationString());
- assertEquals("null", editor.getValue());
-
- editor.setAsText("");
- assertEquals("", editor.getAsText());
- assertEquals("\"\"", editor.getJavaInitializationString());
-
- editor.setAsText(null);
- assertEquals("null", editor.getAsText());
- assertEquals("\"null\"", editor.getJavaInitializationString());
- assertNull(editor.getValue());
- }
-
- public void testStringEditor_SetAsText_SpecialChars() {
- PropertyEditor editor = PropertyEditorManager.findEditor(String.class);
- String str = "\n\t\\a\"";
- editor.setAsText(str);
- assertEquals(str, editor.getAsText());
- assertEquals("\"\n\t\\a\"\"", editor
- .getJavaInitializationString());
- }
-
- public static class FozRegisteredEditor implements PropertyEditor {
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.PropertyEditor#addPropertyChangeListener(java.beans.PropertyChangeListener)
- */
- public void addPropertyChangeListener(PropertyChangeListener listener) {
- // TO DO Auto-generated method stub
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.PropertyEditor#getAsText()
- */
- public String getAsText() {
- // TO DO Auto-generated method stub
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.PropertyEditor#getCustomEditor()
- */
- public Component getCustomEditor() {
- // TO DO Auto-generated method stub
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.PropertyEditor#getJavaInitializationString()
- */
- public String getJavaInitializationString() {
- // TO DO Auto-generated method stub
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.PropertyEditor#getTags()
- */
- public String[] getTags() {
- // TO DO Auto-generated method stub
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.PropertyEditor#getValue()
- */
- public Object getValue() {
- // TO DO Auto-generated method stub
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.PropertyEditor#isPaintable()
- */
- public boolean isPaintable() {
- // TO DO Auto-generated method stub
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.PropertyEditor#paintValue(java.awt.Graphics,
- * java.awt.Rectangle)
- */
- public void paintValue(Graphics graphics, Rectangle box) {
- // TO DO Auto-generated method stub
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.PropertyEditor#removePropertyChangeListener(java.beans.PropertyChangeListener)
- */
- public void removePropertyChangeListener(PropertyChangeListener listener) {
- // TO DO Auto-generated method stub
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.PropertyEditor#setAsText(java.lang.String)
- */
- public void setAsText(String text) throws IllegalArgumentException {
- // TO DO Auto-generated method stub
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.PropertyEditor#setValue(java.lang.Object)
- */
- public void setValue(Object value) {
- // TO DO Auto-generated method stub
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.PropertyEditor#supportsCustomEditor()
- */
- public boolean supportsCustomEditor() {
- // TO DO Auto-generated method stub
- return false;
- }
-
- }
-
- public static class ButtonEditor implements PropertyEditor {
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.PropertyEditor#addPropertyChangeListener(java.beans.PropertyChangeListener)
- */
- public void addPropertyChangeListener(PropertyChangeListener listener) {
- // TO DO Auto-generated method stub
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.PropertyEditor#getAsText()
- */
- public String getAsText() {
- // TO DO Auto-generated method stub
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.PropertyEditor#getCustomEditor()
- */
- public Component getCustomEditor() {
- // TO DO Auto-generated method stub
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.PropertyEditor#getJavaInitializationString()
- */
- public String getJavaInitializationString() {
- // TO DO Auto-generated method stub
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.PropertyEditor#getTags()
- */
- public String[] getTags() {
- // TO DO Auto-generated method stub
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.PropertyEditor#getValue()
- */
- public Object getValue() {
- // TO DO Auto-generated method stub
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.PropertyEditor#isPaintable()
- */
- public boolean isPaintable() {
- // TO DO Auto-generated method stub
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.PropertyEditor#paintValue(java.awt.Graphics,
- * java.awt.Rectangle)
- */
- public void paintValue(Graphics graphics, Rectangle box) {
- // TO DO Auto-generated method stub
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.PropertyEditor#removePropertyChangeListener(java.beans.PropertyChangeListener)
- */
- public void removePropertyChangeListener(PropertyChangeListener listener) {
- // TO DO Auto-generated method stub
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.PropertyEditor#setAsText(java.lang.String)
- */
- public void setAsText(String text) throws IllegalArgumentException {
- // TO DO Auto-generated method stub
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.PropertyEditor#setValue(java.lang.Object)
- */
- public void setValue(Object value) {
- // TO DO Auto-generated method stub
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.PropertyEditor#supportsCustomEditor()
- */
- public boolean supportsCustomEditor() {
- // TO DO Auto-generated method stub
- return false;
- }
-
- }
-
- /**
- * The test checks the method findEditor() for registered editors
- */
- public void testFindRegisteredEditor() {
- PropertyEditorManager.registerEditor(SampleProperty.class,
- OtherEditor.class);
- PropertyEditor pe = PropertyEditorManager
- .findEditor(SampleProperty.class);
- assertNotNull("No property editor found", pe);
- assertTrue(pe instanceof OtherEditor);
- PropertyEditorManager.registerEditor(SampleProperty.class, null);
- }
-
- /**
- * The test checks the method findEditor() for editors found by name
- */
- public void testFindEditorByNameAddOn() {
- PropertyEditor pe = PropertyEditorManager
- .findEditor(SampleProperty.class);
- assertNotNull("No property editor found", pe);
- assertTrue(pe instanceof SamplePropertyEditor);
- }
-
- /**
- * The test checks the method findEditor() for editors on search path
- */
- public void testFindEditorByDefaultLocation() {
- PropertyEditorManager
- .setEditorSearchPath(new String[] { "org.apache.harmony.beans.tests.java.beans.editors" });
- PropertyEditor pe = PropertyEditorManager
- .findEditor(AnotherSampleProperty.class);
-
- assertNotNull("No property editor found", pe);
- assertTrue(pe instanceof AnotherSamplePropertyEditor);
- }
-
- public void testFontEditor() throws Exception{
- PropertyEditor e2 = PropertyEditorManager.findEditor(Font.class);
- Font font = new Font("Helvetica", Font.PLAIN, 12);
- e2.setValue(font);
- assertNull(e2.getAsText());
- assertNull(e2.getTags());
- assertSame(font, e2.getValue());
- assertTrue(e2.isPaintable());
- Component c = e2.getCustomEditor();
- assertSame(c, e2);
- e2.addPropertyChangeListener(new ExceptionPropertyChangeListener());
-
- try {
- e2.setValue(null);
- fail("Should throw MockError");
- } catch (MockError e) {
- // Expected
- assertNull(e2.getValue());
- }
-
- try {
- e2.setValue(new Font("Arial", Font.BOLD, 10));
- fail("Should throw MockError");
- } catch (MockError e) {
- // Expected
- }
- }
-
- @SuppressWarnings("serial")
- public static class MockError extends Error {
- public MockError(String msg) {
- super(msg);
- }
- }
- public static class ExceptionPropertyChangeListener implements PropertyChangeListener {
-
- public void propertyChange(PropertyChangeEvent event) {
- throw new MockError("property changed");
- }
-
- }
-
- public void testColorEditor() throws Exception{
- PropertyEditor e2 = PropertyEditorManager.findEditor(Color.class);
- assertNull(e2.getValue());
- assertEquals("", e2.getAsText());
- e2.setValue(Color.RED);
- e2.setAsText(e2.getAsText());
- assertNull(e2.getTags());
- assertNotSame(Color.RED, e2.getValue());
- assertEquals(Color.RED, e2.getValue());
- assertTrue(e2.isPaintable());
- assertTrue(e2 instanceof Panel);
- assertTrue(e2 instanceof PropertyEditor);
- assertTrue(e2.supportsCustomEditor());
- assertSame(e2, e2.getCustomEditor());
- assertEquals("new java.awt.Color(255,0,0)", e2
- .getJavaInitializationString());
- assertNull(e2.getTags());
-
- ExceptionPropertyChangeListener listener = new ExceptionPropertyChangeListener();
- e2.addPropertyChangeListener(listener);
-
- e2.setValue(null);
- assertEquals(Color.RED.getRed(), ((Color) e2.getValue()).getRed());
-
- try {
- e2.setValue(Color.yellow);
- fail("Should throw MockError");
- } catch (MockError e) {
- // Expected
- }
-
- assertEquals("255,255,0", e2.getAsText());
-
- try {
- e2.setAsText(null);
- fail("Should throw NullPointerException");
- } catch (NullPointerException e) {
- // Expected
- }
-
- try {
- e2.setAsText("text");
- fail("Should throw IllegalArgumentException");
- } catch (IllegalArgumentException e) {
- // Expected
- }
-
- e2.removePropertyChangeListener(listener);
- e2.setAsText("255,255,255");
- assertEquals("java.awt.Color[r=255,g=255,b=255]", ((Color) e2
- .getValue()).toString());
-
- Color value1 = (Color) e2.getValue();
- e2.setAsText("255,255,255");
- Color value2 = (Color) e2.getValue();
- assertNotSame(value1, value2);
- }
-
- public void testGetSetEditorPath() throws Exception{
- String[] s = new String[]{"path1", "path2"};
- PropertyEditorManager.setEditorSearchPath(s);
- s[1] = "path3";
- String[] s2 = PropertyEditorManager.getEditorSearchPath();
- assertFalse(s==s2);
- assertEquals("path1", s2[0]);
- }
-
- String[] defaultSearchPath;
-
- public void setUp(){
- defaultSearchPath = PropertyEditorManager.getEditorSearchPath();
- }
-
- public void tearDown(){
- PropertyEditorManager.setEditorSearchPath(defaultSearchPath);
- }
-}
diff --git a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PropertyEditorSupportTest.java b/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PropertyEditorSupportTest.java
deleted file mode 100644
index 92b1287..0000000
--- a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PropertyEditorSupportTest.java
+++ /dev/null
@@ -1,444 +0,0 @@
-/*
- * 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.java.beans;
-
-import java.beans.EventHandler;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyEditorSupport;
-
-import junit.framework.TestCase;
-
-/**
- * Unit test of PropertyEditorSupport
- */
-public class PropertyEditorSupportTest extends TestCase {
-
- /**
- * @tests java.beans.PropertyEditorSupport#PropertyEditorSupport()
- */
- public void testPropertyEditorSupport() {
- // Regression for HARMONY-516
- PropertyEditorSupport support = new PropertyEditorSupport();
-
- assertEquals("null", support.getAsText());
- assertNull(support.getValue());
- assertNull(support.getCustomEditor());
- assertEquals("???", support.getJavaInitializationString());
- assertNull(support.getTags());
- assertFalse(support.supportsCustomEditor());
- assertFalse(support.isPaintable());
- assertSame(support, support.getSource());
-
- Object value = new String[] { "java.awt.Color.orange" };
- support.setValue(value);
- assertEquals(value.toString(), support.getAsText());
- }
-
- /**
- * @tests java.beans.PropertyEditorSupport#PropertyEditorSupport(
- * java.lang.Object)
- */
- public void testPropertyEditorSupportObject() {
- MockSource source = new MockSource();
- PropertyEditorSupport support = new PropertyEditorSupport(source);
-
- assertEquals("null", support.getAsText());
- assertNull(support.getValue());
- assertNull(support.getCustomEditor());
- assertEquals("???", support.getJavaInitializationString());
- assertNull(support.getTags());
- assertFalse(support.supportsCustomEditor());
- assertFalse(support.isPaintable());
- assertSame(source, support.getSource());
- }
-
- /*
- * source null
- */
- public void testPropertyEditorSupportObject_null() {
- try {
- new PropertyEditorSupport(null);
- fail("Should throw NullPointerException.");
- } catch (NullPointerException e) {
- // expected
- }
- }
-
- /*
- * public void addPropertyChangeListener(PropertyChangeListener listener)
- */
- public void testAddPropertyChangeListener() {
- MockTarget target = new MockTarget();
- PropertyEditorSupport support = new PropertyEditorSupport();
- support.addPropertyChangeListener(EventHandler.create(
- PropertyChangeListener.class, target, "setCalled"));
- support.firePropertyChange();
-
- assertEquals("called", target.getLabel());
- }
-
- public void testAddPropertyChangeListener_source() {
- MockTarget target = new MockTarget();
- MockSource source = new MockSource();
- PropertyEditorSupport support = new PropertyEditorSupport(source);
- support.addPropertyChangeListener(EventHandler.create(
- PropertyChangeListener.class, target, "eventSource", "source"));
- support.firePropertyChange();
- assertSame(source, target.getEventSource());
- }
-
- public void testAddPropertyChangeListener_source_null() {
- MockTarget target = new MockTarget();
- PropertyEditorSupport support = new PropertyEditorSupport();
- support.addPropertyChangeListener(EventHandler.create(
- PropertyChangeListener.class, target, "eventSource", ""));
- support.firePropertyChange();
- PropertyChangeEvent event = (PropertyChangeEvent) target
- .getEventSource();
-
- assertNull(event.getPropertyName());
- assertSame(support, event.getSource());
- }
-
- public void testFirePropertyChange_noListener() {
- PropertyEditorSupport support = new PropertyEditorSupport();
- support.firePropertyChange();
- }
-
- /*
- * listener is null
- */
- public void testAddPropertyChangeListener_null() {
- PropertyEditorSupport support = new PropertyEditorSupport();
- support.addPropertyChangeListener(null);
- try {
- support.firePropertyChange();
- fail("Should throw NullPointerException.");
- } catch (NullPointerException e) {
- // expected
- }
- }
-
- public void testPaintValue() {
- PropertyEditorSupport support = new PropertyEditorSupport();
- support.paintValue(null, null);
- }
-
- public void testRemovePropertyChangeListener() {
- MockTarget target = new MockTarget();
- PropertyEditorSupport support = new PropertyEditorSupport();
- PropertyChangeListener proxy = EventHandler.create(
- PropertyChangeListener.class, target, "eventSource", "source");
- support.addPropertyChangeListener(proxy);
- support.firePropertyChange();
- assertSame(support, target.getEventSource());
-
- target.setEventSource(null);
- support.removePropertyChangeListener(proxy);
- support.firePropertyChange();
- assertNull(target.getEventSource());
- }
-
- public void testRemovePropertyChangeListener_null() {
- MockTarget target = new MockTarget();
- PropertyEditorSupport support = new PropertyEditorSupport();
- PropertyChangeListener proxy = EventHandler.create(
- PropertyChangeListener.class, target, "eventSource", "source");
- support.addPropertyChangeListener(proxy);
- support.firePropertyChange();
- assertSame(support, target.getEventSource());
-
- target.setEventSource(null);
- support.removePropertyChangeListener(null);
- support.firePropertyChange();
- assertSame(support, target.getEventSource());
- }
-
- /*
- * remove a different listener
- */
- public void testRemovePropertyChangeListener_diff() {
- MockTarget target = new MockTarget();
- PropertyEditorSupport support = new PropertyEditorSupport();
- PropertyChangeListener proxy = EventHandler.create(
- PropertyChangeListener.class, target, "eventSource", "source");
- support.addPropertyChangeListener(proxy);
- support.firePropertyChange();
- assertSame(support, target.getEventSource());
-
- target.setEventSource(null);
- PropertyChangeListener proxy2 = EventHandler.create(
- PropertyChangeListener.class, target, "eventSource", "source");
- support.removePropertyChangeListener(proxy2);
- support.firePropertyChange();
- assertSame(support, target.getEventSource());
- }
-
- /*
- * remove null listener
- */
- public void testRemovePropertyChangeListener_null_null() {
- PropertyEditorSupport support = new PropertyEditorSupport();
- support.addPropertyChangeListener(null);
- try {
- support.firePropertyChange();
- fail("Should throw NullPointerException.");
- } catch (NullPointerException e) {
- // expected
- }
-
- support.removePropertyChangeListener(null);
- support.firePropertyChange();
- }
-
- public void testSetAsText() {
- // Regression for HARMONY-1113
- PropertyEditorSupport support;
-
- support = new PropertyEditorSupport();
- try {
- support.setAsText("100");
- fail("Should throw IllegalArgumentException.");
- } catch (IllegalArgumentException e) {
- // expected
- }
-
- support = new PropertyEditorSupport();
- support.setValue(new Object());
- try {
- support.setAsText("string");
- fail("IllegalArgumentException expected");
- } catch (IllegalArgumentException e) {
- }
-
- support = new PropertyEditorSupport();
- support.setValue(new String());
- support.setAsText("string");
- }
-
- public void testSetValue() {
- PropertyEditorSupport support = new PropertyEditorSupport();
- String[] value = new String[] { "This is a sample value." };
- support.setValue(value);
-
- assertEquals(value, support.getValue());
- assertEquals(value.toString(), support.getAsText());
-
- assertNull(support.getCustomEditor());
- assertEquals("???", support.getJavaInitializationString());
- assertNull(support.getTags());
- assertFalse(support.supportsCustomEditor());
- assertFalse(support.isPaintable());
-
- }
-
- public void testSetValue_null() {
- PropertyEditorSupport support = new PropertyEditorSupport();
- support.setValue(null);
-
- assertNull(support.getValue());
- assertEquals("null", support.getAsText());
-
- assertNull(support.getCustomEditor());
- assertEquals("???", support.getJavaInitializationString());
- assertNull(support.getTags());
- assertFalse(support.supportsCustomEditor());
- assertFalse(support.isPaintable());
-
- MockTarget target = new MockTarget();
- support.setValue(target);
-
- assertSame(target, support.getValue());
- assertEquals(target.toString(), support.getAsText());
- assertNull(support.getCustomEditor());
- assertEquals("???", support.getJavaInitializationString());
- assertNull(support.getTags());
- assertFalse(support.supportsCustomEditor());
- assertFalse(support.isPaintable());
- }
-
- /**
- * @tests java.beans.PropertyEditorSupport#setSource(Object)
- * @tests java.beans.PropertyEditorSupport#getSource()
- */
- public void test_setSourceLjava_lang_Object() {
-
- // Regression for HARMONY-1409
- PropertyEditorSupport support = new PropertyEditorSupport();
-
- Object source = new Object();
-
- support.setSource(source);
- assertSame(source, support.getSource());
-
- support.setSource(null);
- }
-
- public void testSetValue_Event() {
- PropertyEditorSupport support = new PropertyEditorSupport();
- Object source = new Object();
- support.setSource(source);
- MockPropertyChangeListener listener = new MockPropertyChangeListener();
- support.addPropertyChangeListener(listener);
-
- support.setValue(new Object());
- PropertyChangeEvent event = listener.getEvent();
- assertNotNull(event);
- assertEquals(source, event.getSource());
- assertNull(event.getNewValue());
- assertNull(event.getOldValue());
- assertNull(event.getPropagationId());
- assertNull(event.getPropertyName());
- }
-
- public static class MockSource {
-
- String id;
-
- String text;
-
- public MockSource() {
- this.id = "0001";
- this.text = getClass().getName();
- }
-
- /**
- * @return Returns the id.
- */
- public String getId() {
- return id;
- }
-
- /**
- * @param id
- * The id to set.
- */
- public void setId(String id) {
- this.id = id;
- }
-
- /**
- * @return Returns the text.
- */
- public String getText() {
- return text;
- }
-
- /**
- * @param text
- * The text to set.
- */
- public void setText(String text) {
- this.text = text;
- }
- }
-
- public static class MockTarget {
-
- String id;
-
- String label;
-
- Object eventSource;
-
- public MockTarget() {
- this.id = "0001";
- this.label = getClass().getName();
- }
-
- /**
- * @return Returns the id.
- */
- public String getId() {
- return id;
- }
-
- /**
- * @param id
- * The id to set.
- */
- public void setId(String id) {
- this.id = id;
- }
-
- /**
- * @return Returns the text.
- */
- public String getLabel() {
- return label;
- }
-
- /**
- * @param text
- * The text to set.
- */
- public void setLabel(String label) {
- this.label = label;
- }
-
- public void setCalled() {
- this.label = "called";
- }
-
- /**
- * @return Returns the eventSource.
- */
- public Object getEventSource() {
- return eventSource;
- }
-
- /**
- * @param eventSource
- * The eventSource to set.
- */
- public void setEventSource(Object eventSource) {
- this.eventSource = eventSource;
- }
-
- @Override
- public boolean equals(Object o) {
- if (!(o instanceof MockTarget)) {
- return false;
- }
-
- MockTarget other = (MockTarget) o;
- return ((this.id == null ? other.id == null : this.id
- .equals(other.id))
- && (this.eventSource == null ? other.eventSource == null
- : this.eventSource.equals(other.eventSource)) && (this.label == null ? other.label == null
- : this.label.equals(other.label)));
- }
- }
-
- public class MockPropertyChangeListener implements PropertyChangeListener
- {
-
- private PropertyChangeEvent event;
- public void propertyChange(PropertyChangeEvent event) {
-
- this.event = event;
- }
-
- public PropertyChangeEvent getEvent()
- {
- return event;
- }
-
- }
-}
diff --git a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PropertyVetoExceptionTest.java b/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PropertyVetoExceptionTest.java
deleted file mode 100644
index 658029d..0000000
--- a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PropertyVetoExceptionTest.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * 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.java.beans;
-
-import java.beans.Beans;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyVetoException;
-import java.io.Serializable;
-
-import junit.framework.TestCase;
-
-import org.apache.harmony.beans.tests.support.mock.MockJavaBean;
-import org.apache.harmony.testframework.serialization.SerializationTest;
-import org.apache.harmony.testframework.serialization.SerializationTest.SerializableAssert;
-
-/**
- * Unit test for class PropertyVetoException
- */
-public class PropertyVetoExceptionTest extends TestCase {
-
- private PropertyChangeEvent event;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- MockJavaBean myBean = new MockJavaBean("Bean_PropertyVetoExceptionTest");
- event = new PropertyChangeEvent(myBean, "propertyOne", "value_old",
- "value_one");
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-
- public void testPropertyVetoException() {
- String message = "testPropertyVetoException";
- PropertyVetoException e = new PropertyVetoException(message, event);
- assertSame(message, e.getMessage());
- assertSame(event, e.getPropertyChangeEvent());
- }
-
- public void testPropertyVetoException_MessageNull() {
- String message = null;
- PropertyVetoException e = new PropertyVetoException(message, event);
- assertNull(e.getMessage());
- assertSame(event, e.getPropertyChangeEvent());
- }
-
- public void testPropertyVetoException_EventNull() {
- String message = "testPropertyVetoException";
- PropertyVetoException e = new PropertyVetoException(message, null);
- assertSame(message, e.getMessage());
- assertNull(e.getPropertyChangeEvent());
- }
-
- // comparator for PropertyVetoException objects
- private static final SerializableAssert comparator = new SerializableAssert() {
- public void assertDeserialized(Serializable initial,
- Serializable deserialized) {
-
- SerializationTest.THROWABLE_COMPARATOR.assertDeserialized(initial,
- deserialized);
-
- PropertyVetoException initEx = (PropertyVetoException) initial;
- PropertyVetoException desrEx = (PropertyVetoException) deserialized;
-
- assertNull(desrEx.getPropertyChangeEvent().getSource());
-
- // compare event objects
- PropertyChangeEventTest.comparator.assertDeserialized(initEx
- .getPropertyChangeEvent(), desrEx.getPropertyChangeEvent());
- }
- };
-
- /**
- * @tests serialization/deserialization.
- */
- public void testSerializationSelf() throws Exception {
-
- SerializationTest.verifySelf(new PropertyVetoException(
- "testPropertyVetoException", event), comparator);
- }
-
- /**
- * @tests serialization/deserialization compatibility with RI.
- */
- public void testSerializationCompatibility() throws Exception {
-
- SerializationTest.verifyGolden(this, new PropertyVetoException(
- "testPropertyVetoException", event), comparator);
- }
-
- public void testPropertyVetoExceptionMessage() {
- // Regression for HARMONY-235 (tracking the similar bug)
- PropertyChangeEvent event = new PropertyChangeEvent(new Beans(),
- "propertyName", "oldValue", "newValue");
-
- String message = "test message";
-
- PropertyVetoException e = new PropertyVetoException(message, event);
- assertEquals(message, e.getMessage());
- }
-}
diff --git a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/SimpleBeanInfoTest.java b/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/SimpleBeanInfoTest.java
deleted file mode 100644
index c087495..0000000
--- a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/SimpleBeanInfoTest.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * 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.java.beans;
-
-import java.awt.Image;
-import java.beans.BeanInfo;
-import java.beans.SimpleBeanInfo;
-
-import junit.framework.TestCase;
-
-
-/**
- * Unit test for SimpleBeanInfo
- */
-public class SimpleBeanInfoTest extends TestCase {
-
- public void testGetAdditionalBeanInfo() {
- SimpleBeanInfo info = new SimpleBeanInfo();
-
- assertNull(info.getAdditionalBeanInfo());
- }
-
- public void testGetBeanDescriptor() {
- SimpleBeanInfo info = new SimpleBeanInfo();
-
- assertNull(info.getBeanDescriptor());
- }
-
- public void testGetDefaultEventIndex() {
- SimpleBeanInfo info = new SimpleBeanInfo();
-
- assertEquals(-1, info.getDefaultEventIndex());
- }
-
- public void testGetDefaultPropertyIndex() {
- SimpleBeanInfo info = new SimpleBeanInfo();
-
- assertEquals(-1, info.getDefaultPropertyIndex());
- }
-
- public void testGetEventSetDescriptors() {
- SimpleBeanInfo info = new SimpleBeanInfo();
-
- assertNull(info.getEventSetDescriptors());
- }
-
- public void testGetIcon() {
- SimpleBeanInfo info = new SimpleBeanInfo();
-
- assertNull(info.getIcon(BeanInfo.ICON_COLOR_16x16));
- }
-
- public void testGetMethodDescriptors() {
- SimpleBeanInfo info = new SimpleBeanInfo();
-
- assertNull(info.getMethodDescriptors());
- }
-
- public void testGetPropertyDescriptors() {
- SimpleBeanInfo info = new SimpleBeanInfo();
-
- assertNull(info.getPropertyDescriptors());
- }
-
- public void testLoadImage() {
- SimpleBeanInfo info = new SimpleBeanInfo();
- Image image;
-
- image = info.loadImage("/gif/harmony-logo.gif");
- assertNotNull(image);
-
- image = info.loadImage("/gif/test.gif");
- assertNotNull(image);
-
- // regression for HARMONY-2241
- info = new SimpleBeanInfo() {};
- image = info.loadImage("testB.jpg");
- assertNotNull(image);
-
- info = new SimpleBeanInfo();
- image = info.loadImage(null);
- assertNull(image);
- }
-
-}
diff --git a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/StatementTest.java b/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/StatementTest.java
deleted file mode 100644
index 4fd1d3c..0000000
--- a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/StatementTest.java
+++ /dev/null
@@ -1,1341 +0,0 @@
-/*
- * 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.java.beans;
-
-import java.beans.DefaultPersistenceDelegate;
-import java.beans.Statement;
-import java.util.Arrays;
-import java.util.TreeMap;
-import java.util.Vector;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.apache.harmony.beans.tests.support.SampleException;
-import org.apache.harmony.beans.tests.support.TInspectorCluster;
-import org.apache.harmony.beans.tests.support.TInspectorCluster.Ancestor;
-import org.apache.harmony.beans.tests.support.TInspectorCluster.BooleanInspector;
-import org.apache.harmony.beans.tests.support.TInspectorCluster.CharacterInspector;
-import org.apache.harmony.beans.tests.support.TInspectorCluster.DoubleInspector;
-import org.apache.harmony.beans.tests.support.TInspectorCluster.FloatInspector;
-import org.apache.harmony.beans.tests.support.TInspectorCluster.IntegerInspector;
-import org.apache.harmony.beans.tests.support.TInspectorCluster.LongInspector;
-import org.apache.harmony.beans.tests.support.TInspectorCluster.ObjectInspector;
-import org.apache.harmony.beans.tests.support.TInspectorCluster.ObjectListInspector;
-import org.apache.harmony.beans.tests.support.TInspectorCluster.Offspring;
-import org.apache.harmony.beans.tests.support.TInspectorCluster.ShortInspector;
-import org.apache.harmony.beans.tests.support.TInspectorCluster.StringInspector;
-
-/**
- * Test the class java.beans.Statement.
- */
-public class StatementTest extends TestCase {
-
- private static int testId = -1;
-
- /**
- * The test checks the method execute() for setter
- */
- public void testSetter() throws Exception {
- Bean bean = new Bean();
- Statement s = new Statement(bean, "setText", new Object[] { "hello" });
- s.execute();
- assertEquals("hello", bean.getText());
- }
-
- /**
- * The test checks the method execute() for indexed setter
- */
- public void testIndexedSetter() throws Exception {
- Bean bean = new Bean("hello");
- Statement s = new Statement(bean, "setChar", new Object[] {
- new Integer(1), new Character('a') });
- s.execute();
- assertEquals("hallo", bean.getText());
- }
-
- /**
- * The test checks the method execute() for array setter
- */
- public void testArraySetter() throws Exception {
- int[] a = { 1, 2, 3 };
- Statement s = new Statement(a, "set", new Object[] { new Integer(1),
- new Integer(7) });
- s.execute();
- assertEquals(7, a[1]);
- }
-
- /**
- * The test checks the method execute() for static method
- */
- public void testStatic() throws Exception {
- int currentId = getTestId();
- Statement s = new Statement(StatementTest.class, "nextTestId",
- new Object[] {});
- s.execute();
- assertEquals(++currentId, getTestId());
- }
-
- /**
- * The test checks the method execute() if exception is thrown on method
- * call
- */
- public void testExceptionThrownOnMethodCall() {
- Bean bean = new Bean("hello");
- Statement s = new Statement(bean, "setChar", new Object[] {
- new Integer(5), new Character('a') });
-
- try {
- s.execute();
- fail("Exception must be thrown while Bean.setChar(5, 'a') "
- + "invocation.");
- } catch (Exception e) {
- // correct situation
- }
- }
-
- /**
- * The test checks the method execute() if exception is thrown on static
- * method call
- */
- public void testExceptionThrownOnStaticMethodCall() throws Exception {
- Statement s = new Statement(StatementTest.class, "methodWithException",
- new Object[] {});
-
- try {
- s.execute();
- fail("Exception must be thrown with methodWithException call");
- } catch (SampleException se) {
- // SampleException is thrown as expected
- }
- }
-
- /**
- * The test checks the method execute() with array as parameter
- */
- public void testMethodWithArrayParam() throws Exception {
- Statement s = new Statement(StatementTest.class, "methodWithIntArray",
- new Object[] { new int[] { 3 } });
- s.execute();
- }
-
- /**
- *
- */
- public static int getTestId() {
- return testId;
- }
-
- /**
- *
- */
- public static void nextTestId() {
- ++testId;
- }
-
- /**
- *
- */
- public static void methodWithException() throws Exception {
- throw new SampleException("sample");
- }
-
- /**
- *
- */
- public static void methodWithIntArray(int[] array) {
- }
-
- /**
- *
- */
- public static Test suite() {
- return new TestSuite(StatementTest.class);
- }
-
- public class Bean {
-
- private String text;
-
- public Bean() {
- text = null;
- }
-
- public Bean(String text) {
- this.text = text;
- }
-
- public String getText() {
- return text;
- }
-
- public void setText(String text) {
- this.text = text;
- }
-
- public char getChar(int idx) throws IllegalAccessException {
- if (text == null) {
- throw new IllegalAccessException("Text property is null.");
- }
- return text.charAt(idx);
- }
-
- public void setChar(int idx, char value) throws IllegalAccessException {
- if (text == null) {
- throw new IllegalAccessException("Text property is null.");
- }
- // IndexOutOfBounds exception is thrown if indexed bounds
- // are violated
- StringBuffer sb = new StringBuffer(text.length());
-
- if (idx < 0 || idx >= text.length()) {
- throw new IndexOutOfBoundsException();
- }
-
- if (idx > 0) {
- sb.append(text.substring(0, idx));
- }
- sb.append(value);
-
- if (idx < (text.length() - 1)) {
- sb.append(text.substring(idx + 1));
- }
-
- text = sb.toString();
- }
- }
-
- /*
- * Test the constructor under normal conditions.
- */
- public void testConstructor_Normal() {
- Object arg1 = new Object();
- Object arg2 = "string";
- Object[] oa = new Object[] { arg1, arg2 };
- Statement t = new Statement(arg1, "method", oa);
- assertSame(arg1, t.getTarget());
- assertSame("method", t.getMethodName());
- assertSame(oa, t.getArguments());
- assertSame(arg1, t.getArguments()[0]);
- assertSame(arg2, t.getArguments()[1]);
- assertEquals("Object.method(Object, \"string\");", t.toString());
- }
-
- /*
- * Test the constructor with null target.
- */
- public void testConstructor_NullTarget() {
- Object arg = new Object();
- Object[] oa = new Object[] { arg };
- Statement t = new Statement(null, "method", oa);
- assertSame(null, t.getTarget());
- assertSame("method", t.getMethodName());
- assertSame(oa, t.getArguments());
- assertSame(arg, t.getArguments()[0]);
- assertEquals("null.method(Object);", t.toString());
- }
-
- /*
- * Test the constructor with an array target.
- */
- public void testConstructor_ArrayTarget() {
- Object arg = new Object();
- Object[] oa = new Object[] { arg };
- Statement t = new Statement(oa, "method", oa);
- assertSame(oa, t.getTarget());
- assertSame("method", t.getMethodName());
- assertSame(oa, t.getArguments());
- assertSame(arg, t.getArguments()[0]);
- assertEquals("ObjectArray.method(Object);", t.toString());
- }
-
- /*
- * Test the constructor with null method name.
- */
- public void testConstructor_NullMethodName() {
- Object target = new Object();
- Object[] oa = new Object[] { new Object() };
- Statement t = new Statement(target, null, oa);
- assertSame(target, t.getTarget());
- assertSame(null, t.getMethodName());
- assertSame(oa, t.getArguments());
- assertEquals("Object.null(Object);", t.toString());
- }
-
- /*
- * Test the constructor with the method name "new".
- */
- public void testConstructor_NewMethodName() {
- Object target = new Object();
- Object[] oa = new Object[] { new Object() };
- Statement t = new Statement(target, "new", oa);
- assertSame(target, t.getTarget());
- assertSame("new", t.getMethodName());
- assertSame(oa, t.getArguments());
- assertEquals("Object.new(Object);", t.toString());
- }
-
- /*
- * Test the constructor with empty method name.
- */
- public void testConstructor_EmptyMethodName() {
- Object target = new Object();
- Object[] oa = new Object[] { new Object() };
- Statement t = new Statement(target, "", oa);
- assertSame(target, t.getTarget());
- assertSame("", t.getMethodName());
- assertSame(oa, t.getArguments());
- assertEquals("Object.(Object);", t.toString());
- }
-
- /*
- * Test the constructor with null arguments.
- */
- public void testConstructor_NullArguments() {
- Object target = new Object();
- Statement t = new Statement(target, "method", null);
- assertSame(target, t.getTarget());
- assertSame("method", t.getMethodName());
- assertEquals(0, t.getArguments().length);
- assertEquals("Object.method();", t.toString());
- }
-
- /*
- * Test the constructor with a null argument.
- */
- public void testConstructor_NullArgument() {
- Object target = new Object();
- Object[] oa = new Object[] { null };
- Statement t = new Statement(target, "method", oa);
- assertSame(target, t.getTarget());
- assertSame("method", t.getMethodName());
- assertSame(oa, t.getArguments());
- assertNull(t.getArguments()[0]);
- assertEquals("Object.method(null);", t.toString());
- }
-
- public void testConstructor_EmptyTarget_EmptyMethod_NullArguments() {
- Statement statement = new Statement(new String(), new String(),
- (Object[]) null);
- assertEquals("\"\".();", statement.toString());
- }
-
- public void testConstructor_StringArrayTarget_EmptyMethod_NullArguments() {
- Object target = new String[2];
- Statement statement = new Statement(target, new String(),
- (Object[]) null);
- assertEquals("StringArray.();", statement.toString());
- }
-
- public void testConstructor_StringArrayArrayTarget_EmptyMethod_NullArguments() {
- Object target = new String[2][];
- Statement statement = new Statement(target, new String(),
- (Object[]) null);
- assertEquals("StringArrayArray.();", statement.toString());
- }
-
- public void testConstructor_StringArrayArrayTarget_EmptyMethod_StringArrayArrayTarget() {
- Object target = new String[2][];
- Statement statement = new Statement(target, new String(),
- new Object[] { target });
- assertEquals("StringArrayArray.(StringArrayArray);", statement
- .toString());
- }
-
- // public void testGetArguments() {
- // // Covered in the testcases for the constructor
- // }
- //
- // public void testGetMethodName() {
- // // Covered in the testcases for the constructor
- // }
- //
- // public void testGetTarget() {
- // // Covered in the testcases for the constructor
- // }
- //
- // public void testToString() {
- // // Covered in the testcases for the constructor
- // }
-
- /*
- * Test the method execute() with a normal object, a valid method name and
- * valid arguments.
- */
- public void testExecute_NormalInstanceMethod() throws Exception {
- MockObject mo = new MockObject(false);
- Statement t = new Statement(mo, "method", new Object[0]);
- t.execute();
- MockObject.assertCalled("method1", new Object[0]);
- t = new Statement(mo, "method", null);
- t.execute();
- MockObject.assertCalled("method1", new Object[0]);
- }
-
- /*
- * Test the method execute() with a normal object, normal method and null
- * arguments.
- */
- public void testExecute_NormalInstanceMethodNull() throws Exception {
- MockObject mo = new MockObject(false);
- Object[] arguments = new Object[] { null, null, null };
- Statement t = new Statement(mo, "method", arguments);
-
- t.execute();
- MockObject.assertCalled("method5", arguments);
- }
-
- /*
- * Test the method execute() with a normal object, a valid method that
- * throws an exception and valid arguments.
- */
- public void testExecute_ExceptionalMethod() throws Exception {
- MockObject mo = new MockObject(false);
- Statement t = new Statement(mo, "method", new Object[] { null, null });
- try {
- t.execute();
- fail("Should throw NullPointerException!");
- } catch (NullPointerException ex) {
- // expected
- }
- MockObject.assertCalled("method4", new Object[] { null, null });
- }
-
- /*
- * Test the method execute() with a normal object and a non-existing method
- * name.
- */
- public void testExecute_NonExistingMethod() throws Exception {
- MockObject mo = new MockObject(false);
- Statement t = new Statement(mo, "method_not_existing", new Object[] {
- null, null });
- try {
- t.execute();
- fail("Should throw NoSuchMethodException!");
- } catch (NoSuchMethodException ex) {
- // expected
- }
- }
-
- /*
- * Test the method execute() with a null object.
- */
- public void testExecute_NullTarget() throws Exception {
- Statement t = new Statement(null, "method_not_existing", new Object[] {
- null, null });
- try {
- t.execute();
- fail("Should throw NullPointerException!");
- } catch (NullPointerException ex) {
- // expected
- }
- }
-
- /*
- * Test the method execute() with a null method name.
- */
- // public void testExecute_NullMethodName() throws Exception {
- // MockObject mo = new MockObject(false);
- // Statement t = new Statement(mo, null, new Object[] { null, null });
- // try {
- // t.execute();
- // fail("Should throw NoSuchMethodException!");
- // } catch (NoSuchMethodException ex) {
- // // expected
- // }
- // }
- /*
- * Test the method execute() with a normal object, a valid method and
- * invalid arguments (in terms of type, numbers, etc.).
- */
- public void testExecute_InvalidArguments() throws Exception {
- MockObject mo = new MockObject(false);
- Statement t = new Statement(mo, "method", new Object[] { new Object(),
- new Object(), new Object() });
- try {
- t.execute();
- fail("Should throw NoSuchMethodException!");
- } catch (NoSuchMethodException ex) {
- // expected
- }
- }
-
- /*
- * Test the method execute() with a normal object, an overloaded method and
- * valid arguments.
- */
- public void testExecute_OverloadedMethods() throws Exception {
- MockObject mo = new MockObject(false);
- Object[] arguments;
- Statement t;
-
- arguments = new Object[] { new Object() };
- t = new Statement(mo, "method", arguments);
- t.execute();
- MockObject.assertCalled("method2", arguments);
-
- arguments = new Object[] { "test" };
- t = new Statement(mo, "method", arguments);
- t.execute();
- MockObject.assertCalled("method3", arguments);
-
- arguments = new Object[] { new Integer(117) };
- t = new Statement(mo, "method", arguments);
- t.execute();
- MockObject.assertCalled("method1-3", arguments);
- }
-
- /*
- * Test the method execute() with a normal object, the method name "new" and
- * valid arguments.
- */
- public void testExecute_NormalConstructor() throws Exception {
- Statement t = new Statement(MockObject.class, "new", new Object[0]);
- t.execute();
- MockObject.assertCalled("new0", new Object[0]);
- t = new Statement(MockObject.class, "new", null);
- t.execute();
- MockObject.assertCalled("new0", new Object[0]);
- }
-
- /*
- * Test the method execute() with a normal object, normal constructor ("new"
- * method) and null arguments.
- */
- public void testExecute_NormalConstructorNull() throws Exception {
- Object[] arguments = new Object[] { null, null };
- Statement t = new Statement(MockObject.class, "new", arguments);
-
- try {
- t.execute();
- fail("Should throw NullPointerException!");
- } catch (NullPointerException ex) {
- // expected
- }
- MockObject.assertCalled("new4", arguments);
- }
-
- /*
- * Test the method execute() with a normal object, the method name "new"
- * that throws an exception and valid arguments.
- */
- public void testExecute_ExceptionalConstructor() throws Exception {
- Statement t = new Statement(MockObject.class, "new", new Object[] {
- null, null });
- try {
- t.execute();
- fail("Should throw NullPointerException!");
- } catch (NullPointerException ex) {
- // expected
- }
- MockObject.assertCalled("new4", new Object[] { null, null });
- }
-
- /*
- * Test the method execute() with a normal object, the method name "new" and
- * invalid arguments (in terms of type, numbers, etc.).
- */
- public void testExecute_NonExistingConstructor() throws Exception {
- Statement t = new Statement(MockObject.class, "new", new Object[] {
- null, null, null, null });
-
- try {
- t.execute();
- fail("Should throw NoSuchMethodException!");
- } catch (NoSuchMethodException ex) {
- // expected
- }
- }
-
- /*
- * Test the method execute() with a normal object with overloaded
- * constructors, the method name "new" and valid arguments.
- */
- public void testExecute_OverloadedConstructors() throws Exception {
- Object[] arguments = new Object[] { new Object() };
- Statement t = new Statement(MockObject.class, "new", arguments);
- t.execute();
- MockObject.assertCalled("new2", arguments);
-
- arguments = new Object[] { "test" };
- t = new Statement(MockObject.class, "new", arguments);
- t.execute();
- //FIXME: the following 2 commented assert cannot pass neither in RI nor in Harmony (HARMONY-4392),
- // waiting for dev-list approval to fix Harmony implementation following spec
-// MockObject.assertCalled("new3", arguments);
-
- Object[] arguments2 = new Object[] { new Integer(1) };
- t = new Statement(MockObject.class, "new", arguments2);
- t.execute();
-// MockObject.assertCalled("new1-2", arguments2);
- }
-
- /*
- * Test the method execute() with the Class object, a static method name and
- * valid arguments.
- */
- public void testExecute_NormalStaticMethodViaClass() throws Exception {
- Object[] arguments = new Object[] { new Object() };
- Statement t = new Statement(MockObject.class, "staticMethod", arguments);
- t.execute();
- MockObject.assertCalled("staticMethod", arguments);
- }
-
- /*
- * Test the method execute() with an object, a static method name and valid
- * arguments.
- */
- public void testExecute_NormalStaticMethodViaObject() throws Exception {
- MockObject mo = new MockObject(false);
- Object[] arguments = new Object[] { new Object() };
- Statement t = new Statement(mo, "staticMethod", arguments);
- t.execute();
- MockObject.assertCalled("staticMethod", arguments);
- }
-
- /*
- * Test the method execute() with a Class object of a normal class that has
- * a method of the same signature as Class.forName(String), a static method
- * name "forName" and valid argument "string".
- */
- public void testExecute_AmbiguousStaticMethod() throws Exception {
- Object[] arguments = new String[] { "test" };
- Statement t = new Statement(MockObject.class, "forName", arguments);
- t.execute();
- MockObject.assertCalled("forName", arguments);
-
- t = new Statement(String.class, "forName",
- new Object[] { "java.lang.String" });
- t.execute();
- }
-
- /*
- * Test the method execute() with the special method Class.forName().
- */
- public void testExecute_ClassForName() throws Exception {
- Object[] arguments = new String[] { Statement.class.getName() };
- Statement t = new Statement(Class.class, "forName", arguments);
- t.execute();
-
- t = new Statement(String.class, "forName",
- new Object[] { "java.lang.String" });
- t.execute();
- }
-
- /*
- * Test the method execute() with a normal array object, the method name
- * "get" and valid and invalid arguments.
- */
- public void testExecute_ArrayGet() throws Exception {
- Object[] array = new Object[] { "test" };
- Statement t = new Statement(array, "get",
- new Object[] { new Integer(0) });
- t.execute();
-
- array = new Object[] { "test" };
- t = new Statement(array, "get", new Object[0]);
- try {
- t.execute();
- fail("Should throw ArrayIndexOutOfBoundsException!");
- } catch (ArrayIndexOutOfBoundsException ex) {
- // expected
- }
- }
-
- /*
- * Test the method execute() with a normal array object, the method name
- * "set" and valid arguments.
- */
- public void testExecute_ArraySet() throws Exception {
- Object[] array = new Object[] { "test" };
- Statement t = new Statement(array, "set", new Object[] {
- new Integer(0), "test2" });
- t.execute();
- assertEquals("test2", array[0]);
- }
-
- /*
- * Test the method execute() with a normal array object, the method name
- * "set" and null index argument.
- */
- public void testExecute_ArrayNullIndex() throws Exception {
- Object[] array = new Object[] { "test" };
- Statement t = new Statement(array, "set",
- new Object[] { null, "test2" });
- try {
- t.execute();
- fail("Should throw NullPointerException!");
- } catch (NullPointerException ex) {
- // expected
- }
- }
-
- /*
- * Test the method execute() with a normal array object, the method name
- * "set" and invalid arguments.
- */
- public void testExecute_ArrayInvalidSet() throws Exception {
- Object[] array = new Object[] { "test" };
- Statement t = new Statement(array, "set", new Object[] {
- new Integer(0), "test2" });
- t.execute();
- assertEquals("test2", array[0]);
-
- try {
- t = new Statement(array, "set", new Object[] { "testtest", "test2",
- new Object() });
- t.execute();
- fail("Should throw ClassCastException!");
- } catch (ClassCastException ex) {
- // expected
- }
-
- t = new Statement(array, "set", new Object[] { new Integer(0) });
- try {
- t.execute();
- fail("Should throw ArrayIndexOutOfBoundsException!");
- } catch (ArrayIndexOutOfBoundsException ex) {
- // expected
- }
- }
-
- /*
- * Test the method execute() with a normal array object, the method name
- * "getInt" and invalid arguments.
- */
- public void testExecute_ArrayInvalidSetInt() throws Exception {
- int[] array = new int[] { 1 };
- Statement t = new Statement(array, "getInt",
- new Object[] { new Integer(0) });
- try {
- t.execute();
- fail("Should throw NoSuchMethodException!");
- } catch (NoSuchMethodException ex) {
- // expected
- }
- }
-
- /*
- * Test the method execute() with a normal array object, the method name
- * "gets".
- */
- public void testExecute_ArrayInvalidName() throws Exception {
- Object[] array = new Object[] { "test" };
- Statement t = new Statement(array, "gets", new Object[] {
- new Integer(0), new Object() });
- try {
- t.execute();
- fail("Should throw NoSuchMethodException!");
- } catch (NoSuchMethodException ex) {
- // expected
- }
- }
-
- /*
- * Test the method execute() with a normal object with overloaded methods
- * (primitive type VS wrapper class), a valid method name and valid
- * arguments.
- *
- * Note: decided by definition position!
- */
- public void testExecute_PrimitiveVSWrapper() throws Exception {
- MockObject mo = new MockObject(false);
- Object[] arguments = new Object[] { new Integer(1) };
- Statement t = new Statement(mo, "methodB", arguments);
- t.execute();
- MockObject.assertCalled("methodB1", arguments);
-
- arguments = new Object[] { Boolean.FALSE };
- t = new Statement(mo, "methodB", arguments);
- t.execute();
- MockObject.assertCalled("methodB2", arguments);
- }
-
- /*
- * Test the method execute() with a protected method but within java.beans
- * package.
- */
- public void testExecute_ProtectedMethodWithPackage() throws Exception {
- DefaultPersistenceDelegate dpd = new DefaultPersistenceDelegate();
- Object[] arguments = new Object[] { "test", "test" };
- Statement t = new Statement(dpd, "mutatesTo", arguments);
- try {
- t.execute();
- fail("Should throw NoSuchMethodException!");
- } catch (NoSuchMethodException e) {
- // expected
- }
- }
-
- /*
- * Test the method execute() with a method that is applicable via type
- * conversion.
- */
- public void testExecute_ApplicableViaTypeConversion() throws Exception {
- MockObject mo = new MockObject(false);
- // mo.methodB('c');
- Object[] arguments = new Object[] { new Character((char) 1) };
- Statement t = new Statement(mo, "methodB", arguments);
- try {
- t.execute();
- fail("Should throw NoSuchMethodException!");
- } catch (NoSuchMethodException e) {
- // expected
- }
- }
-
- /*
- * Test the method execute() with two equal specific methods.
- *
- * Note: decided by definition position!
- */
- // public void testExecute_EqualSpecificMethods() throws Exception {
- // MockObject mo = new MockObject(false);
- // Object[] arguments = new Object[] { new MockObject(false),
- // new MockObject(false) };
- // Statement t = new Statement(mo, "equalSpecificMethod", arguments);
- // t.execute();
- // MockObject.assertCalled("equalSpecificMethod1", arguments);
- // }
- /*
- * Test the method execute() with two equal specific methods but one
- * declaring thrown exception.
- *
- * Note: decided by definition position!
- */
- // public void testExecute_EqualSpecificMethodsException() throws Exception
- // {
- // MockObject mo = new MockObject(false);
- // Object[] arguments = new Object[] { new MockObject(false),
- // new MockObject(false), new Object() };
- // Statement t = new Statement(mo, "equalSpecificMethod", arguments);
- // t.execute();
- // MockObject.assertCalled("equalSpecificMethod4", arguments);
- // }
- /*
- * Test the method execute() with int method while providing a null
- * parameter.
- */
- public void testExecute_IntMethodNullParameter() throws Exception {
- MockObject mo = new MockObject(false);
- Object[] arguments = new Object[] { null };
- Statement t = new Statement(mo, "intMethod", arguments);
- try {
- t.execute();
- fail("Should throw IllegalArgumentException!");
- } catch (IllegalArgumentException ex) {
- // expected
- }
- }
-
- /*
- * Test the method execute() with int array method while providing an
- * Integer array parameter.
- */
- public void testExecute_IntArrayMethod() throws Exception {
- MockObject mo = new MockObject(false);
- Object[] arguments = new Object[] { new Integer[] { new Integer(1) } };
- Statement t = new Statement(mo, "intArrayMethod", arguments);
- try {
- t.execute();
- fail("Should throw NoSuchMethodException!");
- } catch (NoSuchMethodException ex) {
- // expected
- }
- }
-
- /*
- * Test the method execute() with Integer array method while providing an
- * int array parameter.
- */
- public void testExecute_IntegerArrayMethod() throws Exception {
- MockObject mo = new MockObject(false);
- Object[] arguments = new Object[] { new int[] { 1 } };
- Statement t = new Statement(mo, "integerArrayMethod", arguments);
- try {
- t.execute();
- fail("Should throw NoSuchMethodException!");
- } catch (NoSuchMethodException ex) {
- // expected
- }
- }
-
-
- /*
- * Test for special case of overloaded method execute
- */
- public void testExecute_AmbiguousOverloadedMethods() throws Exception {
- MockObject mo = new MockObject();
- Object[] arguments = new Object[] { new MockObject(), new MockObject() };
- Statement t = new Statement(mo, "overloadedMethod", arguments);
- t.execute();
- MockObject.assertCalled("overloadedmethod", arguments);
-
- arguments = new Object[] { new MockParent(), new MockParent() };
- t = new Statement(mo, "overloadedMethod", arguments);
- t.execute();
- MockObject.assertCalled("overloadedmethod2", arguments);
-
- arguments = new Object[] { new MockObject(), new MockObject() };
- t = new Statement(mo, "overloadedMethodB", arguments);
- try{
- t.execute();
- fail("should throw Exception");
- }catch(Exception e){
- }
-
- arguments = new Object[] { new MockObject(), new MockParent() };
- t = new Statement(mo, "overloadedMethodB", arguments);
- t.execute();
- MockObject.assertCalled("overloadedmethodB", arguments);
- }
-
- /*
- * Test for special case of the same signature but different return type
- */
- public void testExecute_SameSignatureDifferentReturn() throws Exception {
- // Regression for Harmony-5854
- Object[] ancestorArguments = new Object[] { new Ancestor() {
- } };
- Object[] offspringArguments = new Object[] { new Offspring() {
- } };
- String methodName = "visit";
- Statement statement = null;
-
- statement = new Statement(new StringInspector(), "visit",
- ancestorArguments);
- statement.execute();
- TInspectorCluster.assertMethodCalled(methodName, ancestorArguments,
- TInspectorCluster.ANCESTOR_STRING);
-
- statement = new Statement(new StringInspector(), "visit",
- offspringArguments);
- statement.execute();
- TInspectorCluster.assertMethodCalled(methodName, offspringArguments,
- TInspectorCluster.OFFSPRING_STRING);
-
- statement = new Statement(new BooleanInspector(), "visit",
- ancestorArguments);
- statement.execute();
- TInspectorCluster.assertMethodCalled(methodName, ancestorArguments,
- TInspectorCluster.ANCESTOR_BOOLEAN);
-
- statement = new Statement(new BooleanInspector(), "visit",
- offspringArguments);
- statement.execute();
- TInspectorCluster.assertMethodCalled(methodName, offspringArguments,
- TInspectorCluster.OFFSPRING_BOOLEAN);
-
- statement = new Statement(new CharacterInspector(), "visit",
- ancestorArguments);
- statement.execute();
- TInspectorCluster.assertMethodCalled(methodName, ancestorArguments,
- TInspectorCluster.ANCESTOR_CHARACTER);
-
- statement = new Statement(new CharacterInspector(), "visit",
- offspringArguments);
- statement.execute();
- TInspectorCluster.assertMethodCalled(methodName, offspringArguments,
- TInspectorCluster.OFFSPRING_CHARACTER);
-
- statement = new Statement(new ShortInspector(), "visit",
- ancestorArguments);
- statement.execute();
- TInspectorCluster.assertMethodCalled(methodName, ancestorArguments,
- TInspectorCluster.ANCESTOR_SHORT);
-
- statement = new Statement(new ShortInspector(), "visit",
- offspringArguments);
- statement.execute();
- TInspectorCluster.assertMethodCalled(methodName, offspringArguments,
- TInspectorCluster.OFFSPRING_SHORT);
-
- statement = new Statement(new IntegerInspector(), "visit",
- ancestorArguments);
- statement.execute();
- TInspectorCluster.assertMethodCalled(methodName, ancestorArguments,
- TInspectorCluster.ANCESTOR_INTEGER);
-
- statement = new Statement(new IntegerInspector(), "visit",
- offspringArguments);
- statement.execute();
- TInspectorCluster.assertMethodCalled(methodName, offspringArguments,
- TInspectorCluster.OFFSPRING_INTEGER);
-
- statement = new Statement(new LongInspector(), "visit",
- ancestorArguments);
- statement.execute();
- TInspectorCluster.assertMethodCalled(methodName, ancestorArguments,
- TInspectorCluster.ANCESTOR_LONG);
-
- statement = new Statement(new LongInspector(), "visit",
- offspringArguments);
- statement.execute();
- TInspectorCluster.assertMethodCalled(methodName, offspringArguments,
- TInspectorCluster.OFFSPRING_LONG);
-
- statement = new Statement(new FloatInspector(), "visit",
- ancestorArguments);
- statement.execute();
- TInspectorCluster.assertMethodCalled(methodName, ancestorArguments,
- TInspectorCluster.ANCESTOR_FLOAT);
-
- statement = new Statement(new FloatInspector(), "visit",
- offspringArguments);
- statement.execute();
- TInspectorCluster.assertMethodCalled(methodName, offspringArguments,
- TInspectorCluster.OFFSPRING_FLOAT);
-
- statement = new Statement(new DoubleInspector(), "visit",
- ancestorArguments);
- statement.execute();
- TInspectorCluster.assertMethodCalled(methodName, ancestorArguments,
- TInspectorCluster.ANCESTOR_DOUBLE);
-
- statement = new Statement(new DoubleInspector(), "visit",
- offspringArguments);
- statement.execute();
- TInspectorCluster.assertMethodCalled(methodName, offspringArguments,
- TInspectorCluster.OFFSPRING_DOUBLE);
-
- statement = new Statement(new ObjectInspector(), "visit",
- ancestorArguments);
- statement.execute();
- TInspectorCluster.assertMethodCalled(methodName, ancestorArguments,
- TInspectorCluster.ANCESTOR_OBJECT);
-
- statement = new Statement(new ObjectInspector(), "visit",
- offspringArguments);
- statement.execute();
- TInspectorCluster.assertMethodCalled(methodName, offspringArguments,
- TInspectorCluster.OFFSPRING_OBJECT);
-
- statement = new Statement(new ObjectListInspector(), "visit",
- ancestorArguments);
- statement.execute();
- TInspectorCluster.assertMethodCalled(methodName, ancestorArguments,
- TInspectorCluster.ANCESTOR_OBJECT_LIST);
-
- statement = new Statement(new ObjectListInspector(), "visit",
- offspringArguments);
- statement.execute();
- TInspectorCluster.assertMethodCalled(methodName, offspringArguments,
- TInspectorCluster.OFFSPRING_OBJECT_LIST);
- }
-
- public void test_Statement_Execute() throws Exception {
- MockTreeMapInnerClass innerTreeMap = new MockTreeMapInnerClass();
- Statement statement = new Statement(innerTreeMap, "get",
- new Object[] { "key" });
- statement.execute();
- assertEquals("value", innerTreeMap.getReturnValue());
- innerTreeMap.reset();
- }
-
- class MockTreeMapInnerClass extends TreeMap {
-
- private Object returnValue = null;
-
- public Object getReturnValue() {
- return returnValue;
- }
-
- public void reset() {
- returnValue = null;
- }
-
- @Override
- public Object get(Object key) {
- return returnValue = "value";
- }
- }
-
- /*
- * Super class of MockObject.
- */
- public static class MockParent {
-
- protected static String calledMethod = null;
-
- protected static Vector<Object> receivedArguments = new Vector<Object>();
-
- public void method() {
- reset();
- calledMethod = "method1";
- }
-
- protected void method(Boolean o) {
- reset();
- calledMethod = "method1-1";
- receivedArguments.add(o);
- }
-
- public void method(Number n) {
- reset();
- calledMethod = "method1-2";
- receivedArguments.add(n);
- }
-
- public void method(Integer o) {
- reset();
- calledMethod = "method1-3";
- receivedArguments.add(o);
- }
-
- public void method(Object o) {
- reset();
- calledMethod = "method2";
- receivedArguments.add(o);
- }
-
- public void method(String o) {
- reset();
- calledMethod = "method3";
- receivedArguments.add(o);
- }
-
- public void method(Object o, Object o2) {
- reset();
- calledMethod = "method4";
- receivedArguments.add(o);
- receivedArguments.add(o2);
- throw new NullPointerException();
- }
-
- public void method(Object o, Number n, String s) {
- reset();
- calledMethod = "method5";
- receivedArguments.add(o);
- receivedArguments.add(n);
- receivedArguments.add(s);
- }
-
- public static void reset() {
- receivedArguments.clear();
- calledMethod = null;
- }
- }
-
- /*
- * Mock object.
- */
- public static class MockObject extends MockParent {
-
- public MockObject() {
- reset();
- calledMethod = "new0";
- }
-
- public MockObject(boolean testingConstructor) {
- reset();
- if (testingConstructor) {
- calledMethod = "new1";
- }
- }
-
- public MockObject(String o) {
- reset();
- calledMethod = "new3";
- receivedArguments.add(o);
- }
-
- public MockObject(Object o) {
- reset();
- calledMethod = "new2";
- receivedArguments.add(o);
- }
-
- public MockObject(Integer o) {
- reset();
- calledMethod = "new1-2";
- receivedArguments.add(o);
- }
- public MockObject(Object o, Object o2) {
- reset();
- calledMethod = "new4";
- receivedArguments.add(o);
- receivedArguments.add(o2);
- throw new NullPointerException();
- }
-
- @SuppressWarnings("unchecked")
- public MockObject(Object o, Vector v, Class c) {
- reset();
- calledMethod = "new5";
- receivedArguments.add(o);
- receivedArguments.add(v);
- receivedArguments.add(c);
- }
-
- public void intMethod(int i) {
- reset();
- calledMethod = "intMethod";
- receivedArguments.add(new Integer(i));
- }
-
- public void intArrayMethod(int[] ia) {
- reset();
- calledMethod = "intArrayMethod";
- receivedArguments.add(ia);
- }
-
- public void integerArrayMethod(Integer[] ia) {
- reset();
- calledMethod = "integerArrayMethod";
- receivedArguments.add(ia);
- }
-
- public void methodB(Integer i) {
- reset();
- calledMethod = "methodB1";
- receivedArguments.add(i);
- }
-
- public void methodB(boolean b) {
- reset();
- calledMethod = "methodB2";
- receivedArguments.add(new Boolean(b));
- }
-
- public void overloadedMethod(MockObject o1, MockObject o2){
- reset();
- calledMethod = "overloadedmethod";
- receivedArguments.add(o1);
- receivedArguments.add(o2);
- }
-
- public void overloadedMethod(MockParent o1, MockParent o2){
- reset();
- calledMethod = "overloadedmethod2";
- receivedArguments.add(o1);
- receivedArguments.add(o2);
- }
-
- public void overloadedMethod(MockObject o1, MockParent o2){
- reset();
- calledMethod = "overloadedmethod2";
- receivedArguments.add(o1);
- receivedArguments.add(o2);
- }
-
- public void overloadedMethodB(MockObject o1, MockParent o2){
- reset();
- calledMethod = "overloadedmethodB";
- receivedArguments.add(o1);
- receivedArguments.add(o2);
- }
-
- public void overloadedMethodB(MockParent o1, MockObject o2){
- reset();
- calledMethod = "overloadedmethodB2";
- receivedArguments.add(o1);
- receivedArguments.add(o2);
- }
-
- public static void staticMethod(Object o) {
- reset();
- calledMethod = "staticMethod";
- receivedArguments.add(o);
- }
-
- // public void equalSpecificMethod(MockObject o, MockParent p) {
- // reset();
- // calledMethod = "equalSpecificMethod1";
- // receivedArguments.add(o);
- // receivedArguments.add(p);
- // }
- //
- // public void equalSpecificMethod(MockParent p, MockObject o) {
- // reset();
- // calledMethod = "equalSpecificMethod2";
- // receivedArguments.add(p);
- // receivedArguments.add(o);
- // }
- //
- // public void equalSpecificMethod(MockParent p, MockObject o, Object
- // o2)
- // throws Exception {
- // reset();
- // calledMethod = "equalSpecificMethod4";
- // receivedArguments.add(p);
- // receivedArguments.add(o);
- // receivedArguments.add(o2);
- // }
- //
- // public void equalSpecificMethod(MockObject o, MockParent p, Object
- // o2) {
- // reset();
- // calledMethod = "equalSpecificMethod3";
- // receivedArguments.add(o);
- // receivedArguments.add(p);
- // receivedArguments.add(o2);
- // }
-
- public static Class<?> forName(String o) {
- reset();
- calledMethod = "forName";
- receivedArguments.add(o);
- return null;
- }
-
- public static void assertCalled(String methodName, Object[] arguments) {
- assertEquals(methodName, calledMethod);
- assertTrue(Arrays.equals(arguments, receivedArguments.toArray()));
- reset();
- }
-
- public static void assertNotCalled() {
- assertNull(calledMethod);
- assertTrue(receivedArguments.isEmpty());
- }
- }
-
- public interface IMockObjectA {
- }
-
- public class MockObjectA implements IMockObjectA {
- }
-
- public interface IMockAccess<E> {
- public void setProperty(E e);
- }
-
- public class MockAccess implements IMockAccess<IMockObjectA> {
-
- private IMockObjectA property;
-
- public void setProperty(IMockObjectA prop) {
- property = prop;
- }
-
- public IMockObjectA getProperty() {
- return property;
- }
-
- }
-
- public void testExecute_ObjectInterface() throws Exception {
- MockAccess mockAccess = new MockAccess();
- MockObjectA mockObjectA = new MockObjectA();
- new Statement(mockAccess, "setProperty", new Object[] { mockObjectA })
- .execute();
- assertSame(mockObjectA, mockAccess.getProperty());
- }
-
-}
diff --git a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/VetoableChangeListenerProxyTest.java b/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/VetoableChangeListenerProxyTest.java
deleted file mode 100644
index 5e42efe..0000000
--- a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/VetoableChangeListenerProxyTest.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * 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.java.beans;
-
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyVetoException;
-import java.beans.VetoableChangeListener;
-import java.beans.VetoableChangeListenerProxy;
-
-import junit.framework.TestCase;
-
-/**
- * Unit test for VetoableChangeListenerProxy
- */
-public class VetoableChangeListenerProxyTest extends TestCase {
- VetoableChangeListenerProxy proxy;
-
- VetoableChangeListener listener = new MockVetoableChangeListener();
-
- String name = "mock";
-
- private static PropertyChangeEvent event = null;
-
- /*
- * @see TestCase#setUp()
- */
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- proxy = new VetoableChangeListenerProxy(name, listener);
- }
-
- /*
- * @see TestCase#tearDown()
- */
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-
- public void testVetoableChangeListenerProxy() throws PropertyVetoException {
- proxy = new VetoableChangeListenerProxy(null, listener);
- assertSame(listener, proxy.getListener());
- assertNull(proxy.getPropertyName());
- PropertyChangeEvent newevent = new PropertyChangeEvent(new Object(),
- "name", new Object(), new Object());
- proxy.vetoableChange(newevent);
- assertSame(newevent, event);
- proxy = new VetoableChangeListenerProxy(name, null);
- assertSame(name, proxy.getPropertyName());
- assertNull(proxy.getListener());
- try {
- proxy.vetoableChange(new PropertyChangeEvent(new Object(), "name",
- new Object(), new Object()));
- fail("should null pointer");
- } catch (NullPointerException e) {
- }
-
- proxy = new VetoableChangeListenerProxy(name, listener);
- assertSame(listener, proxy.getListener());
- assertSame(name, proxy.getPropertyName());
- newevent = new PropertyChangeEvent(new Object(), "name", new Object(),
- new Object());
- assertSame(name, proxy.getPropertyName());
- proxy.vetoableChange(newevent);
- assertSame(newevent, event);
- }
-
- public void testVetoableChange() throws PropertyVetoException {
- PropertyChangeEvent newevent = new PropertyChangeEvent(new Object(),
- "exception", new Object(), new Object());
- try {
- proxy.vetoableChange(newevent);
- fail("should throw exception");
- } catch (PropertyVetoException e) {
- }
- proxy.vetoableChange(null);
- assertNull(event);
- }
-
- public static class MockVetoableChangeListener implements
- VetoableChangeListener {
-
- public void vetoableChange(PropertyChangeEvent newevent)
- throws PropertyVetoException {
- event = newevent;
- if (event != null && event.getPropertyName().equals("exception")) {
- throw new PropertyVetoException("", newevent);
- }
- }
-
- }
-
-}
diff --git a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/VetoableChangeSupportTest.java b/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/VetoableChangeSupportTest.java
deleted file mode 100644
index 28aeb89..0000000
--- a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/VetoableChangeSupportTest.java
+++ /dev/null
@@ -1,1924 +0,0 @@
-/*
- * 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.java.beans;
-
-import java.beans.EventHandler;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyVetoException;
-import java.beans.VetoableChangeListener;
-import java.beans.VetoableChangeListenerProxy;
-import java.beans.VetoableChangeSupport;
-import java.beans.beancontext.BeanContextChildSupport;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.ObjectStreamClass;
-import java.io.Serializable;
-import java.util.ArrayList;
-
-import junit.framework.TestCase;
-
-import org.apache.harmony.beans.tests.support.beancontext.mock.MockBeanContextDelegateS;
-import org.apache.harmony.beans.tests.support.beancontext.mock.MockVetoableChangeListener;
-import org.apache.harmony.beans.tests.support.mock.NonSerializedVCListener;
-import org.apache.harmony.beans.tests.support.mock.SerializedVCListener;
-import org.apache.harmony.testframework.serialization.SerializationTest;
-import org.apache.harmony.testframework.serialization.SerializationTest.SerializableAssert;
-
-import tests.util.SerializationTester;
-
-/**
- * Unit test for VetoableChangeSupport
- */
-public class VetoableChangeSupportTest extends TestCase {
-
- /*
- * Constructor a VetoableChangeSupport instance with normal input
- */
- public void testVetoableChangeSupport() {
- MockSource source = new MockSource();
- new VetoableChangeSupport(source);
-
- }
-
- /*
- * Class under test for void addVetoableChangeListener(String,
- * VetoableChangeListener)
- */
- public void testAddVetoableChangeListenerStringVetoableChangeListener() {
- MockSource source = new MockSource();
- VetoableChangeSupport support = new VetoableChangeSupport(source);
-
- VetoableChangeListener proxy = EventHandler.create(
- VetoableChangeListener.class, source, "setText");
- String propertyName = "label";
- support.addVetoableChangeListener(propertyName, proxy);
-
- assertTrue(support.hasListeners(propertyName));
- assertFalse(support.hasListeners("text"));
-
- VetoableChangeListener[] listeners1 = support
- .getVetoableChangeListeners();
- VetoableChangeListener[] listeners2 = support
- .getVetoableChangeListeners(propertyName);
- VetoableChangeListener[] listeners3 = support
- .getVetoableChangeListeners("text");
-
- assertEquals(0, listeners3.length);
- assertEquals(1, listeners1.length);
- assertEquals(1, listeners2.length);
-
- assertSame(proxy, listeners2[0]);
- VetoableChangeListenerProxy wrappers = (VetoableChangeListenerProxy) listeners1[0];
- assertSame(proxy, wrappers.getListener());
- assertEquals(propertyName, wrappers.getPropertyName());
-
- }
-
- /*
- * add a null listener
- */
- public void testAddVetoableChangeListenerStringVetoableChangeListener_null() {
- MockSource source = new MockSource();
- VetoableChangeSupport support = new VetoableChangeSupport(source);
-
- String propertyName = "label";
- support.addVetoableChangeListener(propertyName, null);
- VetoableChangeListener[] listeners1 = support
- .getVetoableChangeListeners();
- VetoableChangeListener[] listeners2 = support
- .getVetoableChangeListeners(propertyName);
-
- assertFalse(support.hasListeners(propertyName));
- assertFalse(support.hasListeners("text"));
-
- assertEquals(0, listeners1.length);
- assertEquals(0, listeners2.length);
- }
-
- /*
- * add a listener which has already been added.
- */
- public void testAddVetoableChangeListenerStringVetoableChangeListener_duplicate() {
- MockSource source = new MockSource();
- VetoableChangeSupport support = new VetoableChangeSupport(source);
-
- VetoableChangeListener proxy = EventHandler.create(
- VetoableChangeListener.class, source, "setText");
- String propertyName = "label";
- support.addVetoableChangeListener(propertyName, proxy);
- {
- assertTrue(support.hasListeners(propertyName));
- assertFalse(support.hasListeners("text"));
-
- VetoableChangeListener[] listeners1 = support
- .getVetoableChangeListeners();
- VetoableChangeListener[] listeners2 = support
- .getVetoableChangeListeners(propertyName);
- VetoableChangeListener[] listeners3 = support
- .getVetoableChangeListeners("text");
-
- assertEquals(0, listeners3.length);
- assertEquals(1, listeners1.length);
- assertEquals(1, listeners2.length);
-
- assertSame(proxy, listeners2[0]);
- VetoableChangeListenerProxy wrappers = (VetoableChangeListenerProxy) listeners1[0];
- assertSame(proxy, wrappers.getListener());
- assertEquals(propertyName, wrappers.getPropertyName());
- }
-
- support.addVetoableChangeListener(propertyName, proxy);
- {
- assertTrue(support.hasListeners(propertyName));
- assertFalse(support.hasListeners("text"));
-
- VetoableChangeListener[] listeners1 = support
- .getVetoableChangeListeners();
- VetoableChangeListener[] listeners2 = support
- .getVetoableChangeListeners(propertyName);
- VetoableChangeListener[] listeners3 = support
- .getVetoableChangeListeners("text");
-
- assertEquals(0, listeners3.length);
- assertEquals(2, listeners1.length);
- assertEquals(2, listeners2.length);
- for (int i = 0; i < listeners2.length; i++) {
- assertSame(proxy, listeners2[i]);
- VetoableChangeListenerProxy wrappers = (VetoableChangeListenerProxy) listeners1[i];
- assertSame(proxy, wrappers.getListener());
- assertEquals(propertyName, wrappers.getPropertyName());
- }
- }
- }
-
- /*
- * add listener with null property name.
- */
- public void testAddVetoableChangeListenerStringVetoableChangeListener_property_null() {
- MockSource source = new MockSource();
- VetoableChangeSupport support = new VetoableChangeSupport(source);
-
- VetoableChangeListener proxy = EventHandler.create(
- VetoableChangeListener.class, source, "setText");
- String propertyName = null;
- support.addVetoableChangeListener(propertyName, proxy);
- }
-
- /*
- * add listeners to an invalid property
- */
- public void testAddVetoableChangeListenerStringVetoableChangeListener_property_invalid() {
- MockSource source = new MockSource();
- VetoableChangeSupport support = new VetoableChangeSupport(source);
-
- VetoableChangeListener proxy = EventHandler.create(
- VetoableChangeListener.class, source, "setText");
- String propertyName = "label_invalid";
- support.addVetoableChangeListener(propertyName, proxy);
-
- VetoableChangeListener[] listeners1 = support
- .getVetoableChangeListeners();
- VetoableChangeListener[] listeners2 = support
- .getVetoableChangeListeners("label_invalid");
- assertEquals(1, listeners1.length);
- assertEquals(1, listeners2.length);
- assertEquals("label_invalid",
- ((VetoableChangeListenerProxy) listeners1[0]).getPropertyName());
- assertSame(proxy, listeners2[0]);
- assertFalse(support.hasListeners("label"));
- }
-
- /*
- * add different listener with a particular property name.
- */
- public void testAddVetoableChangeListenerStringVetoableChangeListener_property_duplicate() {
- MockSource source = new MockSource();
- VetoableChangeSupport support = new VetoableChangeSupport(source);
-
- VetoableChangeListener proxy = EventHandler.create(
- VetoableChangeListener.class, source, "setText");
- VetoableChangeListener proxy2 = EventHandler.create(
- VetoableChangeListener.class, source, "setText");
-
- String propertyName = "label";
- support.addVetoableChangeListener(propertyName, proxy);
- support.addVetoableChangeListener(propertyName, proxy2);
-
- assertTrue(support.hasListeners(propertyName));
- assertFalse(support.hasListeners("text"));
-
- VetoableChangeListener[] listeners1 = support
- .getVetoableChangeListeners();
- VetoableChangeListener[] listeners2 = support
- .getVetoableChangeListeners(propertyName);
- VetoableChangeListener[] listeners3 = support
- .getVetoableChangeListeners("text");
-
- assertEquals(0, listeners3.length);
- assertEquals(2, listeners1.length);
- assertEquals(2, listeners2.length);
- for (int i = 0; i < listeners2.length; i++) {
- assertTrue((proxy == listeners2[i]) || (proxy2 == listeners2[i]));
- VetoableChangeListenerProxy wrappers = (VetoableChangeListenerProxy) listeners1[i];
- assertTrue((proxy == wrappers.getListener())
- || (proxy2 == wrappers.getListener()));
- assertEquals(propertyName, wrappers.getPropertyName());
- }
- }
-
- /*
- * Class under test for void
- * addVetoableChangeListener(VetoableChangeListener)
- */
- public void testAddVetoableChangeListenerVetoableChangeListener() {
- MockSource source = new MockSource();
- VetoableChangeSupport support = new VetoableChangeSupport(source);
-
- VetoableChangeListener proxy = EventHandler.create(
- VetoableChangeListener.class, source, "setText");
- support.addVetoableChangeListener(proxy);
-
- assertTrue(support.hasListeners("label"));
- assertTrue(support.hasListeners("text"));
-
- VetoableChangeListener[] listeners1 = support
- .getVetoableChangeListeners();
- VetoableChangeListener[] listeners2 = support
- .getVetoableChangeListeners("label");
- VetoableChangeListener[] listeners3 = support
- .getVetoableChangeListeners("text");
-
- assertEquals(1, listeners1.length);
- assertEquals(0, listeners2.length);
- assertEquals(0, listeners3.length);
-
- assertSame(proxy, listeners1[0]);
- }
-
- /*
- * add a null listener
- */
- public void testAddVetoableChangeListenerVetoableChangeListener_null() {
- MockSource source = new MockSource();
- VetoableChangeSupport support = new VetoableChangeSupport(source);
- support.addVetoableChangeListener(null);
-
- assertFalse(support.hasListeners("label"));
- assertFalse(support.hasListeners("text"));
-
- VetoableChangeListener[] listeners1 = support
- .getVetoableChangeListeners();
- VetoableChangeListener[] listeners2 = support
- .getVetoableChangeListeners("label");
- VetoableChangeListener[] listeners3 = support
- .getVetoableChangeListeners("text");
-
- assertEquals(0, listeners1.length);
- assertEquals(0, listeners2.length);
- assertEquals(0, listeners3.length);
- }
-
- /*
- * add duplicated listeners
- */
- public void testAddVetoableChangeListenerVetoableChangeListener_duplicate() {
- MockSource source = new MockSource();
- VetoableChangeSupport support = new VetoableChangeSupport(source);
-
- VetoableChangeListener proxy = EventHandler.create(
- VetoableChangeListener.class, source, "setText");
- support.addVetoableChangeListener(proxy);
- support.addVetoableChangeListener(proxy);
-
- assertTrue(support.hasListeners("label"));
- assertTrue(support.hasListeners("text"));
-
- VetoableChangeListener[] listeners1 = support
- .getVetoableChangeListeners();
- VetoableChangeListener[] listeners2 = support
- .getVetoableChangeListeners("label");
- VetoableChangeListener[] listeners3 = support
- .getVetoableChangeListeners("text");
-
- assertEquals(2, listeners1.length);
- assertEquals(0, listeners2.length);
- assertEquals(0, listeners3.length);
- for (VetoableChangeListener element : listeners1) {
- assertSame(proxy, element);
- }
- }
-
- /*
- * add two different listeners
- */
- public void testAddVetoableChangeListenerVetoableChangeListener_TwoDifferent() {
- MockSource source = new MockSource();
- VetoableChangeSupport support = new VetoableChangeSupport(source);
-
- VetoableChangeListener proxy = EventHandler.create(
- VetoableChangeListener.class, source, "setText");
- VetoableChangeListener proxy2 = EventHandler.create(
- VetoableChangeListener.class, source, "getText");
- support.addVetoableChangeListener(proxy);
- support.addVetoableChangeListener(proxy2);
-
- assertTrue(support.hasListeners("label"));
- assertTrue(support.hasListeners("text"));
-
- VetoableChangeListener[] listeners1 = support
- .getVetoableChangeListeners();
- VetoableChangeListener[] listeners2 = support
- .getVetoableChangeListeners("label");
- VetoableChangeListener[] listeners3 = support
- .getVetoableChangeListeners("text");
-
- assertEquals(2, listeners1.length);
- assertEquals(0, listeners2.length);
- assertEquals(0, listeners3.length);
- for (VetoableChangeListener element : listeners1) {
- assertTrue((proxy == element) || (proxy2 == element));
- }
- }
-
- /*
- * add a VetoableChangeListenerProxy
- */
- public void testAddVetoableChangeListenerVetoableChangeListener_Proxy() {
- MockSource source = new MockSource();
- VetoableChangeSupport support = new VetoableChangeSupport(source);
-
- VetoableChangeListener proxy = EventHandler.create(
- VetoableChangeListener.class, source, "setText");
-
- proxy = new MockVetoableChangeListener();
- String propertyName = "label";
-
- VetoableChangeListenerProxy listenerProxy = new VetoableChangeListenerProxy(
- propertyName, proxy);
- assertFalse(support.hasListeners("label"));
- try{
- support.addVetoableChangeListener(listenerProxy);
- fail("should throw NPE");
- }catch(NullPointerException e){
- //expected
- e.printStackTrace();
- }
- assertTrue(support.hasListeners("label"));
- assertTrue(support.hasListeners(propertyName));
- assertFalse(support.hasListeners("text"));
-
- {
- VetoableChangeListener[] listeners1 = support
- .getVetoableChangeListeners();
- VetoableChangeListener[] listeners2 = support
- .getVetoableChangeListeners(propertyName);
- VetoableChangeListener[] listeners3 = support
- .getVetoableChangeListeners("text");
-
- assertEquals(0, listeners3.length);
- assertEquals(1, listeners1.length);
- assertEquals(1, listeners2.length);
-
- assertSame(proxy, listeners2[0]);
- VetoableChangeListenerProxy wrappers = (VetoableChangeListenerProxy) listeners1[0];
- assertSame(proxy, wrappers.getListener());
- assertEquals(propertyName, wrappers.getPropertyName());
- }
- // add test for remove proxy
- support.removeVetoableChangeListener(listenerProxy);
- {
- VetoableChangeListener[] listeners1 = support
- .getVetoableChangeListeners();
- VetoableChangeListener[] listeners2 = support
- .getVetoableChangeListeners(propertyName);
- assertEquals(0, listeners1.length);
- assertEquals(0, listeners2.length);
- }
-
- }
-
- /*
- * Class under test for void fireVetoableChange(PropertyChangeEvent)
- */
- public void testFireVetoableChangePropertyChangeEvent()
- throws PropertyVetoException {
- MockSource source = new MockSource();
- VetoableChangeSupport support = new VetoableChangeSupport(source);
-
- VetoableChangeListener proxy = EventHandler.create(
- VetoableChangeListener.class, source, "setText");
- support.addVetoableChangeListener(proxy);
- PropertyChangeEvent event = new PropertyChangeEvent(source, "label",
- "Label: old", "Label: new");
- support.fireVetoableChange(event);
-
- assertEquals("called", source.getText());
- }
-
- public void testFireVetoableChangePropertyChangeEvent_Veto()
- throws PropertyVetoException {
- MockSource source = new MockSource();
- VetoableChangeSupport support = new VetoableChangeSupport(source);
-
- MockVetoListener normal1 = new MockVetoListener(false, "Norm1");
- support.addVetoableChangeListener(normal1);
-
- MockVetoListener veto1 = new MockVetoListener(true, "Veto1");
- support.addVetoableChangeListener(veto1);
-
- MockVetoListener normal2 = new MockVetoListener(false, "Norm2");
- support.addVetoableChangeListener(normal2);
-
- MockVetoListener veto2 = new MockVetoListener(true, "Veto2");
- support.addVetoableChangeListener(veto2);
-
- PropertyChangeEvent event = new PropertyChangeEvent(source, "label",
- "1", "5");
- try {
- support.fireVetoableChange(event);
- } catch (PropertyVetoException e) {
-
- }
-
- assertEquals(4, support.getVetoableChangeListeners().length);
-
- // Check the calling status of the first listener
- {
- ArrayList<Object> oldValues = normal1.getOldValues();
- assertEquals(2, oldValues.size());
- assertEquals("1", oldValues.get(0));
- assertEquals("5", oldValues.get(1));
-
- ArrayList<Object> newValues = normal1.getNewValues();
- assertEquals(2, newValues.size());
- assertEquals("5", newValues.get(0));
- assertEquals("1", newValues.get(1));
- }
-
- // Check the status of the second (Veto) listeners
- {
- ArrayList<Object> oldValues = veto1.getOldValues();
- assertEquals(2, oldValues.size());
- assertEquals("1", oldValues.get(0));
- assertEquals("5", oldValues.get(1));
-
- ArrayList<Object> newValues = veto1.getNewValues();
- assertEquals(2, newValues.size());
- assertEquals("5", newValues.get(0));
- assertEquals("1", newValues.get(1));
- }
-
- // Check the status of the third listeners
- {
- ArrayList<Object> oldValues = normal2.getOldValues();
- assertEquals(1, oldValues.size());
- assertEquals("5", oldValues.get(0));
-
- ArrayList<Object> newValues = normal2.getNewValues();
- assertEquals(1, newValues.size());
- assertEquals("1", newValues.get(0));
- }
-
- // Check the status of the fourth (Veto) listeners
- {
- ArrayList<Object> oldValues = veto2.getOldValues();
- assertEquals(1, oldValues.size());
- assertEquals("5", oldValues.get(0));
-
- ArrayList<Object> newValues = veto2.getNewValues();
- assertEquals(1, newValues.size());
- assertEquals("1", newValues.get(0));
- }
- }
-
- /*
- * fire a null event
- */
- public void testFireVetoableChangePropertyChangeEvent_null()
- throws PropertyVetoException {
- MockSource source = new MockSource();
- VetoableChangeSupport support = new VetoableChangeSupport(source);
-
- VetoableChangeListener proxy = EventHandler.create(
- VetoableChangeListener.class, source, "setText");
- support.addVetoableChangeListener(proxy);
- try {
- support.fireVetoableChange(null);
- fail("Should throw NullPointerException.");
- } catch (NullPointerException e) {
- // expected
- }
- }
-
- /*
- * register for one property
- */
- public void testFireVetoableChangePropertyChangeEvent_property()
- throws PropertyVetoException {
- MockSource source = new MockSource();
- VetoableChangeSupport support = new VetoableChangeSupport(source);
-
- VetoableChangeListener proxy = EventHandler.create(
- VetoableChangeListener.class, source, "setText");
-
- String propertyName = "label";
- support.addVetoableChangeListener(propertyName, proxy);
- PropertyChangeEvent event = new PropertyChangeEvent(source, "label",
- "Label: old", "Label: new");
- support.fireVetoableChange(event);
-
- assertEquals("called", source.getText());
- }
-
- public void testFireVetoableChangePropertyChangeEvent_property_invalid()
- throws PropertyVetoException {
- MockSource source = new MockSource();
- VetoableChangeSupport support = new VetoableChangeSupport(source);
-
- VetoableChangeListener proxy = EventHandler.create(
- VetoableChangeListener.class, source, "setText");
-
- String propertyName = "label_invalid";
- support.addVetoableChangeListener(propertyName, proxy);
- PropertyChangeEvent event = new PropertyChangeEvent(source, "label",
- "Label: old", "Label: new");
- support.fireVetoableChange(event);
-
- assertEquals("text.default", source.getText());
- }
-
- /*
- * there are two same listeners, and another different listener.
- */
- public void testFireVetoableChangePropertyChangeEvent_DuplicateListener()
- throws PropertyVetoException {
- MockSource source = new MockSource();
- VetoableChangeSupport support = new VetoableChangeSupport(source);
-
- VetoableChangeListener proxy = EventHandler.create(
- VetoableChangeListener.class, source, "increaseTop");
- VetoableChangeListener proxy2 = EventHandler.create(
- VetoableChangeListener.class, source, "setText");
-
- support.addVetoableChangeListener(proxy);
- support.addVetoableChangeListener(proxy);
- support.addVetoableChangeListener(proxy2);
-
- PropertyChangeEvent event = new PropertyChangeEvent(source, "label",
- "Label: old", "Label: new");
- support.fireVetoableChange(event);
- assertEquals(2, source.getTop());
- assertEquals("called", source.getText());
- }
-
- /*
- * listener is null
- */
- public void testFireVetoableChangePropertyChangeEvent_listener_null()
- throws PropertyVetoException {
- MockSource source = new MockSource();
- VetoableChangeSupport support = new VetoableChangeSupport(source);
-
- support.addVetoableChangeListener(null);
- PropertyChangeEvent event = new PropertyChangeEvent(source, "label",
- "Label: old", "Label: new");
- support.fireVetoableChange(event);
- }
-
- /*
- * Class under test for void fireVetoableChange(String, boolean, boolean)
- */
- public void testFireVetoableChangeStringbooleanboolean()
- throws PropertyVetoException {
- MockSource source = new MockSource();
- VetoableChangeSupport support = new VetoableChangeSupport(source);
-
- VetoableChangeListener proxy = EventHandler.create(
- VetoableChangeListener.class, source, "setText");
- support.addVetoableChangeListener(proxy);
- support.fireVetoableChange("label", true, false);
-
- assertEquals("called", source.getText());
- }
-
- /*
- * register a null listener
- */
- public void testFireVetoableChangeStringbooleanboolean_listener_null()
- throws PropertyVetoException {
- MockSource source = new MockSource();
- VetoableChangeSupport support = new VetoableChangeSupport(source);
-
- support.addVetoableChangeListener(null);
- support.fireVetoableChange("label", true, false);
- }
-
- /*
- * register listener for property "label".
- */
- public void testFireVetoableChangeStringbooleanboolean_property()
- throws PropertyVetoException {
- MockSource source = new MockSource();
- VetoableChangeSupport support = new VetoableChangeSupport(source);
-
- VetoableChangeListener proxy = EventHandler.create(
- VetoableChangeListener.class, source, "setText");
- support.addVetoableChangeListener("label", proxy);
- support.fireVetoableChange("label", true, false);
-
- assertEquals("called", source.getText());
- }
-
- /*
- * register a null listener
- */
- public void testFireVetoableChangeStringbooleanboolean_listener_null_property()
- throws PropertyVetoException {
- MockSource source = new MockSource();
- VetoableChangeSupport support = new VetoableChangeSupport(source);
-
- EventHandler.create(VetoableChangeListener.class, source, "setText");
- support.addVetoableChangeListener("label", null);
- support.fireVetoableChange("label", true, false);
- }
-
- /*
- * two different listeners registered for all
- */
- public void testFireVetoableChangeStringbooleanboolean_twoListeners()
- throws PropertyVetoException {
- MockSource source = new MockSource();
- VetoableChangeSupport support = new VetoableChangeSupport(source);
-
- VetoableChangeListener proxy = EventHandler.create(
- VetoableChangeListener.class, source, "setText");
- VetoableChangeListener proxy2 = EventHandler.create(
- VetoableChangeListener.class, source, "increaseTop");
- support.addVetoableChangeListener(proxy);
- support.addVetoableChangeListener(proxy2);
-
- support.fireVetoableChange("label", true, false);
-
- assertEquals("called", source.getText());
- assertEquals(1, source.getTop());
- }
-
- /*
- * two different listeners registered for property "label"
- */
- public void testFireVetoableChangeStringbooleanboolean_property_twoListeners()
- throws PropertyVetoException {
- MockSource source = new MockSource();
- VetoableChangeSupport support = new VetoableChangeSupport(source);
-
- VetoableChangeListener proxy = EventHandler.create(
- VetoableChangeListener.class, source, "setText");
- VetoableChangeListener proxy2 = EventHandler.create(
- VetoableChangeListener.class, source, "increaseTop");
- support.addVetoableChangeListener("label", proxy);
- support.addVetoableChangeListener("label", proxy2);
-
- support.fireVetoableChange("label", true, false);
-
- assertEquals("called", source.getText());
- assertEquals(1, source.getTop());
- }
-
- /*
- * null propertyname
- */
- public void testFireVetoableChangeStringbooleanboolean_Property_null()
- throws PropertyVetoException {
- MockSource source = new MockSource();
- VetoableChangeSupport support = new VetoableChangeSupport(source);
-
- VetoableChangeListener proxy = EventHandler.create(
- VetoableChangeListener.class, source, "label", "source.text");
- support.addVetoableChangeListener(proxy);
- support.fireVetoableChange(null, true, false);
- assertEquals(source.getText(), source.getLabel());
- }
-
- /*
- * register listener to label.
- */
- public void testFireVetoableChangeStringbooleanboolean_listener_Property_null()
- throws PropertyVetoException {
- MockSource source = new MockSource();
- VetoableChangeSupport support = new VetoableChangeSupport(source);
-
- VetoableChangeListener proxy = EventHandler.create(
- VetoableChangeListener.class, source, "label", "source.text");
- support.addVetoableChangeListener("label", proxy);
- support.fireVetoableChange(null, true, false);
- assertEquals("label.default", source.getLabel());
- }
-
- /*
- * register a null listener
- */
- public void testFireVetoableChangeStringbooleanboolean_listener_Null_Property_null()
- throws PropertyVetoException {
- MockSource source = new MockSource();
- VetoableChangeSupport support = new VetoableChangeSupport(source);
-
- VetoableChangeListener proxy = EventHandler.create(
- VetoableChangeListener.class, source, "label", "source.text");
- support.addVetoableChangeListener("label", proxy);
- support.fireVetoableChange(null, true, false);
- assertEquals("label.default", source.getLabel());
- }
-
- /*
- * invalid propertyname
- */
- public void testFireVetoableChangeStringbooleanboolean_Property_invalid()
- throws PropertyVetoException {
- MockSource source = new MockSource();
- VetoableChangeSupport support = new VetoableChangeSupport(source);
-
- VetoableChangeListener proxy = EventHandler.create(
- VetoableChangeListener.class, source, "label", "source.text");
- support.addVetoableChangeListener(proxy);
- String newText = "new Text value";
- source.setText(newText);
-
- support.fireVetoableChange("label_invalid", true, false);
- assertEquals(newText, source.getLabel());
- }
-
- /*
- * register listener for label property
- */
- public void testFireVetoableChangeStringbooleanboolean_listener_Property_invalid()
- throws PropertyVetoException {
- MockSource source = new MockSource();
- VetoableChangeSupport support = new VetoableChangeSupport(source);
-
- VetoableChangeListener proxy = EventHandler.create(
- VetoableChangeListener.class, source, "label", "source.text");
- support.addVetoableChangeListener("label", proxy);
- String newText = "new Text value";
- source.setText(newText);
-
- support.fireVetoableChange("text", true, false);
- assertEquals("label.default", source.getLabel());
-
- support.fireVetoableChange("label_invalid", true, false);
- assertEquals("label.default", source.getLabel());
-
- support.fireVetoableChange("label", true, false);
- assertEquals(newText, source.getLabel());
- }
-
- /*
- * oldvalue==newValue
- */
- public void testFireVetoableChangeStringbooleanboolean_SameValue()
- throws PropertyVetoException {
- MockSource source = new MockSource();
- VetoableChangeSupport support = new VetoableChangeSupport(source);
-
- VetoableChangeListener proxy = EventHandler.create(
- VetoableChangeListener.class, source, "setText");
- support.addVetoableChangeListener(proxy);
-
- support.fireVetoableChange("label", true, true);
- assertEquals("text.default", source.getText());
- }
-
- /*
- * Class under test for void fireVetoableChange(String, int, int)
- *
- * register listener for all
- */
- public void testFireVetoableChangeStringintint()
- throws PropertyVetoException {
- MockSource source = new MockSource();
- VetoableChangeSupport support = new VetoableChangeSupport(source);
-
- VetoableChangeListener proxy = EventHandler.create(
- VetoableChangeListener.class, source, "setText");
- support.addVetoableChangeListener(proxy);
- support.fireVetoableChange("label", 1, 2);
-
- assertEquals("called", source.getText());
- }
-
- /*
- * Propertyname is null register listener for all
- */
- public void testFireVetoableChangeStringintint_property_null()
- throws PropertyVetoException {
- MockSource source = new MockSource();
- VetoableChangeSupport support = new VetoableChangeSupport(source);
-
- VetoableChangeListener proxy = EventHandler.create(
- VetoableChangeListener.class, source, "setText");
- support.addVetoableChangeListener(proxy);
- support.fireVetoableChange(null, 1, 2);
-
- assertEquals("called", source.getText());
- }
-
- /*
- * property name is invalid register listener for all
- */
- public void testFireVetoableChangeStringintint_property_Invalid()
- throws PropertyVetoException {
- MockSource source = new MockSource();
- VetoableChangeSupport support = new VetoableChangeSupport(source);
-
- VetoableChangeListener proxy = EventHandler.create(
- VetoableChangeListener.class, source, "setText");
- support.addVetoableChangeListener(proxy);
- support.fireVetoableChange("label_invalid", 1, 2);
-
- assertEquals("called", source.getText());
- }
-
- /*
- * oldvalue=newValue register listener for all
- */
- public void testFireVetoableChangeStringintint_SameValue()
- throws PropertyVetoException {
- MockSource source = new MockSource();
- VetoableChangeSupport support = new VetoableChangeSupport(source);
-
- VetoableChangeListener proxy = EventHandler.create(
- VetoableChangeListener.class, source, "setText");
- support.addVetoableChangeListener(proxy);
- support.fireVetoableChange("label", 1, 1);
-
- assertEquals("text.default", source.getText());
- }
-
- /*
- * Class under test for void fireVetoableChange(String, int, int)
- *
- * register listener for one property - "label"
- */
- public void testFireVetoableChangeStringintint_listener()
- throws PropertyVetoException {
- MockSource source = new MockSource();
- VetoableChangeSupport support = new VetoableChangeSupport(source);
-
- VetoableChangeListener proxy = EventHandler.create(
- VetoableChangeListener.class, source, "setText");
- support.addVetoableChangeListener("label", proxy);
- support.fireVetoableChange("label", 1, 2);
- assertEquals("called", source.getText());
- }
-
- /*
- * Propertyname is null register listener for one property - "label"
- */
- public void testFireVetoableChangeStringintint_listener_property_null()
- throws PropertyVetoException {
- MockSource source = new MockSource();
- VetoableChangeSupport support = new VetoableChangeSupport(source);
-
- VetoableChangeListener proxy = EventHandler.create(
- VetoableChangeListener.class, source, "setText");
- support.addVetoableChangeListener("label", proxy);
- support.fireVetoableChange(null, 1, 2);
-
- assertEquals("text.default", source.getText());
- }
-
- /*
- * property name is invalid register listener for one property - "label"
- */
- public void testFireVetoableChangeStringintint_listener_property_Invalid()
- throws PropertyVetoException {
- MockSource source = new MockSource();
- VetoableChangeSupport support = new VetoableChangeSupport(source);
-
- VetoableChangeListener proxy = EventHandler.create(
- VetoableChangeListener.class, source, "setText");
- support.addVetoableChangeListener("label", proxy);
- support.fireVetoableChange("label_invalid", 1, 2);
-
- assertEquals("text.default", source.getText());
- }
-
- /*
- * oldvalue=newValue register listener for one property - "label"
- */
- public void testFireVetoableChangeStringintint_listener_SameValue()
- throws PropertyVetoException {
- MockSource source = new MockSource();
- VetoableChangeSupport support = new VetoableChangeSupport(source);
-
- VetoableChangeListener proxy = EventHandler.create(
- VetoableChangeListener.class, source, "setText");
- support.addVetoableChangeListener("label", proxy);
- support.fireVetoableChange("label", 1, 1);
-
- assertEquals("text.default", source.getText());
- }
-
- public void testFireVetoableChangeStringintint_listener_Invalid_property()
- throws PropertyVetoException {
- MockSource source = new MockSource();
- VetoableChangeSupport support = new VetoableChangeSupport(source);
-
- VetoableChangeListener proxy = EventHandler.create(
- VetoableChangeListener.class, source, "setText");
- support.addVetoableChangeListener("label_invalid", proxy);
- support.fireVetoableChange("label", 1, 2);
-
- assertEquals("text.default", source.getText());
- }
-
- /*
- * Class under test for void fireVetoableChange(String, Object, Object)
- *
- * register listener for all
- */
- public void testFireVetoableChangeStringObjectObject()
- throws PropertyVetoException {
- MockSource source = new MockSource();
- VetoableChangeSupport support = new VetoableChangeSupport(source);
-
- VetoableChangeListener proxy = EventHandler.create(
- VetoableChangeListener.class, source, "setText");
- support.addVetoableChangeListener(proxy);
- support.fireVetoableChange("label", "Label: old", "Label: new");
- assertEquals("called", source.getText());
- }
-
- /*
- * property name is null. register listener for all
- */
- public void testFireVetoableChangeStringObjectObject_property_Null()
- throws PropertyVetoException {
- MockSource source = new MockSource();
- VetoableChangeSupport support = new VetoableChangeSupport(source);
-
- VetoableChangeListener proxy = EventHandler.create(
- VetoableChangeListener.class, source, "setText");
- support.addVetoableChangeListener(proxy);
- support.fireVetoableChange(null, "Label: old", "Label: new");
- assertEquals("called", source.getText());
- }
-
- /*
- * property name is invalid. register listener for all
- */
- public void testFireVetoableChangeStringObjectObject_property_invalid()
- throws PropertyVetoException {
- MockSource source = new MockSource();
- VetoableChangeSupport support = new VetoableChangeSupport(source);
-
- VetoableChangeListener proxy = EventHandler.create(
- VetoableChangeListener.class, source, "setText");
- support.addVetoableChangeListener(proxy);
- support.fireVetoableChange("label_invalid", "Label: old", "Label: new");
- assertEquals("called", source.getText());
- }
-
- /*
- * oldValue=NewValue. register listener for all
- */
- public void testFireVetoableChangeStringObjectObject_SameValue()
- throws PropertyVetoException {
- MockSource source = new MockSource();
- VetoableChangeSupport support = new VetoableChangeSupport(source);
-
- VetoableChangeListener proxy = EventHandler.create(
- VetoableChangeListener.class, source, "setText");
- support.addVetoableChangeListener(proxy);
- support.fireVetoableChange("label", "Label: old", "Label: old");
- assertEquals("text.default", source.getText());
- }
-
- /*
- * oldValue=NewValue=null. register listener for all
- */
- public void testFireVetoableChangeStringObjectObject_SameValue_null()
- throws PropertyVetoException {
- MockSource source = new MockSource();
- VetoableChangeSupport support = new VetoableChangeSupport(source);
-
- VetoableChangeListener proxy = EventHandler.create(
- VetoableChangeListener.class, source, "setText");
- support.addVetoableChangeListener(proxy);
- support.fireVetoableChange("label", null, null);
- assertEquals("called", source.getText());
- }
-
- /*
- * Class under test for void fireVetoableChange(String, Object, Object)
- *
- * register listener for one property - "label"
- */
- public void testFireVetoableChangeStringObjectObject_listener()
- throws PropertyVetoException {
- MockSource source = new MockSource();
- VetoableChangeSupport support = new VetoableChangeSupport(source);
-
- VetoableChangeListener proxy = EventHandler.create(
- VetoableChangeListener.class, source, "setText");
- support.addVetoableChangeListener("label", proxy);
- support.fireVetoableChange("label", "Label: old", "Label: new");
- assertEquals("called", source.getText());
- }
-
- /*
- * property name is null. register listener for one property - "label"
- */
- public void testFireVetoableChangeStringObjectObject_listener_property_Null()
- throws PropertyVetoException {
- MockSource source = new MockSource();
- VetoableChangeSupport support = new VetoableChangeSupport(source);
-
- VetoableChangeListener proxy = EventHandler.create(
- VetoableChangeListener.class, source, "setText");
- support.addVetoableChangeListener("label", proxy);
- support.fireVetoableChange(null, "Label: old", "Label: new");
- assertEquals("text.default", source.getText());
- }
-
- /*
- * property name is invalid. register listener for one property - "label"
- */
- public void testFireVetoableChangeStringObjectObject_listener_property_invalid()
- throws PropertyVetoException {
- MockSource source = new MockSource();
- VetoableChangeSupport support = new VetoableChangeSupport(source);
-
- VetoableChangeListener proxy = EventHandler.create(
- VetoableChangeListener.class, source, "setText");
- support.addVetoableChangeListener("label", proxy);
- support.fireVetoableChange("label_invalid", "Label: old", "Label: new");
- assertEquals("text.default", source.getText());
- }
-
- /*
- * oldValue=NewValue. register listener for one property - "label"
- */
- public void testFireVetoableChangeStringObjectObject_listener_SameValue()
- throws PropertyVetoException {
- MockSource source = new MockSource();
- VetoableChangeSupport support = new VetoableChangeSupport(source);
-
- VetoableChangeListener proxy = EventHandler.create(
- VetoableChangeListener.class, source, "setText");
- support.addVetoableChangeListener(proxy);
- support.fireVetoableChange("label", "Label: old", "Label: old");
- assertEquals("text.default", source.getText());
- }
-
- /*
- * oldValue=NewValue=null. register listener for one property - "label"
- */
- public void testFireVetoableChangeStringObjectObject_listener_SameValue_null()
- throws PropertyVetoException {
- MockSource source = new MockSource();
- VetoableChangeSupport support = new VetoableChangeSupport(source);
-
- VetoableChangeListener proxy = EventHandler.create(
- VetoableChangeListener.class, source, "setText");
- support.addVetoableChangeListener("label", proxy);
- support.fireVetoableChange("label", null, null);
- assertEquals("called", source.getText());
- }
-
- /*
- * register listener to an invalid property
- */
- public void testFireVetoableChangeStringObjectObject_listener_invalid()
- throws PropertyVetoException {
- MockSource source = new MockSource();
- VetoableChangeSupport support = new VetoableChangeSupport(source);
-
- VetoableChangeListener proxy = EventHandler.create(
- VetoableChangeListener.class, source, "setText");
- support.addVetoableChangeListener("label_invalid", proxy);
- support.fireVetoableChange("label", "1", "2");
- assertEquals("text.default", source.getText());
- }
-
- public void testFireVetoableChangeException_revert_event() {
- final VetoableChangeSupport support = new VetoableChangeSupport(
- new Object());
- final StringBuffer sb = new StringBuffer();
- final String A_IN = "a", B_IN = "b", A_THROW = "A", B_THROW = "B";
-
- support.addVetoableChangeListener(new VetoableChangeListener() {
- public void vetoableChange(PropertyChangeEvent e)
- throws PropertyVetoException {
- sb.append(A_IN);
- if (sb.length() == 4) {
- sb.append(A_THROW);
- throw new PropertyVetoException(A_THROW, e);
- }
- }
- });
-
- support.addVetoableChangeListener(new VetoableChangeListener() {
- public void vetoableChange(PropertyChangeEvent e)
- throws PropertyVetoException {
- sb.append(B_IN);
- if (sb.length() == 2) {
- sb.append(B_THROW);
- throw new PropertyVetoException(B_THROW, e);
- }
- }
- });
-
- try {
- support.fireVetoableChange("propName", 0, 1);
- } catch (PropertyVetoException pve) {
- assertEquals("Illegal sequence:" + sb, "abBaAb", sb.toString());
- String message = pve.getMessage();
- assertEquals("Illegal exception:" + message, B_THROW, message);
- return;
- }
- fail("Unreachable path:" + sb);
- }
-
- /*
- * Class under test for void removeVetoableChangeListener(String,
- * VetoableChangeListener)
- *
- * register listener for property
- */
- public void testRemoveVetoableChangeListenerStringVetoableChangeListener_property() {
- MockSource source = new MockSource();
- VetoableChangeSupport support = new VetoableChangeSupport(source);
-
- VetoableChangeListener proxy = EventHandler.create(
- VetoableChangeListener.class, source, "setText");
-
- String propertyName = "label";
- support.addVetoableChangeListener(propertyName, proxy);
- assertTrue(support.hasListeners(propertyName));
-
- support.removeVetoableChangeListener(propertyName, proxy);
- assertFalse(support.hasListeners(propertyName));
- assertEquals(0, support.getVetoableChangeListeners(propertyName).length);
- assertEquals(0, support.getVetoableChangeListeners().length);
- }
-
- /*
- * register listener for property, two same listeners
- */
- public void testRemoveVetoableChangeListenerStringVetoableChangeListener_property_more() {
- MockSource source = new MockSource();
- VetoableChangeSupport support = new VetoableChangeSupport(source);
-
- VetoableChangeListener proxy = EventHandler.create(
- VetoableChangeListener.class, source, "setText");
-
- String propertyName = "label";
- support.addVetoableChangeListener(propertyName, proxy);
- support.addVetoableChangeListener(propertyName, proxy);
-
- assertTrue(support.hasListeners(propertyName));
- assertEquals(2, support.getVetoableChangeListeners(propertyName).length);
-
- support.removeVetoableChangeListener(propertyName, proxy);
- assertTrue(support.hasListeners(propertyName));
- assertEquals(1, support.getVetoableChangeListeners(propertyName).length);
- assertEquals(1, support.getVetoableChangeListeners().length);
- }
-
- /*
- * register listener for property, two different listeners
- */
- public void testRemoveVetoableChangeListenerStringVetoableChangeListener_property_diff() {
- MockSource source = new MockSource();
- VetoableChangeSupport support = new VetoableChangeSupport(source);
-
- VetoableChangeListener proxy = EventHandler.create(
- VetoableChangeListener.class, source, "setText");
-
- VetoableChangeListener proxy2 = EventHandler.create(
- VetoableChangeListener.class, source, "getText");
-
- String propertyName = "label";
- support.addVetoableChangeListener(propertyName, proxy);
- support.addVetoableChangeListener(propertyName, proxy2);
-
- assertTrue(support.hasListeners(propertyName));
- assertEquals(2, support.getVetoableChangeListeners(propertyName).length);
-
- support.removeVetoableChangeListener(propertyName, proxy);
- assertTrue(support.hasListeners(propertyName));
- assertEquals(1, support.getVetoableChangeListeners(propertyName).length);
- assertEquals(1, support.getVetoableChangeListeners().length);
- assertSame(proxy2, support.getVetoableChangeListeners(propertyName)[0]);
- }
-
- /*
- * register listener for property, two different listeners
- */
- public void testRemoveVetoableChangeListenerStringVetoableChangeListener_listener_diff() {
- MockSource source = new MockSource();
- VetoableChangeSupport support = new VetoableChangeSupport(source);
-
- VetoableChangeListener proxy = EventHandler.create(
- VetoableChangeListener.class, source, "setText");
-
- VetoableChangeListener proxy2 = EventHandler.create(
- VetoableChangeListener.class, source, "getText");
-
- String propertyName = "label";
- support.addVetoableChangeListener(propertyName, proxy);
-
- assertTrue(support.hasListeners(propertyName));
- assertEquals(1, support.getVetoableChangeListeners(propertyName).length);
-
- support.removeVetoableChangeListener(propertyName, proxy2);
- assertTrue(support.hasListeners(propertyName));
- assertEquals(1, support.getVetoableChangeListeners(propertyName).length);
- assertEquals(1, support.getVetoableChangeListeners().length);
- }
-
- public void testRemoveVetoableChangeListenerStringVetoableChangeListener_listener_null() {
- MockSource source = new MockSource();
- VetoableChangeSupport support = new VetoableChangeSupport(source);
-
- VetoableChangeListener proxy = EventHandler.create(
- VetoableChangeListener.class, source, "setText");
-
- String propertyName = "label";
- support.addVetoableChangeListener(propertyName, null);
-
- assertFalse(support.hasListeners(propertyName));
- assertEquals(0, support.getVetoableChangeListeners(propertyName).length);
-
- support.removeVetoableChangeListener(propertyName, proxy);
- assertFalse(support.hasListeners(propertyName));
- assertEquals(0, support.getVetoableChangeListeners(propertyName).length);
- assertEquals(0, support.getVetoableChangeListeners().length);
- }
-
- /*
- * register listener for property.
- */
- public void testRemoveVetoableChangeListenerStringVetoableChangeListener_all() {
- MockSource source = new MockSource();
- VetoableChangeSupport support = new VetoableChangeSupport(source);
-
- VetoableChangeListener proxy = EventHandler.create(
- VetoableChangeListener.class, source, "setText");
-
- String propertyName = "label";
- support.addVetoableChangeListener(proxy);
- assertTrue(support.hasListeners(propertyName));
-
- support.removeVetoableChangeListener(propertyName, proxy);
- assertTrue(support.hasListeners(propertyName));
- assertEquals(0, support.getVetoableChangeListeners(propertyName).length);
- assertEquals(1, support.getVetoableChangeListeners().length);
- }
-
- /*
- * remove listener from null property
- */
- public void testRemoveVetoableChangeListenerStringVetoableChangeListener_propertyName_Null() {
- MockSource source = new MockSource();
- VetoableChangeSupport support = new VetoableChangeSupport(source);
-
- VetoableChangeListener proxy = EventHandler.create(
- VetoableChangeListener.class, source, "setText");
-
- String propertyName = "label";
- support.addVetoableChangeListener(propertyName, proxy);
- assertTrue(support.hasListeners(propertyName));
- support.removeVetoableChangeListener(null, proxy);
- }
-
- /*
- * propertyname is invalid
- */
- public void testRemoveVetoableChangeListenerStringVetoableChangeListener_propertyName_Invalid() {
- MockSource source = new MockSource();
- VetoableChangeSupport support = new VetoableChangeSupport(source);
-
- VetoableChangeListener proxy = EventHandler.create(
- VetoableChangeListener.class, source, "setText");
-
- String propertyName = "label";
- support.addVetoableChangeListener(propertyName, proxy);
- assertTrue(support.hasListeners(propertyName));
-
- support.removeVetoableChangeListener(propertyName + "_invalid", proxy);
- assertTrue(support.hasListeners(propertyName));
- assertEquals(1, support.getVetoableChangeListeners(propertyName).length);
- assertEquals(1, support.getVetoableChangeListeners().length);
- }
-
- /*
- * no listener attached to the property
- */
- public void testRemoveVetoableChangeListenerStringVetoableChangeListener_propertyName_NoListener() {
- MockSource source = new MockSource();
- VetoableChangeSupport support = new VetoableChangeSupport(source);
-
- VetoableChangeListener proxy = EventHandler.create(
- VetoableChangeListener.class, source, "setText");
-
- String propertyName = "label";
- assertFalse(support.hasListeners(propertyName));
-
- support.removeVetoableChangeListener(propertyName, proxy);
- assertFalse(support.hasListeners(propertyName));
- assertEquals(0, support.getVetoableChangeListeners(propertyName).length);
- assertEquals(0, support.getVetoableChangeListeners().length);
- }
-
- /*
- * listener null
- */
- public void testRemoveVetoableChangeListenerStringVetoableChangeListener_listener_null_null() {
- MockSource source = new MockSource();
- VetoableChangeSupport support = new VetoableChangeSupport(source);
-
- String propertyName = "label";
- support.addVetoableChangeListener(propertyName, null);
- assertFalse(support.hasListeners(propertyName));
-
- support.removeVetoableChangeListener(propertyName, null);
- assertFalse(support.hasListeners(propertyName));
- assertEquals(0, support.getVetoableChangeListeners(propertyName).length);
- assertEquals(0, support.getVetoableChangeListeners().length);
- }
-
- /*
- * Class under test for void
- * removeVetoableChangeListener(VetoableChangeListener)
- *
- * register listener for all
- */
- public void testRemoveVetoableChangeListenerVetoableChangeListener_all() {
- MockSource source = new MockSource();
- VetoableChangeSupport support = new VetoableChangeSupport(source);
-
- VetoableChangeListener proxy = EventHandler.create(
- VetoableChangeListener.class, source, "setText");
-
- String propertyName = "label";
- support.addVetoableChangeListener(proxy);
- assertTrue(support.hasListeners(propertyName));
-
- support.removeVetoableChangeListener(proxy);
- assertFalse(support.hasListeners(propertyName));
- assertEquals(0, support.getVetoableChangeListeners(propertyName).length);
- assertEquals(0, support.getVetoableChangeListeners().length);
- }
-
- /*
- * two same listeners
- */
- public void testRemoveVetoableChangeListenerVetoableChangeListener_all_more() {
- MockSource source = new MockSource();
- VetoableChangeSupport support = new VetoableChangeSupport(source);
-
- VetoableChangeListener proxy = EventHandler.create(
- VetoableChangeListener.class, source, "setText");
-
- String propertyName = "label";
- support.addVetoableChangeListener(proxy);
- support.addVetoableChangeListener(proxy);
-
- assertTrue(support.hasListeners(propertyName));
- assertEquals(2, support.getVetoableChangeListeners().length);
-
- support.removeVetoableChangeListener(proxy);
-
- assertTrue(support.hasListeners(propertyName));
- assertEquals(0, support.getVetoableChangeListeners(propertyName).length);
- assertEquals(1, support.getVetoableChangeListeners().length);
- }
-
- /*
- * two different listeners
- */
- public void testRemoveVetoableChangeListenerVetoableChangeListener_all_more_diff() {
- MockSource source = new MockSource();
- VetoableChangeSupport support = new VetoableChangeSupport(source);
-
- VetoableChangeListener proxy = EventHandler.create(
- VetoableChangeListener.class, source, "setText");
- VetoableChangeListener proxy2 = EventHandler.create(
- VetoableChangeListener.class, source, "getText");
-
- String propertyName = "label";
- support.addVetoableChangeListener(proxy);
- support.addVetoableChangeListener(proxy2);
-
- assertTrue(support.hasListeners(propertyName));
- assertEquals(2, support.getVetoableChangeListeners().length);
-
- support.removeVetoableChangeListener(proxy);
-
- assertTrue(support.hasListeners(propertyName));
- assertEquals(0, support.getVetoableChangeListeners(propertyName).length);
- assertEquals(1, support.getVetoableChangeListeners().length);
- assertEquals(proxy2, support.getVetoableChangeListeners()[0]);
- }
-
- /*
- * listener null
- */
- public void testRemoveVetoableChangeListenerVetoableChangeListener_all_null() {
- MockSource source = new MockSource();
- VetoableChangeSupport support = new VetoableChangeSupport(source);
-
- VetoableChangeListener proxy = EventHandler.create(
- VetoableChangeListener.class, source, "setText");
-
- String propertyName = "label";
- support.addVetoableChangeListener(null);
-
- assertFalse(support.hasListeners(propertyName));
- assertEquals(0, support.getVetoableChangeListeners().length);
-
- support.removeVetoableChangeListener(proxy);
-
- assertFalse(support.hasListeners(propertyName));
- assertEquals(0, support.getVetoableChangeListeners(propertyName).length);
- assertEquals(0, support.getVetoableChangeListeners().length);
- }
-
- /*
- * register for one property
- */
- public void testRemoveVetoableChangeListenerVetoableChangeListener_property() {
- MockSource source = new MockSource();
- VetoableChangeSupport support = new VetoableChangeSupport(source);
-
- VetoableChangeListener proxy = EventHandler.create(
- VetoableChangeListener.class, source, "setText");
-
- String propertyName = "label";
- support.addVetoableChangeListener("label", proxy);
-
- assertTrue(support.hasListeners(propertyName));
- assertEquals(1, support.getVetoableChangeListeners().length);
-
- support.removeVetoableChangeListener(proxy);
-
- assertTrue(support.hasListeners(propertyName));
- assertEquals(1, support.getVetoableChangeListeners(propertyName).length);
- assertEquals(1, support.getVetoableChangeListeners().length);
- }
-
- /*
- * listener null
- */
- public void testRemoveVetoableChangeListenerVetoableChangeListener_null() {
- MockSource source = new MockSource();
- VetoableChangeSupport support = new VetoableChangeSupport(source);
-
- VetoableChangeListener proxy = EventHandler.create(
- VetoableChangeListener.class, source, "setText");
-
- String propertyName = "label";
- support.addVetoableChangeListener(proxy);
-
- assertTrue(support.hasListeners(propertyName));
- assertEquals(1, support.getVetoableChangeListeners().length);
-
- support.removeVetoableChangeListener(null);
-
- assertTrue(support.hasListeners(propertyName));
- assertEquals(0, support.getVetoableChangeListeners(propertyName).length);
- assertEquals(1, support.getVetoableChangeListeners().length);
- }
-
- /*
- * register null listener, remove null listener.
- */
- public void testRemoveVetoableChangeListenerVetoableChangeListener_null_null() {
- MockSource source = new MockSource();
- VetoableChangeSupport support = new VetoableChangeSupport(source);
-
- EventHandler.create(VetoableChangeListener.class, source, "setText");
-
- String propertyName = "label";
- support.addVetoableChangeListener(null);
-
- assertFalse(support.hasListeners(propertyName));
- assertEquals(0, support.getVetoableChangeListeners().length);
-
- support.removeVetoableChangeListener(null);
-
- assertFalse(support.hasListeners(propertyName));
- assertEquals(0, support.getVetoableChangeListeners(propertyName).length);
- assertEquals(0, support.getVetoableChangeListeners().length);
- }
-
- /*
- * Regression test for HARMONY-321
- */
- public void testFireVetoableChange_regression() {
- VetoableChangeSupport vcs = new VetoableChangeSupport(this);
- MockVetoListener2 vlistener = new MockVetoListener2();
-
- vcs.addVetoableChangeListener(vlistener);
- try {
- vcs.fireVetoableChange(vlistener.vetoedPropName, 0, 1);
- fail("PropertyVetoException expected");
- } catch (PropertyVetoException ok) {
- }
-
- assertEquals(Integer.valueOf(1), vlistener.event.getOldValue());
- assertEquals(Integer.valueOf(0), vlistener.event.getNewValue());
- }
-
- /*
- * no this listener
- */
- public void testRemoveVetoableChangeListenerVetoableChangeListener_invalid() {
- MockSource source = new MockSource();
- VetoableChangeSupport support = new VetoableChangeSupport(source);
-
- VetoableChangeListener proxy = EventHandler.create(
- VetoableChangeListener.class, source, "setText");
-
- String propertyName = "label";
- assertFalse(support.hasListeners(propertyName));
- assertEquals(0, support.getVetoableChangeListeners().length);
-
- support.removeVetoableChangeListener(proxy);
-
- assertFalse(support.hasListeners(propertyName));
- assertEquals(0, support.getVetoableChangeListeners(propertyName).length);
- assertEquals(0, support.getVetoableChangeListeners().length);
- }
-
- public void testSerialization() throws IOException, ClassNotFoundException {
- MockSource source = new MockSource();
- VetoableChangeSupport support = new VetoableChangeSupport(source);
-
- String propertyName1 = "text";
- SerializedVCListener serialized = new SerializedVCListener(
- propertyName1);
- support.addVetoableChangeListener(propertyName1, serialized);
-
- String propertyName2 = "top";
- NonSerializedVCListener nonSerialized = new NonSerializedVCListener(
- propertyName2);
- support.addVetoableChangeListener(propertyName2, nonSerialized);
-
- assertTrue(support.hasListeners(propertyName1));
- assertTrue(support.hasListeners(propertyName2));
- assertEquals(2, support.getVetoableChangeListeners().length);
- assertEquals(1,
- support.getVetoableChangeListeners(propertyName1).length);
- assertEquals(1,
- support.getVetoableChangeListeners(propertyName2).length);
-
- VetoableChangeSupport deserializedSupport = (VetoableChangeSupport) SerializationTester
- .getDeserilizedObject(support);
-
- assertTrue(deserializedSupport.hasListeners(propertyName1));
- assertFalse(deserializedSupport.hasListeners(propertyName2));
- assertEquals(1, deserializedSupport.getVetoableChangeListeners().length);
- assertEquals(1, deserializedSupport
- .getVetoableChangeListeners(propertyName1).length);
- assertEquals(0, deserializedSupport
- .getVetoableChangeListeners(propertyName2).length);
-
- assertEquals(
- support.getVetoableChangeListeners(propertyName1)[0],
- deserializedSupport.getVetoableChangeListeners(propertyName1)[0]);
-
- }
-
- public void testSerialization_Compatibility() throws Exception {
- MockSource source = new MockSource();
- VetoableChangeSupport support = new VetoableChangeSupport(source);
-
- final String propertyName1 = "text";
- SerializedVCListener serialized = new SerializedVCListener(
- propertyName1);
- support.addVetoableChangeListener(propertyName1, serialized);
-
- final String propertyName2 = "top";
- NonSerializedVCListener nonSerialized = new NonSerializedVCListener(
- propertyName2);
- support.addVetoableChangeListener(propertyName2, nonSerialized);
-
- assertTrue(support.hasListeners(propertyName1));
- assertTrue(support.hasListeners(propertyName2));
- assertEquals(2, support.getVetoableChangeListeners().length);
- assertEquals(1,
- support.getVetoableChangeListeners(propertyName1).length);
- assertEquals(1,
- support.getVetoableChangeListeners(propertyName2).length);
-
- SerializationTest.verifyGolden(this, support, new SerializableAssert(){
- public void assertDeserialized(Serializable orig, Serializable ser) {
- VetoableChangeSupport support = (VetoableChangeSupport)orig;
- VetoableChangeSupport deserializedSupport = (VetoableChangeSupport)ser;
-
- assertTrue(deserializedSupport.hasListeners(propertyName1));
- assertFalse(deserializedSupport.hasListeners(propertyName2));
- assertEquals(1, deserializedSupport.getVetoableChangeListeners().length);
- assertEquals(1, deserializedSupport
- .getVetoableChangeListeners(propertyName1).length);
- assertEquals(0, deserializedSupport
- .getVetoableChangeListeners(propertyName2).length);
-
- assertEquals(
- support.getVetoableChangeListeners(propertyName1)[0],
- deserializedSupport.getVetoableChangeListeners(propertyName1)[0]);
- }
- });
- }
-
- public static class MockSource implements Serializable {
-
- private static final long serialVersionUID = 2592367737991345105L;
-
- private String name;
-
- private String text;
-
- private String label;
-
- private int top;
-
- private boolean visible;
-
- public MockSource() {
- this.name = getClass().getName();
- this.text = "text.default";
- this.label = "label.default";
- }
-
- /**
- * @return Returns the name.
- */
- public String getName() {
- return name;
- }
-
- /**
- * @param name
- * The name to set.
- */
- public void setName(String name) {
- this.name = name;
- }
-
- /**
- * @return Returns the text.
- */
- public String getText() {
- return text;
- }
-
- /**
- * @param text
- * The text to set.
- */
- public void setText(String text) {
- this.text = text;
- }
-
- public void setText() {
- this.text = "called";
- }
-
- /**
- * @return Returns the top.
- */
- public int getTop() {
- return top;
- }
-
- /**
- * @param top
- * The top to set.
- */
- public void setTop(int top) {
- this.top = top;
- }
-
- public void increaseTop() {
- this.top++;
- }
-
- /**
- * @return Returns the visible.
- */
- public boolean isVisible() {
- return visible;
- }
-
- /**
- * @param visible
- * The visible to set.
- */
- public void setVisible(boolean visible) {
- this.visible = visible;
- }
-
- /**
- * @return Returns the label.
- */
- public String getLabel() {
- return label;
- }
-
- /**
- * @param label
- * The label to set.
- */
- public void setLabel(String label) {
- this.label = label;
- }
- }
-
- public static class MockVetoListener implements VetoableChangeListener {
-
- ArrayList<Object> oldValues = new ArrayList<Object>();
-
- ArrayList<Object> newValues = new ArrayList<Object>();
-
- boolean veto;
-
- String prefix;
-
- public MockVetoListener(boolean veto, String prefix) {
- this.veto = veto;
- this.prefix = prefix;
- }
-
- public void vetoableChange(PropertyChangeEvent event)
- throws PropertyVetoException {
- oldValues.add(event.getOldValue());
- newValues.add(event.getNewValue());
-
- if (false) {
- System.out.println(prefix + " old: " + event.getOldValue()
- + " new: " + event.getNewValue());
- }
- if (veto) {
- throw new PropertyVetoException("Veto Change", event);
- }
- }
-
- public ArrayList<Object> getOldValues() {
- return this.oldValues;
- }
-
- public ArrayList<Object> getNewValues() {
- return this.newValues;
- }
-
- }
-
- public static class MockVetoListener2 implements VetoableChangeListener {
-
- public PropertyChangeEvent event;
-
- public final String vetoedPropName = "prop";
-
- public void vetoableChange(PropertyChangeEvent e)
- throws PropertyVetoException {
-
- event = e;
- String propName = e.getPropertyName();
-
- if (propName.equals(vetoedPropName)
- && e.getNewValue().equals(new Integer(1))) {
- throw new PropertyVetoException(
- propName + " change is vetoed!", e);
- }
- }
-
- }
-
- /**
- * @tests java.beans.VetoableChangeSupport#VetoableChangeSupport(
- * java.lang.Object)
- */
- public void testVetoableChangeSupport_null() {
- // Regression for HARMONY-228
- try {
- new VetoableChangeSupport(null);
- fail("Should throw NullPointerException.");
- } catch (NullPointerException e) {
- }
- }
-
- /**
- * @tests java.beans.VetoableChangeSupport#addVetoableChangeListener(java.lang.String,
- * java.beans.VetoableChangeListener)
- */
- public void test_addPropertyChangeListenerNullNull() throws Exception {
- // Regression for HARMONY-441
- new VetoableChangeSupport("bean1")
- .addVetoableChangeListener(null, null);
- }
-
- public void test_readObject() throws Exception {
- // Regression for HARMONY-421
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
-
- ObjectOutputStream oos = new ObjectOutputStream(baos);
- oos.writeObject(new BeanContextChildSupport());
- oos.flush();
-
- ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(
- baos.toByteArray()));
- ois.readObject();
-
- ois.close();
- oos.close();
- }
-
- /**
- * The test checks the method add() with no property specified
- */
- public void testAddVetoableChangeListener() {
- VetoableChangeSupport vcs = new VetoableChangeSupport("bean1");
- VetoableChangeListener vcl = new VetoableChangeListener() {
-
- public void vetoableChange(PropertyChangeEvent pce) {
- }
- };
- vcs.addVetoableChangeListener(vcl);
- VetoableChangeListener[] vcls = vcs.getVetoableChangeListeners();
-
- assertNotNull("Returned listeners is null.", vcls);
- assertEquals(1, vcls.length);
- assertEquals(vcl, vcls[0]);
- }
-
- /**
- * The test checks the method add() for property specified
- */
- public void testAddVetoableChangeListenerByPropertyName() {
- VetoableChangeSupport vcs = new VetoableChangeSupport("bean1");
- VetoableChangeListener vcl = new VetoableChangeListener() {
-
- public void vetoableChange(PropertyChangeEvent pce) {
- }
- };
- vcs.addVetoableChangeListener("property1", vcl);
- VetoableChangeListener[] vcls = vcs
- .getVetoableChangeListeners("property1");
-
- assertNotNull("Returned listeners is null.", vcls);
- assertEquals(1, vcls.length);
- assertEquals(vcl, vcls[0]);
- }
-
- /**
- * The test checks the method add() for VetoableChangeListenerProxy
- */
- public void testAddVetoableChangeListenerProxy() {
- VetoableChangeSupport vcs = new VetoableChangeSupport("bean1");
- VetoableChangeListener vcl = new VetoableChangeListener() {
-
- public void vetoableChange(PropertyChangeEvent pce) {
- }
- };
- vcs.addVetoableChangeListener("property1", vcl);
- VetoableChangeListener[] vcls = vcs.getVetoableChangeListeners();
-
- assertNotNull("Returned listeners is null.", vcls);
- assertEquals(1, vcls.length);
-
- assertTrue("Listener is not of VetoableChangeListenerProxy type",
- vcls[0] instanceof VetoableChangeListenerProxy);
- assertEquals(vcl, ((VetoableChangeListenerProxy) vcls[0]).getListener());
- assertEquals("property1", ((VetoableChangeListenerProxy) vcls[0])
- .getPropertyName());
- }
-
-
- public void testSerializationForm(){
- ObjectStreamClass objectStreamClass = ObjectStreamClass.lookup(VetoableChangeSupport.class);
- assertNotNull(objectStreamClass.getField("source"));
- assertNotNull(objectStreamClass.getField("children"));
- assertNotNull(objectStreamClass.getField("vetoableChangeSupportSerializedDataVersion"));
- }
-}
diff --git a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/XMLDecoderTest.java b/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/XMLDecoderTest.java
deleted file mode 100644
index d001ba6..0000000
--- a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/XMLDecoderTest.java
+++ /dev/null
@@ -1,688 +0,0 @@
-/*
- * 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.java.beans;
-
-import java.beans.ExceptionListener;
-import java.beans.Introspector;
-import java.beans.XMLDecoder;
-import java.beans.XMLEncoder;
-import java.io.BufferedInputStream;
-import java.io.BufferedReader;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.lang.reflect.Array;
-import java.util.HashMap;
-import java.util.Vector;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.apache.harmony.beans.tests.java.beans.EncoderTest.SampleBean;
-import org.apache.harmony.beans.tests.java.beans.XMLEncoderTest.DependencyBean;
-import org.apache.harmony.beans.tests.support.MockOwnerClass;
-import org.apache.harmony.beans.tests.support.mock.MockBean4Codec;
-import org.apache.harmony.beans.tests.support.mock.MockBean4Owner_Owner;
-import org.apache.harmony.beans.tests.support.mock.MockBean4Owner_Target;
-import org.apache.harmony.beans.tests.support.mock.MockBean4StaticField;
-import org.apache.harmony.beans.tests.support.mock.MockExceptionListener;
-
-/**
- * Tests XMLDecoder
- */
-public class XMLDecoderTest extends TestCase {
-
- private InputStream getCodedXML(Class clazz, String xmlFile)
- throws Exception {
- InputStream refIn;
-
- String version = System.getProperty("java.version");
-
- refIn = XMLEncoderTest.class.getResourceAsStream(xmlFile);
- if (refIn == null) {
- throw new Error("resource " + xmlFile + " not exist in "
- + XMLEncoderTest.class.getPackage());
- }
- BufferedReader br = new BufferedReader(new InputStreamReader(refIn,
- "UTF-8"));
- StringBuilder sb = new StringBuilder();
- String line = null;
- while ((line = br.readLine()) != null) {
- sb.append(line + "\n");
- }
- refIn.close();
- String refString = sb.toString();
- refString = refString.replace("${version}", version);
- if (clazz != null) {
- refString = refString.replace("${classname}", clazz.getName());
- }
- return new ByteArrayInputStream(refString.getBytes("UTF-8"));
- }
-
- static byte xml123bytes[] = null;
-
- static {
- ByteArrayOutputStream byteout = new ByteArrayOutputStream();
- XMLEncoder enc = new XMLEncoder(byteout);
- enc.writeObject(Integer.valueOf("1"));
- enc.writeObject(Integer.valueOf("2"));
- enc.writeObject(Integer.valueOf("3"));
- enc.close();
- xml123bytes = byteout.toByteArray();
- }
-
- static class MockClassLoader extends ClassLoader {
- @Override
- public Class<?> loadClass(String name) throws ClassNotFoundException {
- throw new ClassNotFoundException();
- }
-
- @Override
- protected Class<?> findClass(String name) throws ClassNotFoundException {
- throw new ClassNotFoundException();
- }
-
- }
-
- /*
- * test XMLDecoder constructor with null inputStream argument
- */
- public void test_Constructor_NullInputStream_scenario1() {
- XMLDecoder xmlDecoder = new XMLDecoder(null);
- assertNull(xmlDecoder.readObject());
- assertNull(xmlDecoder.getOwner());
- assertNotNull(xmlDecoder.getExceptionListener());
- xmlDecoder.close();
- }
-
- /*
- * test XMLDecoder constructor with null inputStream argument
- */
- public void test_Constructor_NullInputStream_scenario2() {
- XMLDecoder xmlDecoder = new XMLDecoder(null, null);
- assertNull(xmlDecoder.readObject());
- assertNull(xmlDecoder.getOwner());
- assertNotNull(xmlDecoder.getExceptionListener());
- xmlDecoder.close();
- }
-
- /*
- * test XMLDecoder constructor with null inputStream argument
- */
- public void test_Constructor_NullInputStream_scenario3() {
- XMLDecoder xmlDecoder = new XMLDecoder(null, null, null);
- assertNull(xmlDecoder.readObject());
- assertNull(xmlDecoder.getOwner());
- assertNotNull(xmlDecoder.getExceptionListener());
- xmlDecoder.close();
- }
-
- /*
- * test XMLDecoder constructor with null inputStream argument
- */
- public void test_Constructor_NullInputStream_scenario4() {
- XMLDecoder xmlDecoder = new XMLDecoder(null, null, null, null);
- assertNull(xmlDecoder.readObject());
- assertNull(xmlDecoder.getOwner());
- assertNotNull(xmlDecoder.getExceptionListener());
- xmlDecoder.close();
- }
-
- /*
- * test XMLDecoder constructor
- */
- public void test_Constructor_Normal() throws Exception {
- XMLDecoder xmlDecoder;
- xmlDecoder = new XMLDecoder(new ByteArrayInputStream(xml123bytes));
- assertEquals(null, xmlDecoder.getOwner());
-
- final Vector<Exception> exceptions = new Vector<Exception>();
- ExceptionListener el = new ExceptionListener() {
- public void exceptionThrown(Exception e) {
- exceptions.addElement(e);
- }
- };
-
- xmlDecoder = new XMLDecoder(new ByteArrayInputStream(xml123bytes),
- this, el);
- assertEquals(el, xmlDecoder.getExceptionListener());
- assertEquals(this, xmlDecoder.getOwner());
- }
-
- /* RI fails on this testcase */
- /*
- public void testConstructor_ClassLoader() {
- XMLDecoder dec;
- final Vector<Exception> exceptions = new Vector<Exception>();
-
- ExceptionListener el = new ExceptionListener() {
- public void exceptionThrown(Exception e) {
- exceptions.addElement(e);
- }
- };
-
- dec = new XMLDecoder(new ByteArrayInputStream(xml123bytes), this, el,
- Thread.currentThread().getContextClassLoader());
- assertEquals(Integer.valueOf("1"), dec.readObject());
- assertEquals(0, exceptions.size());
- dec.close();
-
- dec = new XMLDecoder(new ByteArrayInputStream(xml123bytes), this, el,
- new MockClassLoader());
- try {
- dec.readObject();
- assertTrue(exceptions.size() > 0);
- } catch (ArrayIndexOutOfBoundsException e) {
- // also valid
- }
-
- dec.close();
- }
- */
-
- public void testClose() {
- XMLDecoder dec = new XMLDecoder(new ByteArrayInputStream(xml123bytes));
- assertEquals(Integer.valueOf("1"), dec.readObject());
-
- dec.close();
-
- assertEquals(Integer.valueOf("2"), dec.readObject());
- assertEquals(Integer.valueOf("3"), dec.readObject());
- }
-
- public void testGetExceptionListener() {
- XMLDecoder dec = new XMLDecoder(new ByteArrayInputStream(xml123bytes));
- assertNotNull(dec.getExceptionListener());
- }
-
- public void testGetOwner() {
- XMLDecoder dec = new XMLDecoder(new ByteArrayInputStream(xml123bytes));
- assertNull(dec.getOwner());
- }
-
- public void testReadObject_ArrayOutOfBounds() {
- XMLDecoder dec = new XMLDecoder(new ByteArrayInputStream(xml123bytes));
- assertEquals(Integer.valueOf("1"), dec.readObject());
- assertEquals(Integer.valueOf("2"), dec.readObject());
- assertEquals(Integer.valueOf("3"), dec.readObject());
-
- try {
- dec.readObject();
- fail();
- } catch (ArrayIndexOutOfBoundsException e) {
- // expected
- }
- }
-
- public void testReadObject_Null() {
- XMLDecoder dec = new XMLDecoder(this.getClass().getResourceAsStream(
- "/xml/null.xml"));
- Object obj = dec.readObject();
- assertNull(obj);
- }
-
- public void testReadObject_Integer() {
- XMLDecoder dec = new XMLDecoder(this.getClass().getResourceAsStream(
- "/xml/int.xml"));
- Object obj = dec.readObject();
- assertEquals(Integer.valueOf("3"), obj);
- }
-
- public void testReadObject_StringCodec() {
- XMLDecoder dec = new XMLDecoder(this.getClass().getResourceAsStream(
- "/xml/SampleBean_StringCodec.xml"));
- SampleBean obj = (SampleBean) dec.readObject();
- assertEquals("<Li Yang> & \"liyang'", obj.getMyid());
- assertEquals("a child", obj.getRef().getMyid());
- }
-
- public void testReadObject_IntArray() {
- XMLDecoder dec = new XMLDecoder(this.getClass().getResourceAsStream(
- "/xml/IntArray.xml"));
- int ints[] = (int[]) dec.readObject();
- assertEquals(1, ints[0]);
- assertEquals(2, ints[1]);
- assertEquals(3, ints[2]);
- }
-
- public void testReadObject_Array_WithoutLength() {
- // Read array of primitive types without length attribute
- XMLDecoder dec = new XMLDecoder(this.getClass().getResourceAsStream(
- "/xml/Array_Primitive.xml"));
- Object[] arrays = (Object[]) dec.readObject();
-
- boolean[] booleanArray = (boolean[]) arrays[0];
- assertTrue(booleanArray[0]);
- assertFalse(booleanArray[1]);
-
- short[] shortArray = (short[]) arrays[1];
- assertEquals(1, shortArray[0]);
- assertEquals(1, shortArray[1]);
-
- byte[] byteArray = (byte[]) arrays[2];
- assertEquals(2, byteArray[0]);
- assertEquals(2, byteArray[1]);
-
- char[] charArray = (char[]) arrays[3];
- assertEquals('c', charArray[0]);
- assertEquals('c', charArray[1]);
-
- int[] intArray = (int[]) arrays[4];
- assertEquals(4, intArray[0]);
- assertEquals(4, intArray[1]);
- assertEquals(4, intArray[2]);
- assertEquals(4, intArray[3]);
-
- long[] longArray = (long[]) arrays[5];
- assertEquals(5l, longArray[0]);
- assertEquals(5l, longArray[1]);
- assertEquals(5l, longArray[2]);
- assertEquals(5l, longArray[3]);
- assertEquals(5l, longArray[4]);
-
- float[] floatArray = (float[]) arrays[6];
- assertEquals(6f, floatArray[0]);
- assertEquals(6f, floatArray[1]);
-
- double[] doubleArray = (double[]) arrays[7];
- assertEquals(7d, doubleArray[0]);
- assertEquals(7d, doubleArray[1]);
-
- // Read array of Object types without length attribute
- dec = new XMLDecoder(this.getClass().getResourceAsStream(
- "/xml/Array_Object.xml"));
- Object[] array = (Object[]) dec.readObject();
-
- assertTrue((Boolean) array[0]);
- assertEquals(new Short((short) 1), (Short) array[1]);
- assertEquals(new Byte((byte) 2), (Byte) array[2]);
- assertEquals(new Character('c'), (Character) array[3]);
- assertEquals(new Integer(4), (Integer) array[4]);
- assertEquals(new Long(5), (Long) array[5]);
- assertEquals(new Float(6), (Float) array[6]);
- assertEquals(new Double(7), (Double) array[7]);
- assertEquals("string", (String) array[8]);
-
- // Read wrapper element in array of primitive types
- dec = new XMLDecoder(this.getClass().getResourceAsStream(
- "/xml/Array_Wrapper.xml"));
- int[] integers = (int[]) dec.readObject();
- assertEquals(11, integers[0]);
- assertEquals(22, integers[1]);
- }
-
- public void testReadObject_Array_Special() {
- // Read array of Object types in special case without length attribute
- XMLDecoder dec = new XMLDecoder(this.getClass().getResourceAsStream(
- "/xml/Array_Null.xml"));
- Object[] array = (Object[]) dec.readObject();
- assertNull(array[0]);
- assertNull(array[1]);
- assertEquals("", (String) array[2]);
-
- // Read array with wrong type, it should return null,
- // and throw a java.lang.IllegalArgumentException
- dec = new XMLDecoder(this.getClass().getResourceAsStream(
- "/xml/Array_Illegal.xml"));
- array = (Object[]) dec.readObject();
- assertNull(array);
- }
-
- public void testReadObject_PropertyDependency() {
- XMLDecoder dec = new XMLDecoder(this.getClass().getResourceAsStream(
- "/xml/DependencyBean.xml"));
- DependencyBean b = (DependencyBean) dec.readObject();
- assertEquals(888, b.getInts()[0]);
- assertSame(b.getInts(), b.getRef());
- }
-
- public void testReadObject_NoChange() throws Exception {
- XMLDecoder dec = new XMLDecoder(getCodedXML(MockBean4Codec.class,
- "/xml/MockBean4Codec_NoChange.xml"));
- dec.readObject();
- }
-
- public void testReadObject_BornFriendChange() throws Exception {
- XMLDecoder dec = new XMLDecoder(getCodedXML(MockBean4Codec.class,
- "/xml/MockBean4Codec_BornFriendChange.xml"));
- MockBean4Codec b = (MockBean4Codec) dec.readObject();
- assertEquals(888, b.getBornFriend().getZarr()[0]);
- assertEquals(b.getBornFriend(), b.getNill());
- }
-
- public void testReadObject_ManyChanges() throws Exception {
- XMLDecoder dec = new XMLDecoder(getCodedXML(MockBean4Codec.class,
- "/xml/MockBean4Codec_ManyChanges.xml"));
- MockBean4Codec b = (MockBean4Codec) dec.readObject();
- assertEquals(127, b.getB());
- assertSame(b, b.getBackRef());
- assertEquals(new Byte((byte) 127), b.getBobj());
- assertFalse(b.isBool());
- assertEquals(Boolean.TRUE, b.getBoolobj());
- assertEquals(Exception.class, b.getBornFriend().getClazz());
- assertEquals(888, b.getBornFriend().getZarr()[0]);
- assertEquals('Z', b.getC());
- assertEquals(String.class, b.getClazz());
- assertEquals(new Character('z'), b.getCobj());
- assertEquals(123.456, b.getD(), 0);
- assertEquals(new Double(123.456), b.getDobj());
- assertEquals(12.34F, b.getF(), 0);
- assertEquals(new Float(12.34F), b.getFobj());
- assertEquals(MockBean4Codec.class, b.getFriend().getClazz());
- assertEquals(999, b.getI());
- assertEquals(new Integer(999), b.getIobj());
- assertEquals(8888888, b.getL());
- assertEquals(new Long(8888888), b.getLobj());
- assertEquals("Li Yang", b.getName());
- assertNull(b.getNill());
- assertEquals(55, b.getS());
- assertEquals(new Short((short) 55), b.getSobj());
- assertEquals(3, b.getZarr().length);
- assertEquals(3, b.getZarr()[0]);
- assertEquals(2, b.getZarr()[1]);
- assertEquals(1, b.getZarr()[2]);
- assertEquals(1, b.getZarrarr().length);
- assertEquals(3, b.getZarrarr()[0].length);
- assertEquals("6", b.getZarrarr()[0][0]);
- assertEquals("6", b.getZarrarr()[0][1]);
- assertEquals("6", b.getZarrarr()[0][2]);
- }
-
- public void testReadObject_StaticField() throws Exception {
- XMLDecoder dec1 = new XMLDecoder(getCodedXML(
- MockBean4StaticField.class,
- "/xml/MockBean4StaticField_Original.xml"));
- MockBean4StaticField o1 = (MockBean4StaticField) dec1.readObject();
- assertNull(o1);
-
- XMLDecoder dec2 = new XMLDecoder(getCodedXML(
- MockBean4StaticField.class, "/xml/MockBean4StaticField.xml"));
- MockBean4StaticField o2 = (MockBean4StaticField) dec2.readObject();
- assertNotNull(o2);
- }
-
- public void testReadObject_Owner() throws Exception {
- MockBean4Owner_Owner o1 = new MockBean4Owner_Owner();
- XMLDecoder dec1 = new XMLDecoder(
- getCodedXML(MockBean4Owner_Target.class,
- "/xml/MockBean4Owner_SetOwner.xml"), o1);
- MockBean4Owner_Target t1 = (MockBean4Owner_Target) dec1.readObject();
-
- assertEquals(1, o1.getV());
- assertEquals(o1, t1.getV());
- }
-
- public void testReadObject_Owner_Specific() {
- String expectedValue = "expected value";
- HashMap map = new HashMap();
- map.put("key", expectedValue);
-
- XMLDecoder decoder = new XMLDecoder(this.getClass()
- .getResourceAsStream("/xml/MockOwner.xml"), map);
- String actualValue = (String) decoder.readObject();
- assertEquals(expectedValue, actualValue);
-
- MockOwnerClass mock = new MockOwnerClass();
- expectedValue = "I_Ljava.lang.String";
- decoder = new XMLDecoder(this.getClass().getResourceAsStream(
- "/xml/MockOwner_Specific.xml"), mock);
- actualValue = (String) decoder.readObject();
- assertEquals(expectedValue, actualValue);
-
- decoder = new XMLDecoder(this.getClass().getResourceAsStream(
- "/xml/MockOwner_Ambiguous.xml"), mock);
- actualValue = (String) decoder.readObject();
- assertNull(actualValue);
-
- decoder = new XMLDecoder(this.getClass().getResourceAsStream(
- "/xml/MockOwner_Null.xml"), mock);
- actualValue = (String) decoder.readObject();
- assertNull(actualValue);
- }
-
- public void testReadObject_Owner_WithWriteStatement() throws Exception {
- MockBean4Owner_Owner o2 = new MockBean4Owner_Owner();
- XMLDecoder dec2 = new XMLDecoder(getCodedXML(
- MockBean4Owner_Target.class,
- "/xml/MockBean4Owner_SetOwnerWithWriteStatement.xml"), o2);
- MockBean4Owner_Target t2 = (MockBean4Owner_Target) dec2.readObject();
-
- assertEquals(999, o2.getV());
- assertEquals(o2, t2.getV());
- }
-
- public void testReadObject_Repeated() throws Exception {
- final Vector<Exception> exceptionList = new Vector<Exception>();
-
- final ExceptionListener exceptionListener = new ExceptionListener() {
- public void exceptionThrown(Exception e) {
- exceptionList.addElement(e);
- }
- };
-
- XMLDecoder xmlDecoder = new XMLDecoder(new ByteArrayInputStream(
- xml123bytes));
- xmlDecoder.setExceptionListener(exceptionListener);
- assertEquals(new Integer(1), xmlDecoder.readObject());
- assertEquals(new Integer(2), xmlDecoder.readObject());
- assertEquals(new Integer(3), xmlDecoder.readObject());
- xmlDecoder.close();
- assertEquals(0, exceptionList.size());
- }
-
- public void testSetExceptionListener_Called() throws Exception {
- class MockExceptionListener implements ExceptionListener {
-
- private boolean isCalled = false;
-
- public void exceptionThrown(Exception e) {
- isCalled = true;
- }
-
- public boolean isCalled() {
- return isCalled;
- }
- }
-
- XMLDecoder xmlDecoder = new XMLDecoder(new ByteArrayInputStream(
- "<java><string/>".getBytes("UTF-8")));
- MockExceptionListener mockListener = new MockExceptionListener();
- xmlDecoder.setExceptionListener(mockListener);
-
- assertFalse(mockListener.isCalled());
- // Real Parsing should occur in method of ReadObject rather constructor.
- assertNotNull(xmlDecoder.readObject());
- assertTrue(mockListener.isCalled());
- }
-
- public void testSetExceptionListener() {
- XMLDecoder dec = new XMLDecoder(new ByteArrayInputStream(xml123bytes));
- Object defaultL = dec.getExceptionListener();
-
- dec.setExceptionListener(null);
- assertSame(defaultL, dec.getExceptionListener());
-
- ExceptionListener newL = new MockExceptionListener();
- dec.setExceptionListener(newL);
- assertSame(newL, dec.getExceptionListener());
- }
-
- /* RI also failed on the test case */
- /*
- public void testSetExceptionListener_CatchException() throws Exception {
- MockExceptionListener l = new MockExceptionListener();
- new XMLDecoder(getCodedXML(null, "/xml/bad_int.xml"), null, l);
- assertTrue(l.size() > 0);
- }
- */
-
- public void testSetOwner() {
- XMLDecoder dec = new XMLDecoder(new ByteArrayInputStream(xml123bytes));
- assertNull(dec.getOwner());
-
- String owner = "owner";
- dec.setOwner(owner);
- assertSame(owner, dec.getOwner());
-
- dec.setOwner(null);
- assertNull(dec.getOwner());
- }
-
- /*
- * Class under test for void XMLDecoder(java.io.InputStream)
- */
- public void testXMLDecoderInputStream() {
- XMLDecoder dec = new XMLDecoder(new ByteArrayInputStream(xml123bytes));
- assertNull(dec.getOwner());
- assertNotNull(dec.getExceptionListener());
- }
-
- /*
- * Class under test for void XMLDecoder(java.io.InputStream,
- * java.lang.Object)
- */
- public void testXMLDecoderInputStreamObject() {
- String owner = "owner";
- XMLDecoder dec = new XMLDecoder(new ByteArrayInputStream(xml123bytes),
- owner);
- assertSame(owner, dec.getOwner());
- assertNotNull(dec.getExceptionListener());
- }
-
- /*
- * Class under test for void XMLDecoder(java.io.InputStream,
- * java.lang.Object, java.beans.ExceptionListener)
- */
- public void testXMLDecoderInputStreamObjectExceptionListener() {
- String owner = "owner";
- MockExceptionListener l = new MockExceptionListener();
- XMLDecoder dec = new XMLDecoder(new ByteArrayInputStream(xml123bytes),
- owner, l);
- assertSame(owner, dec.getOwner());
- assertSame(l, dec.getExceptionListener());
- }
-
- /**
- * The test checks the code generation for XML from Test1.xml
- */
- public void testDecodeLinkedList() throws Exception {
- decode("xml/Test1.xml");
- }
-
- /**
- * The test checks the code generation for XML from Test2.xml
- */
- public void testDecodePrimitiveArrayByLength() throws Exception {
- decode("xml/Test2.xml");
- }
-
- /**
- * The test checks the code generation for XML from Test3.xml
- */
- public void testDecodePrimitiveArrayByElements() throws Exception {
- decode("xml/Test3.xml");
- }
-
- /**
- * The test checks the code generation for XML from Test4.xml
- */
- public void testDecodeObjectArrayByLength() throws Exception {
- decode("xml/Test4.xml");
- }
-
- /**
- * The test checks the code generation for XML from Test5.xml
- */
- public void testDecodeObjectArrayByElements() throws Exception {
- decode("xml/Test5.xml");
- }
-
- /**
- * The test checks the code generation for XML from Test6.xml
- */
- public void testDecodeReference() throws Exception {
- XMLDecoder d = null;
- try {
- Introspector.setBeanInfoSearchPath(new String[] {});
- d = new XMLDecoder(getCodedXML(
- org.apache.harmony.beans.tests.support.SampleBean.class,
- "/xml/Test6.xml"));
- while (true) {
- d.readObject();
- }
- } catch (ArrayIndexOutOfBoundsException aibe) {
- assertTrue(true);
- } finally {
- if (d != null) {
- d.close();
- }
- }
- }
-
- /**
- * The test checks the code generation for XML from Test7.xml
- */
- public void testDecodeStringArray() throws Exception {
- decode("xml/Test7.xml");
- }
-
- /**
- * Regression test for HARMONY-1890
- */
- public void testDecodeEmptyStringArray1890() {
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- XMLEncoder encoder = new XMLEncoder(out);
- XMLDecoder decoder;
- Object obj;
-
- encoder.writeObject(new String[10]);
- encoder.close();
-
- decoder = new XMLDecoder(new ByteArrayInputStream(out.toByteArray()));
- obj = decoder.readObject();
- decoder.close();
- assertTrue("Returned object is not array", obj.getClass().isArray());
- assertSame("String type expected", String.class, obj.getClass()
- .getComponentType());
- assertEquals("Size mismatch", 10, Array.getLength(obj));
- }
-
- public static Test suite() {
- return new TestSuite(XMLDecoderTest.class);
- }
-
- private void decode(String resourceName) throws Exception {
- XMLDecoder d = null;
- try {
- Introspector.setBeanInfoSearchPath(new String[] {});
- d = new XMLDecoder(new BufferedInputStream(ClassLoader
- .getSystemClassLoader().getResourceAsStream(resourceName)));
- while (true) {
- d.readObject();
- }
- } catch (ArrayIndexOutOfBoundsException aibe) {
- assertTrue(true);
- } finally {
- if (d != null) {
- d.close();
- }
- }
- }
-}
diff --git a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/XMLEncoderTest.java b/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/XMLEncoderTest.java
deleted file mode 100644
index b7c164e..0000000
--- a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/XMLEncoderTest.java
+++ /dev/null
@@ -1,1953 +0,0 @@
-/*
- * 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.java.beans;
-
-import java.awt.SystemColor;
-import java.awt.font.TextAttribute;
-import java.beans.DefaultPersistenceDelegate;
-import java.beans.Encoder;
-import java.beans.ExceptionListener;
-import java.beans.Expression;
-import java.beans.PersistenceDelegate;
-import java.beans.Statement;
-import java.beans.XMLDecoder;
-import java.beans.XMLEncoder;
-import java.io.BufferedReader;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.io.PrintWriter;
-import java.io.StringReader;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Map;
-import java.util.Set;
-import java.util.SortedMap;
-import java.util.SortedSet;
-import java.util.TreeMap;
-import java.util.TreeSet;
-
-import junit.framework.TestCase;
-
-import org.apache.harmony.beans.tests.java.beans.EncoderTest.SampleBean;
-import org.apache.harmony.beans.tests.support.AType;
-import org.apache.harmony.beans.tests.support.StandardBean;
-import org.apache.harmony.beans.tests.support.TestEventHandler;
-import org.apache.harmony.beans.tests.support.mock.MockBean4Codec;
-import org.apache.harmony.beans.tests.support.mock.MockBean4Owner_Owner;
-import org.apache.harmony.beans.tests.support.mock.MockBean4Owner_Target;
-import org.apache.harmony.beans.tests.support.mock.MockTreeMapClass;
-import org.xml.sax.InputSource;
-import org.xml.sax.XMLReader;
-import org.xml.sax.helpers.XMLReaderFactory;
-
-/**
- * Tests for XMLEncoder
- */
-public class XMLEncoderTest extends TestCase {
-
- public static class DependencyBean {
- private int ints[] = new int[] { 1 };
-
- private Object ref;
-
- public int[] getInts() {
- return ints;
- }
-
- public void setInts(int[] ints) {
- this.ints = ints;
- }
-
- public Object getRef() {
- return ref;
- }
-
- public void setRef(Object ref) {
- this.ref = ref;
- }
- }
-
- public static class VerboseEncoder extends XMLEncoder {
-
- private PrintWriter out;
-
- private boolean ident;
-
- public VerboseEncoder() {
- this(new PrintWriter(System.out, true), true);
- }
-
- public VerboseEncoder(PrintWriter out, boolean ident) {
- super(System.out);
- this.out = out;
- this.ident = ident;
- }
-
- @Override
- public Object get(Object arg0) {
- String identStr = ident ? ident() : "";
- out.println(identStr + "get()> " + arg0);
- Object result = super.get(arg0);
- out.println(identStr + "get()< " + result);
- return result;
- }
-
- @Override
- public PersistenceDelegate getPersistenceDelegate(Class<?> type) {
- PersistenceDelegate result = super.getPersistenceDelegate(type);
- return result;
- }
-
- @Override
- public Object remove(Object arg0) {
- String identStr = ident ? ident() : "";
- out.println(identStr + "remove()> " + arg0);
- Object result = super.remove(arg0);
- out.println(identStr + "remove()< " + result);
- return result;
- }
-
- @Override
- public void writeExpression(Expression arg0) {
- String identStr = ident ? ident() : "";
- out.println(identStr + "writeExpression()> " + string(arg0));
- super.writeExpression(arg0);
- out.println(identStr + "writeExpression()< ");
- }
-
- @Override
- public void writeStatement(Statement arg0) {
- String identStr = ident ? ident() : "";
- out.println(identStr + "writeStatement()> " + string(arg0));
- super.writeStatement(arg0);
- out.println(identStr + "writeStatement()< ");
- }
-
- @Override
- public void writeObject(Object arg0) {
- String identStr = ident ? ident() : "";
- out.println(identStr + "writeObject()> " + arg0);
- super.writeObject(arg0);
- out.println(identStr + "writeObject()< ");
- }
- }
-
- public XMLEncoderTest() {
- super();
- }
-
- public XMLEncoderTest(String s) {
- super(s);
- }
-
- public static String ident() {
- Exception ex = new Exception();
- int level = ex.getStackTrace().length;
- StringBuffer buf = new StringBuffer();
- for (int i = 0; i < level; i++) {
- buf.append(" ");
- }
- return buf.toString();
- }
-
- public static String string(Statement stat) {
- String str = "(" + stat.getTarget() + ")." + stat.getMethodName() + "(";
- Object args[] = stat.getArguments();
- for (int i = 0; i < args.length; i++) {
- if (i > 0) {
- str += ", ";
- }
- str += args[i];
- }
- str = str + ")";
- return str;
- }
-
- public static String string(Expression exp) {
- String str = "";
- try {
- str += str + exp.getValue();
- } catch (Exception e) {
- e.printStackTrace();
- }
- str += "=" + string((Statement) exp);
- return str;
- }
-
- public void testWriteExpression_Scenario1() {
- XMLEncoder xmlEncoder = new XMLEncoder((OutputStream) null);
- try {
- xmlEncoder.writeExpression((Expression) null);
- fail("should throw NullPointerException");
- } catch (NullPointerException e) {
- // Expected
- }
- }
-
- public void testWriteExpression_Scenario2() {
- XMLEncoder xmlEncoder = new XMLEncoder(new ByteArrayOutputStream());
- try {
- xmlEncoder.writeExpression((Expression) null);
- fail("should throw NullPointerException");
- } catch (NullPointerException e) {
- // Expected
- }
- }
-
- public void testWriteStatement() {
- // covered by testWriteStatement
-
- //Regression for HARMONY-1521
- //no exception expected
- new XMLEncoder(new ByteArrayOutputStream()).writeStatement(null);
- }
-
- public void testWriteObject_Null() throws Exception {
- assertCodedXML(null, "/xml/null.xml");
- }
-
- public void testWriteObject_Integer() throws Exception {
- assertCodedXML(new Integer(3), "/xml/int.xml");
- }
-
- public void testWriteObject_StringCodec() throws Exception {
- SampleBean b = new SampleBean();
- b.setMyid("<Li Yang> & \"liyang'");
- SampleBean c = new SampleBean();
- c.setMyid("a child");
- b.setRef(c);
- assertCodedXML(b, "/xml/SampleBean_StringCodec.xml");
- }
-
- public void testWriteObject_IntArray() throws Exception {
- assertCodedXML(new int[] { 1, 2, 3 }, "/xml/IntArray.xml");
- }
-
- public void testWriteObject_PropertyDependency() throws Exception {
- DependencyBean b = new DependencyBean();
- b.getInts()[0] = 888;
- b.setRef(b.getInts());
- assertCodedXML(b, "/xml/DependencyBean.xml");
- }
-
- public void testWriteObject_NoChange() throws Exception {
- assertCodedXML(new MockBean4Codec(), "/xml/MockBean4Codec_NoChange.xml");
- }
-
- public void testWriteObject_BornFriendChange() throws Exception {
- MockBean4Codec b = new MockBean4Codec();
- b.getBornFriend().getZarr()[0] = 888;
- b.setNill(b.getBornFriend());
-
- assertCodedXML(b, "/xml/MockBean4Codec_BornFriendChange.xml");
- }
-
- /* RI fails on this. Because even though we have change the class
- eception, it does not occurred on the output. */
- public void testWriteObject_ManyChanges() throws Exception {
- assertCodedXML(MockBean4Codec.getInstanceOfManyChanges(),
- "/xml/MockBean4Codec_ManyChanges.xml");
- }
-
- /* RI fails on this. Because even though we have change the class
- eception, it does not occurred on the output. */
- public void testWriteObject_ManyChanges_2() throws Exception {
- assertCodedXML(MockBean4Codec.getInstanceOfManyChanges2(),
- "/xml/MockBean4Codec_ManyChanges_2.xml");
- }
-
- public void testWriteObject_SetOwner() throws Exception {
- ByteArrayOutputStream temp = new ByteArrayOutputStream();
- XMLEncoder enc = new XMLEncoder(temp);
-
- MockBean4Owner_Target t = new MockBean4Owner_Target();
- MockBean4Owner_Owner o = new MockBean4Owner_Owner();
- t.setV(o);
- enc.setOwner(o);
-
- assertCodedXML(t, "/xml/MockBean4Owner_SetOwner.xml", temp, enc);
-
- }
-
- public void testWriteObject_SetOwnerWithWriteStatement() throws Exception {
- ByteArrayOutputStream temp = new ByteArrayOutputStream();
- XMLEncoder enc = new XMLEncoder(temp);
-
- MockBean4Owner_Target t = new MockBean4Owner_Target();
- MockBean4Owner_Owner o = new MockBean4Owner_Owner();
- t.setV(o);
- enc.setOwner(o);
-
- enc.writeStatement(new Statement(o, "loading", new Object[] {}));
-
- assertCodedXML(t, "/xml/MockBean4Owner_SetOwnerWithWriteStatement.xml",
- temp, enc);
-
- }
-
- /* TODO HARMONY fails on this test case
- public void testWriteObject_StaticField() throws Exception {
- ByteArrayOutputStream temp = new ByteArrayOutputStream();
- XMLEncoder enc = new XMLEncoder(temp);
-
- enc.setPersistenceDelegate(MockBean4StaticField.class,
- new MockBean4StaticField_PD());
-
- assertCodedXML(MockBean4StaticField.inst,
- "/xml/MockBean4StaticField.xml", temp, enc);
-
- }
- */
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- public void testWriteObject_MockTreeMap() throws Exception {
- Map<String, TreeMap<String, String>> innerTreeMap = new MockTreeMapClass();
- TreeMap resultTreeMap = innerTreeMap.get("outKey");
- resultTreeMap.put("innerKey", "innerValue");
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- XMLEncoder xmlEncoder = new XMLEncoder(baos);
-
- assertCodedXML(innerTreeMap, "/xml/MockTreeMap.xml", baos, xmlEncoder);
- assertEquals(1, innerTreeMap.size());
- }
-
- public static enum Element {
- ELEMENTA, ELEMENTB, ELEMENTC
- }
-
- public static class MockEnumObject {
-
- Element element;
-
- public Element getElement() {
- return element;
- }
-
- public void setElement(Element element) {
- this.element = element;
- }
- }
-
- public void testWriteObject_EnumObject() throws Exception {
- MockEnumObject mockEnumObject = new MockEnumObject();
- mockEnumObject.setElement(Element.ELEMENTA);
- assertCodedXML(mockEnumObject, "/xml/MockEnumObject.xml");
- }
-
- public static class Mock2EnumObject {
-
- Element element = Element.ELEMENTA;
-
- public Element getElement() {
- return element;
- }
-
- public void setElement(Element element) {
- this.element = element;
- }
- }
-
- public static class ElementPersistenceDelegate extends
- DefaultPersistenceDelegate {
- }
-
- public void testWriteObject_2EnumObject() throws Exception {
- Mock2EnumObject mockEnumObject = new Mock2EnumObject();
- Encoder encoder = new Encoder();
- encoder.setPersistenceDelegate(Element.class,
- new ElementPersistenceDelegate());
- assertFalse(encoder.getPersistenceDelegate(Element.class) instanceof ElementPersistenceDelegate);
- mockEnumObject.setElement(Element.ELEMENTB);
- assertCodedXML(mockEnumObject, "/xml/Mock2EnumObject.xml");
- }
-
- public void testClose() {
- ByteArrayOutputStream out = new ByteArrayOutputStream() {
- boolean closeCalled = false;
-
- @Override
- public void close() throws IOException {
- if (closeCalled) {
- throw new IOException("close already called!");
- }
- closeCalled = true;
- super.close();
- }
- };
- XMLEncoder enc = new XMLEncoder(out);
- enc.writeObject(new Integer(3));
- assertEquals(0, out.size());
-
- enc.close();
-
- assertTrue(out.size() > 0);
- try {
- out.close();
- fail();
- } catch (IOException e) {
- assertEquals("close already called!", e.getMessage());
- }
- }
-
- public void testFlush() {
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- XMLEncoder enc = new XMLEncoder(out);
- Integer i = new Integer(3);
- enc.writeObject(i);
- assertEquals(0, out.size());
- assertNotNull(enc.get(i));
-
- enc.flush();
-
- assertTrue(out.size() > 0);
- assertNull(enc.get(i));
- }
-
- public void testXMLEncoder_Null() throws NullPointerException {
- new XMLEncoder(null);
- }
-
- public void testGetOwner() {
- XMLEncoder enc = new XMLEncoder(System.out);
- assertNull(enc.getOwner());
- }
-
- public void testSetOwner() {
- XMLEncoder enc = new XMLEncoder(System.out);
- Object owner = Boolean.FALSE;
-
- enc.setOwner(owner);
- assertSame(owner, enc.getOwner());
-
- enc.setOwner(null);
- assertNull(enc.getOwner());
- }
-
- private void assertCodedXML(Object obj, String xmlFile) throws Exception {
- ByteArrayOutputStream temp = new ByteArrayOutputStream();
- XMLEncoder enc = new XMLEncoder(temp);
-
- assertCodedXML(obj, xmlFile, temp, enc);
- }
-
- private void assertCodedXML(Object obj, String xmlFile,
- ByteArrayOutputStream temp, XMLEncoder enc) throws Exception {
- if (enc == null || temp == null) {
- temp = new ByteArrayOutputStream();
- enc = new XMLEncoder(temp);
- }
- enc.writeObject(obj);
- enc.close();
-
- assertXMLContent(obj, temp.toByteArray(), xmlFile);
-
- }
-
- private void assertXMLContent(Object obj, byte[] bytes, String xmlFile) throws Exception {
- InputStream refIn;
- InputStreamReader xml;
-
- XMLReader xmlReader;
- XMLReader refXmlReader;
- TestEventHandler handler = new TestEventHandler();
- TestEventHandler refHandler = new TestEventHandler();
- String saxParserClassName = System.getProperty("org.xml.sax.driver");
- String version = System.getProperty("java.version");
- xml = new InputStreamReader(new ByteArrayInputStream(bytes), "UTF-8");
- refIn = XMLEncoderTest.class.getResourceAsStream(xmlFile);
- if (refIn == null) {
- throw new Error("resource " + xmlFile + " not exist in "
- + XMLEncoderTest.class.getPackage());
- }
- BufferedReader br = new BufferedReader(new InputStreamReader(refIn, "UTF-8"));
- StringBuilder sb = new StringBuilder();
- String line = null;
- while((line = br.readLine()) != null){
- sb.append(line + "\n");
- }
- refIn.close();
- String refString = sb.toString();
- refString = refString.replace("${version}", version);
- if(obj != null){
- refString = refString.replace("${classname}", obj.getClass().getName());
- }
- if (saxParserClassName == null) {
- xmlReader = XMLReaderFactory.createXMLReader();
- refXmlReader = XMLReaderFactory.createXMLReader();
- } else {
- xmlReader = XMLReaderFactory.createXMLReader(saxParserClassName);
- refXmlReader = XMLReaderFactory.createXMLReader(saxParserClassName);
- }
-
- xmlReader.setContentHandler(handler);
- xmlReader.setErrorHandler(handler);
- xmlReader.parse(new InputSource(xml));
-
- refXmlReader.setContentHandler(refHandler);
- refXmlReader.setErrorHandler(refHandler);
- refXmlReader.parse(new InputSource(new StringReader(refString)));
-
- assertEquals("Generated XML differs from the sample,", refHandler.root,
- handler.root);
- }
-
- /**
- * The test checks that java.lang.Boolean exemplar store is correct
- */
- public void testEncodeBoolean() {
- XMLEncoder e = new XMLEncoder(System.out);
- e.setExceptionListener(new ExceptionListener() {
- public void exceptionThrown(Exception e) {
- fail("Exception " + e.getClass() + " is thrown: "
- + e.getMessage());
- }
- });
-
- try {
- e.writeObject(new Boolean(true));
- } finally {
- e.close();
- }
- }
-
- /**
- * The test checks that java.lang.Byte exemplar store is correct
- */
- public void testEncodeByte() {
- XMLEncoder e = new XMLEncoder(System.out);
- e.setExceptionListener(new ExceptionListener() {
- public void exceptionThrown(Exception e) {
- fail("Exception " + e.getClass() + " is thrown: "
- + e.getMessage());
- }
- });
-
- try {
- e.writeObject(new Byte((byte) 123));
- } finally {
- e.close();
- }
- }
-
- /**
- * The test checks that java.lang.Character exemplar store is correct
- */
- public void testEncodeCharacter() {
- XMLEncoder e = new XMLEncoder(System.out);
- e.setExceptionListener(new ExceptionListener() {
- public void exceptionThrown(Exception e) {
- fail("Exception " + e.getClass() + " is thrown: "
- + e.getMessage());
- }
- });
-
- try {
- e.writeObject(new Character('a'));
- } finally {
- e.close();
- }
- }
-
- /**
- * The test checks that java.lang.Class exemplar store is correct
- */
- public void testEncodeClass() {
- XMLEncoder e = new XMLEncoder(System.out);
- e.setExceptionListener(new ExceptionListener() {
- public void exceptionThrown(Exception e) {
- fail("Exception " + e.getClass() + " is thrown: "
- + e.getMessage());
- }
- });
-
- try {
- e.writeObject(Object.class);
- } finally {
- e.close();
- }
- }
-
- /**
- * The test checks that java.lang.Double exemplar store is correct
- */
- public void testEncodeDouble() {
- XMLEncoder e = new XMLEncoder(System.out);
- e.setExceptionListener(new ExceptionListener() {
- public void exceptionThrown(Exception e) {
- fail("Exception " + e.getClass() + " is thrown: "
- + e.getMessage());
- }
- });
-
- try {
- e.writeObject(new Double(0.01));
- } finally {
- e.close();
- }
- }
-
- /**
- * The test checks that java.lang.Float exemplar store is correct
- */
- public void testEncodeFloat() {
- XMLEncoder e = new XMLEncoder(System.out);
- e.setExceptionListener(new ExceptionListener() {
- public void exceptionThrown(Exception e) {
- fail("Exception " + e.getClass() + " is thrown: "
- + e.getMessage());
- }
- });
-
- try {
- e.writeObject(new Float((float) 0.01));
- } finally {
- e.close();
- }
- }
-
- /**
- * The test checks that java.lang.Integer exemplar store is correct
- */
- public void testEncodeInteger() {
- XMLEncoder e = new XMLEncoder(System.out);
- e.setExceptionListener(new ExceptionListener() {
- public void exceptionThrown(Exception e) {
- fail("Exception " + e.getClass() + " is thrown: "
- + e.getMessage());
- }
- });
-
- try {
- e.writeObject(new Integer(1));
- } finally {
- e.close();
- }
- }
-
- /**
- * The test checks that java.lang.Long exemplar store is correct
- */
- public void testEncodeLong() {
- XMLEncoder e = new XMLEncoder(System.out);
- e.setExceptionListener(new ExceptionListener() {
- public void exceptionThrown(Exception e) {
- fail("Exception " + e.getClass() + " is thrown: "
- + e.getMessage());
- }
- });
-
- try {
- e.writeObject(new Long(1));
- } finally {
- e.close();
- }
- }
-
- /**
- * The test checks that java.lang.Short exemplar store is correct
- */
- public void testEncodeShort() {
- XMLEncoder e = new XMLEncoder(System.out);
- e.setExceptionListener(new ExceptionListener() {
- public void exceptionThrown(Exception e) {
- fail("Exception " + e.getClass() + " is thrown: "
- + e.getMessage());
- }
- });
-
- try {
- e.writeObject(new Short((short) 1));
- } finally {
- e.close();
- }
- }
-
- /**
- * The test checks that java.lang.String exemplar store is correct
- */
- public void testEncodeString() {
- XMLEncoder e = new XMLEncoder(System.out);
- e.setExceptionListener(new ExceptionListener() {
- public void exceptionThrown(Exception e) {
- fail("Exception " + e.getClass() + " is thrown: "
- + e.getMessage());
- }
- });
-
- try {
- e.writeObject(new String("hello"));
- } finally {
- e.close();
- }
- }
-
- /**
- * The test checks that array exemplar store is correct
- */
- public void testEncodeArray() {
- XMLEncoder e = new XMLEncoder(System.out);
- e.setExceptionListener(new ExceptionListener() {
- public void exceptionThrown(Exception e) {
- fail("Exception " + e.getClass() + " is thrown: "
- + e.getMessage());
- }
- });
-
- try {
- e.writeObject(new int[] { 1, 2, 3 });
- } finally {
- e.close();
- }
- }
-
- /**
- * The test checks that null exemplar store is correct
- */
- public void testEncodeNull() {
- XMLEncoder e = new XMLEncoder(System.out);
- e.setExceptionListener(new ExceptionListener() {
- public void exceptionThrown(Exception e) {
- fail("Exception " + e.getClass() + " is thrown: "
- + e.getMessage());
- }
- });
-
- try {
- e.writeObject(null);
- } finally {
- e.close();
- }
- }
-
- /**
- * The test checks that complex scenario store is correct
- */
- public void testEncodingScenario1() {
- XMLEncoder e = new XMLEncoder(System.out);
- e.setExceptionListener(new ExceptionListener() {
- public void exceptionThrown(Exception e) {
- fail("Exception " + e.getClass() + " is thrown: "
- + e.getMessage());
- }
- });
-
- StandardBean bean1 = new StandardBean("bean1");
-
- StandardBean bean2 = new StandardBean();
- bean2.setText(null);
-
- bean1.setPeer(bean2);
- bean2.setPeer(bean1);
-
- try {
- e.writeObject(bean1);
- e.writeObject(bean2);
- } finally {
- e.close();
- }
- }
-
- public static class MockClass {
-
- private Date date = null;
-
- public MockClass() {
-
- }
-
- public MockClass(Date date) {
- this.date = date;
- }
-
- public boolean equals(Object obj) {
- MockClass mockObj = (MockClass) obj;
- if (date != null && mockObj.date != null) {
- return date.equals(mockObj.date);
- }
- return false;
- }
-
- public Date getDate() {
- return date;
- }
-
- public void setDate(Date date) {
- this.date = date;
- }
- }
-
- public void testEncodingScenario2() {
- XMLEncoder xmlEncoder = new XMLEncoder(System.out);
- xmlEncoder.setExceptionListener(new ExceptionListener() {
- public void exceptionThrown(Exception e) {
- fail("Exception " + e.getClass() + " is thrown: "
- + e.getMessage());
- }
- });
-
- xmlEncoder.writeObject(new MockClass(new Date()));
- }
-
- /**
- * The test checks that encoder can handle writeExpression in initialize
- */
- public void testEncodeExpressionAsStatement() {
- XMLEncoder e = new XMLEncoder(System.out);
- e.setExceptionListener(new ExceptionListener() {
- public void exceptionThrown(Exception e) {
- fail("Exception " + e.getClass() + " is thrown: "
- + e.getMessage());
- }
- });
-
- try {
- final Object object = new Object();
- e.setPersistenceDelegate(AType.class,
- new DefaultPersistenceDelegate() {
- @Override
- protected void initialize(Class<?> type,
- Object oldInstance, Object newInstance,
- Encoder out) {
- out.writeExpression(new Expression(object,
- oldInstance, "go", new Object[] {}));
- }
- });
- AType a = new AType();
-
- // e.writeObject(object);
- e.writeObject(a);
- e.writeObject(object);
- } finally {
- e.close();
- }
- }
-
- /**
- * This is a regression test for HARMONY-5707.
- */
- public void test5707() {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- XMLEncoder encoder = new XMLEncoder(baos);
- TstBean5707 bean1 = new TstBean5707();
-
- encoder.writeObject(bean1);
- encoder.close();
- }
-
- public class TstBean5707 {
- int val;
-
- public TstBean5707() {
- val = 0;
- }
-
- public TstBean5707(int n) {
- val = n;
- }
-
- public TstBean5707 getProp1() {
- return new TstBean5707(val);
- }
-
- public void setProp1(TstBean5707 val) {}
-
- public boolean equals(Object obj) {
- if (obj instanceof TstBean5707) {
- return ((TstBean5707) obj).val == val;
- }
-
- return false;
- }
- }
-
- public void testWriteObject_StaticFields() throws Exception {
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- XMLEncoder xmlEncoder = new XMLEncoder(bos);
- xmlEncoder.setPersistenceDelegate(MockObject.class,
- new MockObjectPersistenceDelegate());
- xmlEncoder.writeObject(MockObject.inst);
- xmlEncoder.writeObject(MockObject.inst);
- xmlEncoder.writeObject(SystemColor.activeCaption);
- xmlEncoder.writeObject(SystemColor.activeCaption);
- xmlEncoder.writeObject(TextAttribute.FAMILY);
- xmlEncoder.writeObject(TextAttribute.FAMILY);
- xmlEncoder.close();
- assertXMLContent(null, bos.toByteArray(), "/xml/StaticField.xml");
- }
-
- public static class MockObject {
- public static MockObject inst = new MockObject();
- }
-
- public static class MockObjectPersistenceDelegate extends
- PersistenceDelegate {
- protected Expression instantiate(Object oldInstance, Encoder enc) {
- Expression exp = null;
- try {
- exp = new Expression(MockObject.class.getField("inst"), "get",
- new Object[] { null });
- } catch (Exception e) {
- e.printStackTrace();
- }
- return exp;
- }
- }
-
- public void testWriteObject_ChangedObject() throws Exception {
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- XMLEncoder xmlEncoder = new XMLEncoder(bos);
- Sample sample = new Sample("oldName");
- xmlEncoder.writeObject(sample);
- sample.setName("newName");
- xmlEncoder.writeObject(sample);
- xmlEncoder.close();
- assertXMLContent(null, bos.toByteArray(), "/xml/ChangedObject.xml");
- }
-
- public static class Sample {
-
- String name;
-
- public Sample() {
- name = null;
- }
-
- public Sample(String n) {
- name = n;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
- }
-
- public void testWriteObject_ClassID() throws Exception {
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- XMLEncoder xmlEncoder = new XMLEncoder(bos);
- ChildClass childClazz = new ChildClass();
- childClazz.setClazz(ChildClass.class);
- xmlEncoder.writeObject(childClazz);
- xmlEncoder.close();
- assertXMLContent(null, bos.toByteArray(), "/xml/ClassID.xml");
- }
-
- public static class ParentClass {
-
- Class<?> clazz = Collection.class;
-
- public Class<?> getClazz() {
- return clazz;
- }
-
- public void setClazz(Class<?> clazz) {
- this.clazz = clazz;
- }
- }
-
- public static class ChildClass extends ParentClass {
- }
-
- public void testWriteObject_ObjectID() throws Exception {
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- XMLEncoder xmlEncoder = new XMLEncoder(bos);
- ExampleA exampleAI = new ExampleA("exampleAI");
- xmlEncoder.writeObject(exampleAI);
- xmlEncoder.writeObject(exampleAI);
- ExampleA exampleAII = new ExampleA("exampleAI");
- xmlEncoder.writeObject(exampleAII);
- xmlEncoder.writeObject(exampleAII);
-
- ExampleB exampleBI = new ExampleB("exampleBI");
- xmlEncoder.writeObject(exampleBI);
- xmlEncoder.writeObject(exampleBI);
- ExampleB exampleBII = new ExampleB("exampleBII");
- xmlEncoder.writeObject(exampleBII);
- xmlEncoder.writeObject(exampleBII);
-
- ExampleC exampleCI = new ExampleC("exampleCI");
- xmlEncoder.writeObject(exampleCI);
- xmlEncoder.writeObject(exampleCI);
- ExampleC exampleCII = new ExampleC("exampleCII");
- xmlEncoder.writeObject(exampleCII);
- xmlEncoder.writeObject(exampleCII);
-
- xmlEncoder.close();
-
- assertXMLContent(null, bos.toByteArray(), "/xml/ObjectID.xml");
- }
-
- public static class ExampleA {
-
- private String name;
-
- public ExampleA() {
-
- }
-
- public ExampleA(String name) {
- this.name = name;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
- }
-
- public static class ExampleB {
-
- private String name;
-
- public ExampleB() {
-
- }
-
- public ExampleB(String name) {
- this.name = name;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
- }
-
- public static class ExampleC {
-
- private String name;
-
- public ExampleC() {
-
- }
-
- public ExampleC(String name) {
- this.name = name;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
- }
-
- public static class MockCharProperty {
- private char property;
-
- public char getProperty() {
- return property;
- }
-
- public void setProperty(char property) {
- this.property = property;
- }
-
- public boolean equals(Object obj) {
- if (obj instanceof MockCharProperty) {
- return ((MockCharProperty) obj).property == (this.property);
- }
- return false;
- }
- }
-
- public void testMockCharProperty() {
- MockCharProperty expectedObj = new MockCharProperty();
- MockCharProperty actualObj;
- ByteArrayOutputStream baos;
- ByteArrayInputStream bais;
- XMLEncoder xmlEncoder;
- XMLDecoder xmlDecoder;
- char ch;
- for (int index = 1; index < 65536; index++) {
- ch = (char) index;
- if (invalidCharacter(ch)) {
- expectedObj.setProperty(ch);
- baos = new ByteArrayOutputStream();
- xmlEncoder = new XMLEncoder(baos);
- xmlEncoder.writeObject(expectedObj);
- xmlEncoder.close();
- assertTrue(baos.toString().contains("<char code=\"#"));
-
- bais = new ByteArrayInputStream(baos.toByteArray());
- xmlDecoder = new XMLDecoder(bais);
- actualObj = (MockCharProperty) xmlDecoder.readObject();
- xmlDecoder.close();
- assertEquals(expectedObj, actualObj);
- }
- }
- }
-
- public static class MockStringProperty {
- private String property;
-
- public String getProperty() {
- return property;
- }
-
- public void setProperty(String property) {
- this.property = property;
- }
-
- public boolean equals(Object obj) {
- if (obj instanceof MockStringProperty) {
- return ((MockStringProperty) obj).property
- .equals(this.property);
- }
- return false;
- }
- }
-
- public void testMockStringProperty() {
- MockStringProperty expectedObj = new MockStringProperty();
- MockStringProperty actualObj;
- ByteArrayOutputStream baos;
- ByteArrayInputStream bais;
- XMLEncoder xmlEncoder;
- XMLDecoder xmlDecoder;
- char ch;
- for (int index = 0; index < 65536; index++) {
- ch = (char) index;
- if (invalidCharacter(ch)) {
- expectedObj.setProperty(stringWithChar(ch));
- baos = new ByteArrayOutputStream();
- xmlEncoder = new XMLEncoder(baos);
- xmlEncoder.writeObject(expectedObj);
- xmlEncoder.close();
- assertTrue(baos.toString().contains("<char code=\"#"));
-
- bais = new ByteArrayInputStream(baos.toByteArray());
- xmlDecoder = new XMLDecoder(bais);
- actualObj = (MockStringProperty) xmlDecoder.readObject();
- xmlDecoder.close();
- assertEquals(expectedObj, actualObj);
- }
- }
- }
-
- private String stringWithChar(char character) {
- return "a string with a " + character + " character";
- }
-
- private boolean invalidCharacter(char c) {
- return ((0x0000 <= c && c < 0x0009) || (0x000a < c && c < 0x000d)
- || (0x000d < c && c < 0x0020) || (0xd7ff < c && c < 0xe000) || c == 0xfffe);
- }
-
- public static class MockUnmodifiableCollection {
-
- private Collection<String> property = new ArrayList<String>();
-
- public Collection<String> getProperty() {
- return Collections.unmodifiableCollection(property);
- }
-
- public void setProperty(Collection<String> set) {
- property.clear();
- property.addAll(set);
- }
- }
-
- public void testWriteObject_MockUnmodifiableCollection() throws Exception {
- MockUnmodifiableCollection mockCollections = new MockUnmodifiableCollection();
- Class<?> propertyClass = mockCollections.getProperty().getClass();
- assertEquals("java.util.Collections$UnmodifiableCollection",
- propertyClass.getName());
- assertSamePD(propertyClass);
- mockCollections.setProperty(Arrays
- .asList(new String[] { "A", "B", "C" }));
- assertCodedXML(mockCollections, "/xml/MockUnmodifiableCollection.xml");
- }
-
- public static class MockUnmodifiableList {
-
- private List<String> property = new LinkedList<String>();
-
- public Collection<String> getProperty() {
- return Collections.unmodifiableList(property);
- }
-
- public void setProperty(Collection<String> set) {
- property.clear();
- property.addAll(set);
- }
- }
-
- public void testWriteObject_MockUnmodifiableList() throws Exception {
- MockUnmodifiableList mockCollections = new MockUnmodifiableList();
- Class<?> propertyClass = mockCollections.getProperty().getClass();
- assertEquals("java.util.Collections$UnmodifiableList",
- propertyClass.getName());
- assertSamePD(propertyClass);
- mockCollections.setProperty(Arrays
- .asList(new String[] { "A", "B", "C" }));
- assertCodedXML(mockCollections, "/xml/MockUnmodifiableList.xml");
- }
-
- public static class MockUnmodifiableRandomAccessList {
-
- private List<String> property = new ArrayList<String>();
-
- public Collection<String> getProperty() {
- return Collections.unmodifiableList(property);
- }
-
- public void setProperty(Collection<String> set) {
- property.clear();
- property.addAll(set);
- }
- }
-
- public void testWriteObject_MockUnmodifiableRandomAccessList()
- throws Exception {
- MockUnmodifiableRandomAccessList mockCollections = new MockUnmodifiableRandomAccessList();
- Class<?> propertyClass = mockCollections.getProperty().getClass();
- assertEquals("java.util.Collections$UnmodifiableRandomAccessList",
- propertyClass.getName());
- assertSamePD(propertyClass);
- mockCollections.setProperty(Arrays
- .asList(new String[] { "A", "B", "C" }));
- assertCodedXML(mockCollections,
- "/xml/MockUnmodifiableRandomAccessList.xml");
- }
-
- public static class MockUnmodifiableSet {
-
- private Set<String> property = new HashSet<String>();
-
- public Collection<String> getProperty() {
- return Collections.unmodifiableSet(property);
- }
-
- public void setProperty(Collection<String> set) {
- property.clear();
- property.addAll(set);
- }
- }
-
- public void testWriteObject_MockUnmodifiableSet() throws Exception {
- MockUnmodifiableSet mockCollections = new MockUnmodifiableSet();
- Class<?> propertyClass = mockCollections.getProperty().getClass();
- assertEquals("java.util.Collections$UnmodifiableSet",
- propertyClass.getName());
- assertSamePD(propertyClass);
- Set<String> prop = new HashSet<String>();
- prop.add("A");
- prop.add("B");
- prop.add("C");
- mockCollections.setProperty(prop);
- assertCodedXML(mockCollections, "/xml/MockUnmodifiableSet.xml");
- }
-
- public static class MockUnmodifiableSortedSet {
-
- private SortedSet<String> property = new TreeSet<String>();
-
- public Collection<String> getProperty() {
- return Collections.unmodifiableSortedSet(property);
- }
-
- public void setProperty(Collection<String> set) {
- property.clear();
- property.addAll(set);
- }
- }
-
- public void testWriteObject_MockUnmodifiableSortedSet() throws Exception {
- MockUnmodifiableSortedSet mockCollections = new MockUnmodifiableSortedSet();
- Class<?> propertyClass = mockCollections.getProperty().getClass();
- assertEquals("java.util.Collections$UnmodifiableSortedSet",
- propertyClass.getName());
- assertSamePD(propertyClass);
- Set<String> prop = new HashSet<String>();
- prop.add("A");
- prop.add("B");
- prop.add("C");
- mockCollections.setProperty(prop);
- assertCodedXML(mockCollections, "/xml/MockUnmodifiableSortedSet.xml");
- }
-
- public static class MockUnmodifiableMap {
-
- private Map<String, String> property = new HashMap<String, String>();
-
- public Map<String, String> getProperty() {
- return Collections.unmodifiableMap(property);
- }
-
- public void setProperty(Map<String, String> prop) {
- property.clear();
- property.putAll(prop);
- }
- }
-
- public void testWriteObject_MockUnmodifiableMap() throws Exception {
- MockUnmodifiableMap mockCollections = new MockUnmodifiableMap();
- Class<?> propertyClass = mockCollections.getProperty().getClass();
- assertEquals("java.util.Collections$UnmodifiableMap",
- propertyClass.getName());
- assertSamePD(propertyClass);
- Map<String, String> prop = new HashMap<String, String>();
- prop.put("A", "a");
- prop.put("B", "b");
- prop.put("C", "c");
- mockCollections.setProperty(prop);
- assertCodedXML(mockCollections, "/xml/MockUnmodifiableMap.xml");
- }
-
- public static class MockUnmodifiableSortedMap {
-
- private SortedMap<String, String> property = new TreeMap<String, String>();
-
- public Map<String, String> getProperty() {
- return Collections.unmodifiableSortedMap(property);
- }
-
- public void setProperty(Map<String, String> prop) {
- property.clear();
- property.putAll(prop);
- }
- }
-
- public void testWriteObject_MockUnmodifiableSortedMap() throws Exception {
- MockUnmodifiableSortedMap mockCollections = new MockUnmodifiableSortedMap();
- Class<?> propertyClass = mockCollections.getProperty().getClass();
- assertEquals("java.util.Collections$UnmodifiableSortedMap",
- propertyClass.getName());
- assertSamePD(propertyClass);
- Map<String, String> prop = new HashMap<String, String>();
- prop.put("A", "a");
- prop.put("B", "b");
- prop.put("C", "c");
- mockCollections.setProperty(prop);
- assertCodedXML(mockCollections, "/xml/MockUnmodifiableSortedMap.xml");
- }
-
- public static class MockSynchronizedCollection {
-
- private Collection<String> property = new ArrayList<String>();
-
- public Collection<String> getProperty() {
- return Collections.synchronizedCollection(property);
- }
-
- public void setProperty(Collection<String> prop) {
- property.clear();
- property.addAll(prop);
- }
- }
-
- public void testWriteObject_MockSynchronizedCollection() throws Exception {
- MockSynchronizedCollection mockCollections = new MockSynchronizedCollection();
- Class<?> propertyClass = mockCollections.getProperty().getClass();
- assertEquals("java.util.Collections$SynchronizedCollection",
- propertyClass.getName());
- assertSamePD(propertyClass);
- mockCollections.setProperty(Arrays
- .asList(new String[] { "A", "B", "C" }));
- assertCodedXML(mockCollections, "/xml/MockSynchronizedCollection.xml");
- }
-
- public static class MockSynchronizedList {
-
- private List<String> property = new LinkedList<String>();
-
- public Collection<String> getProperty() {
- return Collections.synchronizedList(property);
- }
-
- public void setProperty(Collection<String> prop) {
- property.clear();
- property.addAll(prop);
- }
- }
-
- public void testWriteObject_MockSynchronizedList() throws Exception {
- MockSynchronizedList mockCollections = new MockSynchronizedList();
- Class<?> propertyClass = mockCollections.getProperty().getClass();
- assertEquals("java.util.Collections$SynchronizedList",
- propertyClass.getName());
- assertSamePD(propertyClass);
- mockCollections.setProperty(Arrays
- .asList(new String[] { "A", "B", "C" }));
- assertCodedXML(mockCollections, "/xml/MockSynchronizedList.xml");
- }
-
- public static class MockSynchronizedRandomAccessList {
-
- private List<String> property = new ArrayList<String>();
-
- public Collection<String> getProperty() {
- return Collections.synchronizedList(property);
- }
-
- public void setProperty(Collection<String> prop) {
- property.clear();
- property.addAll(prop);
- }
- }
-
- public void testWriteObject_MockSynchronizedRandomAccessList()
- throws Exception {
- MockSynchronizedRandomAccessList mockCollections = new MockSynchronizedRandomAccessList();
- Class<?> propertyClass = mockCollections.getProperty().getClass();
- assertEquals("java.util.Collections$SynchronizedRandomAccessList",
- propertyClass.getName());
- assertSamePD(propertyClass);
- mockCollections.setProperty(Arrays
- .asList(new String[] { "A", "B", "C" }));
- assertCodedXML(mockCollections,
- "/xml/MockSynchronizedRandomAccessList.xml");
- }
-
- public static class MockSynchronizedSet {
-
- private Set<String> property = new HashSet<String>();
-
- public Collection<String> getProperty() {
- return Collections.synchronizedSet(property);
- }
-
- public void setProperty(Collection<String> prop) {
- property.clear();
- property.addAll(prop);
- }
- }
-
- public void testWriteObject_MockSynchronizedSet() throws Exception {
- MockSynchronizedSet mockCollections = new MockSynchronizedSet();
- Class<?> propertyClass = mockCollections.getProperty().getClass();
- assertEquals("java.util.Collections$SynchronizedSet",
- propertyClass.getName());
- assertSamePD(propertyClass);
- mockCollections.setProperty(Arrays
- .asList(new String[] { "A", "B", "C" }));
- assertCodedXML(mockCollections, "/xml/MockSynchronizedSet.xml");
- }
-
- public static class MockSynchronizedSortedSet {
-
- private SortedSet<String> property = new TreeSet<String>();
-
- public Collection<String> getProperty() {
- return Collections.synchronizedSortedSet(property);
- }
-
- public void setProperty(Collection<String> prop) {
- property.clear();
- property.addAll(prop);
- }
- }
-
- public void testWriteObject_MockSynchronizedSortedSet() throws Exception {
- MockSynchronizedSortedSet mockCollections = new MockSynchronizedSortedSet();
- Class<?> propertyClass = mockCollections.getProperty().getClass();
- assertEquals("java.util.Collections$SynchronizedSortedSet",
- propertyClass.getName());
- assertSamePD(propertyClass);
- mockCollections.setProperty(Arrays
- .asList(new String[] { "A", "B", "C" }));
- assertCodedXML(mockCollections, "/xml/MockSynchronizedSortedSet.xml");
- }
-
- public static class MockSynchronizedMap {
-
- private Map<String, String> property = new HashMap<String, String>();
-
- public Map<String, String> getProperty() {
- return Collections.synchronizedMap(property);
- }
-
- public void setProperty(Map<String, String> prop) {
- property.clear();
- property.putAll(prop);
- }
- }
-
- public void testWriteObject_MockSynchronizedMap() throws Exception {
- MockSynchronizedMap mockCollections = new MockSynchronizedMap();
- Class<?> propertyClass = mockCollections.getProperty().getClass();
- assertEquals("java.util.Collections$SynchronizedMap",
- propertyClass.getName());
- assertSamePD(propertyClass);
- Map<String, String> prop = new HashMap<String, String>();
- prop.put("A", "a");
- prop.put("B", "b");
- prop.put("C", "c");
- mockCollections.setProperty(prop);
- assertCodedXML(mockCollections, "/xml/MockSynchronizedMap.xml");
- }
-
- public static class MockSynchronizedSortedMap {
-
- private SortedMap<String, String> property = new TreeMap<String, String>();
-
- public Map<String, String> getProperty() {
- return Collections.synchronizedSortedMap(property);
- }
-
- public void setProperty(Map<String, String> prop) {
- property.clear();
- property.putAll(prop);
- }
- }
-
- public void testWriteObject_MockSynchronizedSortedMap() throws Exception {
- MockSynchronizedSortedMap mockCollections = new MockSynchronizedSortedMap();
- Class<?> propertyClass = mockCollections.getProperty().getClass();
- assertEquals("java.util.Collections$SynchronizedSortedMap",
- propertyClass.getName());
- assertSamePD(propertyClass);
- Map<String, String> prop = new HashMap<String, String>();
- prop.put("A", "a");
- prop.put("B", "b");
- prop.put("C", "c");
- mockCollections.setProperty(prop);
- assertCodedXML(mockCollections, "/xml/MockSynchronizedSortedMap.xml");
- }
-
- public static class MockCheckedCollection {
-
- private Collection<String> property = new ArrayList<String>();
-
- public Collection<String> getProperty() {
- return Collections.checkedCollection(property, String.class);
- }
-
- public void setProperty(Collection<String> prop) {
- property.clear();
- property.addAll(prop);
- }
- }
-
- public void testWriteObject_MockCheckedCollection() throws Exception {
- MockCheckedCollection mockCollections = new MockCheckedCollection();
- Class<?> propertyClass = mockCollections.getProperty().getClass();
- assertEquals("java.util.Collections$CheckedCollection",
- propertyClass.getName());
- assertSamePD(propertyClass);
- mockCollections.setProperty(Arrays
- .asList(new String[] { "A", "B", "C" }));
- assertCodedXML(mockCollections, "/xml/MockCheckedCollection.xml");
- }
-
- public static class MockCheckedList {
-
- private List<String> property = new LinkedList<String>();
-
- public Collection<String> getProperty() {
- return Collections.checkedList(property, String.class);
- }
-
- public void setProperty(Collection<String> prop) {
- property.clear();
- property.addAll(prop);
- }
- }
-
- public void testWriteObject_MockCheckedList() throws Exception {
- MockCheckedList mockCollections = new MockCheckedList();
- Class<?> propertyClass = mockCollections.getProperty().getClass();
- assertEquals("java.util.Collections$CheckedList",
- propertyClass.getName());
- assertSamePD(propertyClass);
- mockCollections.setProperty(Arrays
- .asList(new String[] { "A", "B", "C" }));
- assertCodedXML(mockCollections, "/xml/MockCheckedList.xml");
- }
-
- public static class MockCheckedRandomAccessList {
-
- private List<String> property = new ArrayList<String>();
-
- public Collection<String> getProperty() {
- return Collections.checkedList(property, String.class);
- }
-
- public void setProperty(Collection<String> prop) {
- property.clear();
- property.addAll(prop);
- }
- }
-
- public void testWriteObject_MockCheckedRandomAccessList() throws Exception {
- MockCheckedRandomAccessList mockCollections = new MockCheckedRandomAccessList();
- Class<?> propertyClass = mockCollections.getProperty().getClass();
- assertEquals("java.util.Collections$CheckedRandomAccessList",
- propertyClass.getName());
- assertSamePD(propertyClass);
- mockCollections.setProperty(Arrays
- .asList(new String[] { "A", "B", "C" }));
- assertCodedXML(mockCollections, "/xml/MockCheckedRandomAccessList.xml");
- }
-
- public static class MockCheckedSet {
-
- private Set<String> property = new HashSet<String>();
-
- public Collection<String> getProperty() {
- return Collections.checkedSet(property, String.class);
- }
-
- public void setProperty(Collection<String> prop) {
- property.clear();
- property.addAll(prop);
- }
- }
-
- public void testWriteObject_MockCheckedSet() throws Exception {
- MockCheckedSet mockCollections = new MockCheckedSet();
- Class<?> propertyClass = mockCollections.getProperty().getClass();
- assertEquals("java.util.Collections$CheckedSet",
- propertyClass.getName());
- assertSamePD(propertyClass);
- mockCollections.setProperty(Arrays
- .asList(new String[] { "A", "B", "C" }));
- assertCodedXML(mockCollections, "/xml/MockCheckedSet.xml");
- }
-
- public static class MockCheckedSortedSet {
-
- private SortedSet<String> property = new TreeSet<String>();
-
- public Collection<String> getProperty() {
- return Collections.checkedSortedSet(property, String.class);
- }
-
- public void setProperty(Collection<String> prop) {
- property.clear();
- property.addAll(prop);
- }
- }
-
- public void testWriteObject_MockCheckedSortedSet() throws Exception {
- MockCheckedSortedSet mockCollections = new MockCheckedSortedSet();
- Class<?> propertyClass = mockCollections.getProperty().getClass();
- assertEquals("java.util.Collections$CheckedSortedSet",
- propertyClass.getName());
- assertSamePD(propertyClass);
- mockCollections.setProperty(Arrays
- .asList(new String[] { "A", "B", "C" }));
- assertCodedXML(mockCollections, "/xml/MockCheckedSortedSet.xml");
- }
-
- public static class MockCheckedMap {
-
- private Map<String, String> property = new HashMap<String, String>();
-
- public Map<String, String> getProperty() {
- return Collections.checkedMap(property, String.class, String.class);
- }
-
- public void setProperty(Map<String, String> prop) {
- property.clear();
- property.putAll(prop);
- }
- }
-
- public void testWriteObject_MockCheckedMap() throws Exception {
- MockCheckedMap mockCollections = new MockCheckedMap();
- Class<?> propertyClass = mockCollections.getProperty().getClass();
- assertEquals("java.util.Collections$CheckedMap",
- propertyClass.getName());
- assertSamePD(propertyClass);
- Map<String, String> prop = new HashMap<String, String>();
- prop.put("A", "a");
- prop.put("B", "b");
- prop.put("C", "c");
- mockCollections.setProperty(prop);
- assertCodedXML(mockCollections, "/xml/MockCheckedMap.xml");
- }
-
- public static class MockCheckedSortedMap {
-
- private SortedMap<String, String> property = new TreeMap<String, String>();
-
- public Map<String, String> getProperty() {
- return Collections.checkedSortedMap(property, String.class,
- String.class);
- }
-
- public void setProperty(Map<String, String> prop) {
- property.clear();
- property.putAll(prop);
- }
- }
-
- public void testWriteObject_MockCheckedSortedMap() throws Exception {
- MockCheckedSortedMap mockCollections = new MockCheckedSortedMap();
- Class<?> propertyClass = mockCollections.getProperty().getClass();
- assertEquals("java.util.Collections$CheckedSortedMap",
- propertyClass.getName());
- assertSamePD(propertyClass);
- Map<String, String> prop = new HashMap<String, String>();
- prop.put("A", "a");
- prop.put("B", "b");
- prop.put("C", "c");
- mockCollections.setProperty(prop);
- assertCodedXML(mockCollections, "/xml/MockCheckedSortedMap.xml");
- }
-
- public static class MockGetPropertyClass {
-
- private Set<String> property = new HashSet<String>();
-
- public Set<String> getProperty() {
- return new HashSet<String>(property);
- }
-
- public void setProperty(Set<String> set) {
- property.clear();
- property.addAll(set);
- }
- }
-
- public void testWriteObject_MockGetPropertyClass() throws Exception {
- MockGetPropertyClass mockCollections = new MockGetPropertyClass();
- assertSamePD(mockCollections.getProperty().getClass());
- Set<String> prop = new HashSet<String>();
- prop.add("A");
- prop.add("B");
- prop.add("C");
- mockCollections.setProperty(prop);
- assertCodedXML(mockCollections, "/xml/MockGetPropertyClass.xml");
- }
-
- public static class MockListImplements implements List<String> {
-
- private List<String> property = new ArrayList<String>();
-
- public List<String> getProperty() {
- return property;
- }
-
- public void setProperty(List<String> prop) {
- property = prop;
- }
-
- public boolean add(String o) {
- return property.add(o);
- }
-
- public void add(int index, String o) {
- property.add(index, o);
- }
-
- public boolean addAll(Collection<? extends String> c) {
- return property.addAll(c);
- }
-
- public boolean addAll(int index, Collection<? extends String> c) {
- return property.addAll(index, c);
- }
-
- public void clear() {
- property.clear();
- }
-
- public boolean contains(Object o) {
- return property.contains(o);
- }
-
- public boolean containsAll(Collection<?> c) {
- return property.containsAll(c);
- }
-
- public String get(int index) {
- return property.get(index);
- }
-
- public int indexOf(Object o) {
- return property.indexOf(o);
- }
-
- public boolean isEmpty() {
- return property.isEmpty();
- }
-
- public Iterator<String> iterator() {
- return property.iterator();
- }
-
- public int lastIndexOf(Object o) {
- return property.lastIndexOf(o);
- }
-
- public ListIterator<String> listIterator() {
- return property.listIterator();
- }
-
- public ListIterator<String> listIterator(int index) {
- return property.listIterator(index);
- }
-
- public boolean remove(Object o) {
- return property.remove(o);
- }
-
- public String remove(int index) {
- return property.remove(index);
- }
-
- public boolean removeAll(Collection<?> c) {
- return property.removeAll(c);
- }
-
- public boolean retainAll(Collection<?> c) {
- return property.retainAll(c);
- }
-
- public String set(int index, String o) {
- return property.set(index, o);
- }
-
- public int size() {
- return property.size();
- }
-
- public List<String> subList(int fromIndex, int toIndex) {
- return property.subList(fromIndex, toIndex);
- }
-
- public Object[] toArray() {
- return property.toArray();
- }
-
- public <T> T[] toArray(T[] a) {
- return property.toArray(a);
- }
- }
-
- public void testWriteObject_MockListImplements() throws Exception {
- List<String> mockListImplements = new MockListImplements();
- mockListImplements.add("A");
- assertCodedXML(mockListImplements, "/xml/MockListImplements.xml");
- }
-
- public static class MockSetImplements implements Set<String> {
-
- private Set<String> property;
-
- public MockSetImplements() {
- property = new HashSet<String>();
- }
-
- public Set<String> getProperty() {
- return property;
- }
-
- public void setProperty(Set<String> prop) {
- property = prop;
- }
-
- public boolean add(String o) {
- return property.add(o);
- }
-
- public void clear() {
- property.clear();
- }
-
- public boolean contains(final Object o) {
- return property.contains(o);
- }
-
- public boolean containsAll(final Collection<?> c) {
- return property.containsAll(c);
- }
-
- public boolean isEmpty() {
- return property.isEmpty();
- }
-
- public Iterator<String> iterator() {
- return property.iterator();
- }
-
- public boolean remove(final Object o) {
- return property.remove(o);
- }
-
- public boolean removeAll(final Collection<?> c) {
- return property.removeAll(c);
- }
-
- public boolean retainAll(final Collection<?> c) {
- return property.retainAll(c);
- }
-
- public int size() {
- return property.size();
- }
-
- public Object[] toArray() {
- return property.toArray();
- }
-
- public <T> T[] toArray(final T[] a) {
- return property.toArray(a);
- }
-
- public int hashCode() {
- return property.hashCode();
- }
-
- public boolean addAll(Collection<? extends String> c) {
- return property.addAll(c);
- }
- }
-
- public void testWriteObject_MockSetImplements() throws Exception {
- Set<String> mockSetImplements = new MockSetImplements();
- mockSetImplements.add("A");
- assertCodedXML(mockSetImplements, "/xml/MockSetImplements.xml");
- }
-
- private Encoder encoder = new Encoder();
-
- private void assertSamePD(Class<?> clazz) {
- assertSame(encoder.getPersistenceDelegate(clazz),
- encoder.getPersistenceDelegate(clazz));
- }
-
-} \ No newline at end of file
diff --git a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextChildSupportTest.java b/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextChildSupportTest.java
deleted file mode 100644
index a77cb6a..0000000
--- a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextChildSupportTest.java
+++ /dev/null
@@ -1,1005 +0,0 @@
-/*
- * 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.java.beans.beancontext;
-
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyChangeSupport;
-import java.beans.PropertyVetoException;
-import java.beans.VetoableChangeListener;
-import java.beans.VetoableChangeSupport;
-import java.beans.beancontext.BeanContext;
-import java.beans.beancontext.BeanContextChild;
-import java.beans.beancontext.BeanContextChildSupport;
-import java.beans.beancontext.BeanContextMembershipEvent;
-import java.beans.beancontext.BeanContextSupport;
-import java.io.IOException;
-import java.io.Serializable;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.apache.harmony.beans.tests.support.beancontext.Utils;
-import org.apache.harmony.beans.tests.support.beancontext.mock.MockBeanContext;
-import org.apache.harmony.beans.tests.support.beancontext.mock.MockBeanContextChild;
-import org.apache.harmony.beans.tests.support.beancontext.mock.MockBeanContextChildDelegateS;
-import org.apache.harmony.beans.tests.support.beancontext.mock.MockPropertyChangeListener;
-import org.apache.harmony.beans.tests.support.beancontext.mock.MockPropertyChangeListenerS;
-import org.apache.harmony.beans.tests.support.beancontext.mock.MockVetoChangeListener;
-import org.apache.harmony.beans.tests.support.beancontext.mock.MockVetoableChangeListener;
-import org.apache.harmony.beans.tests.support.beancontext.mock.MockVetoableChangeListenerS;
-import org.apache.harmony.testframework.serialization.SerializationTest;
-import org.apache.harmony.testframework.serialization.SerializationTest.SerializableAssert;
-
-import tests.util.SerializationTester;
-
-/**
- * Test BeanContextChildSupport
- */
-public class BeanContextChildSupportTest extends TestCase {
-
- private static class MockBeanContextChildSupport extends
- BeanContextChildSupport {
-
- private static final long serialVersionUID = -8602521752077435319L;
-
- public BeanContext lastInitBeanContext = null;
-
- public BeanContext lastReleaseBeanContext = null;
-
- public boolean vetoBeanContext = false;
-
- /**
- *
- */
- public MockBeanContextChildSupport() {
- super();
- assertNull(this.beanContext);
- assertSame(this, this.beanContextChildPeer);
- assertFalse(this.rejectedSetBCOnce);
- }
-
- /**
- * @param bcc
- */
- public MockBeanContextChildSupport(BeanContextChild bcc) {
- super(bcc);
- assertNull(this.beanContext);
- assertSame(bcc, this.beanContextChildPeer);
- assertFalse(this.rejectedSetBCOnce);
- }
-
- public boolean rejectedSetBCOnce() {
- return rejectedSetBCOnce;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.beancontext.BeanContextChildSupport#initializeBeanContextResources()
- */
- @Override
- protected void initializeBeanContextResources() {
- lastInitBeanContext = this.beanContext;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.beancontext.BeanContextChildSupport#releaseBeanContextResources()
- */
- @Override
- protected void releaseBeanContextResources() {
- lastReleaseBeanContext = this.beanContext;
- }
-
- public void clearLastRecords() {
- lastInitBeanContext = null;
- lastReleaseBeanContext = null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.beancontext.BeanContextChildSupport#validatePendingSetBeanContext(java.beans.beancontext.BeanContext)
- */
- @Override
- public boolean validatePendingSetBeanContext(BeanContext newValue) {
- if (vetoBeanContext) {
- return false;
- }
- return super.validatePendingSetBeanContext(newValue);
- }
- }
-
- public void testAddPropertyChangeListener_NullParam() {
- BeanContextChildSupport support = new MockBeanContextChildSupport();
- support.addPropertyChangeListener(null, new MockPropertyChangeListener());
- support.addPropertyChangeListener("property name", null);
- support.firePropertyChange("property name", "old value",
- "new value");
- }
-
- public void testAddPropertyChangeListener() {
- BeanContextChildSupport support = new MockBeanContextChildSupport();
- MockPropertyChangeListener l1 = new MockPropertyChangeListener();
- MockPropertyChangeListener l2 = new MockPropertyChangeListener();
- String propName = "property name";
- Object oldValue = new Integer(1);
- Object newValue = new Integer(5);
-
- l1.clearLastEvent();
- l2.clearLastEvent();
- support.firePropertyChange(propName, oldValue, newValue);
- assertNull(l1.lastEvent);
- assertNull(l2.lastEvent);
-
- support.addPropertyChangeListener(propName, l1);
- l1.clearLastEvent();
- l2.clearLastEvent();
- support.firePropertyChange(propName, oldValue, newValue);
- assertEquals(propName, l1.lastEvent.getPropertyName());
- assertSame(oldValue, l1.lastEvent.getOldValue());
- assertSame(newValue, l1.lastEvent.getNewValue());
- assertSame(support, l1.lastEvent.getSource());
- assertNull(l2.lastEvent);
-
- support.addPropertyChangeListener(propName, l2);
- l1.clearLastEvent();
- l2.clearLastEvent();
- support.firePropertyChange(propName, oldValue, newValue);
- assertEquals(propName, l1.lastEvent.getPropertyName());
- assertSame(oldValue, l1.lastEvent.getOldValue());
- assertSame(newValue, l1.lastEvent.getNewValue());
- assertSame(support, l1.lastEvent.getSource());
- assertEquals(propName, l2.lastEvent.getPropertyName());
- assertSame(oldValue, l2.lastEvent.getOldValue());
- assertSame(newValue, l2.lastEvent.getNewValue());
- assertSame(support, l2.lastEvent.getSource());
-
- l1.clearLastEvent();
- l2.clearLastEvent();
- support.firePropertyChange("xxx", oldValue, newValue);
- assertNull(l1.lastEvent);
- assertNull(l2.lastEvent);
- }
-
- public void testAddVetoableChangeListener_NullParam()
- throws PropertyVetoException {
- BeanContextChildSupport support = new MockBeanContextChildSupport();
- support.addVetoableChangeListener(null,
- new MockVetoableChangeListener());
- support.addVetoableChangeListener("property name", null);
- support.fireVetoableChange("property name", "old value", "new value");
- }
-
- public void testAddVetoableChangeListener() throws PropertyVetoException {
- BeanContextChildSupport support = new MockBeanContextChildSupport();
- MockVetoableChangeListener l1 = new MockVetoableChangeListener();
- MockVetoableChangeListener l2 = new MockVetoableChangeListener();
- String propName = "property name";
- Object oldValue = new Integer(1);
- Object newValue = new Integer(5);
-
- l1.clearLastEvent();
- l2.clearLastEvent();
- support.fireVetoableChange(propName, oldValue, newValue);
- assertNull(l1.lastEvent);
- assertNull(l2.lastEvent);
-
- support.addVetoableChangeListener(propName, l1);
- l1.clearLastEvent();
- l2.clearLastEvent();
- support.fireVetoableChange(propName, oldValue, newValue);
- assertEquals(propName, l1.lastEvent.getPropertyName());
- assertSame(oldValue, l1.lastEvent.getOldValue());
- assertSame(newValue, l1.lastEvent.getNewValue());
- assertSame(support, l1.lastEvent.getSource());
- assertNull(l2.lastEvent);
-
- support.addVetoableChangeListener(propName, l2);
- l1.clearLastEvent();
- l2.clearLastEvent();
- support.fireVetoableChange(propName, oldValue, newValue);
- assertEquals(propName, l1.lastEvent.getPropertyName());
- assertSame(oldValue, l1.lastEvent.getOldValue());
- assertSame(newValue, l1.lastEvent.getNewValue());
- assertSame(support, l1.lastEvent.getSource());
- assertEquals(propName, l2.lastEvent.getPropertyName());
- assertSame(oldValue, l2.lastEvent.getOldValue());
- assertSame(newValue, l2.lastEvent.getNewValue());
- assertSame(support, l2.lastEvent.getSource());
-
- l1.clearLastEvent();
- l2.clearLastEvent();
- support.fireVetoableChange("xxx", oldValue, newValue);
- assertNull(l1.lastEvent);
- assertNull(l2.lastEvent);
- }
-
- /*
- * Class under test for void BeanContextChildSupport()
- */
- public void testBeanContextChildSupport() {
- BeanContextChildSupport support = new MockBeanContextChildSupport();
- assertSame(support, support.getBeanContextChildPeer());
- assertSame(support, support.beanContextChildPeer);
- }
-
- /*
- * Class under test for void
- * BeanContextChildSupport(java.beans.beancontext.BeanContextChild)
- */
- public void testBeanContextChildSupportBeanContextChild() {
- BeanContextChild c = new MockBeanContextChild();
- BeanContextChildSupport support = new MockBeanContextChildSupport(c);
- assertSame(c, support.getBeanContextChildPeer());
- assertSame(c, support.beanContextChildPeer);
- }
-
- public void testFirePropertyChange_NullParam() {
- BeanContextChildSupport support = new MockBeanContextChildSupport();
- support.firePropertyChange(null, "a", "b");
- }
-
- public void testFirePropertyChange() {
- BeanContextChildSupport support = new MockBeanContextChildSupport();
- MockPropertyChangeListener l1 = new MockPropertyChangeListener();
- MockPropertyChangeListener l2 = new MockPropertyChangeListener();
- String propName = "property name";
- Object oldValue = new Integer(1);
- Object newValue = new Integer(5);
-
- support.addPropertyChangeListener(propName, l1);
- support.addPropertyChangeListener("xxx", l2);
- l1.clearLastEvent();
- l2.clearLastEvent();
- support.firePropertyChange(propName, oldValue, newValue);
- assertEquals(propName, l1.lastEvent.getPropertyName());
- assertSame(oldValue, l1.lastEvent.getOldValue());
- assertSame(newValue, l1.lastEvent.getNewValue());
- assertSame(support, l1.lastEvent.getSource());
- assertNull(l2.lastEvent);
- }
-
- public void testFirePropertyChange_OldEqualsNew() {
- BeanContextChildSupport support = new MockBeanContextChildSupport();
- MockPropertyChangeListener l1 = new MockPropertyChangeListener();
- MockPropertyChangeListener l2 = new MockPropertyChangeListener();
- String propName = "property name";
- Object oldValue = new Integer(1);
- Object newValue = new Integer(1);
-
- support.addPropertyChangeListener(propName, l1);
- support.addPropertyChangeListener("xxx", l2);
- l1.clearLastEvent();
- l2.clearLastEvent();
- support.firePropertyChange(propName, oldValue, newValue);
- assertNull(l1.lastEvent);
- assertNull(l2.lastEvent);
- }
-
- public void testFirePropertyChange_OldEqualsNew_IsNull() {
- BeanContextChildSupport support = new MockBeanContextChildSupport();
- MockPropertyChangeListener l1 = new MockPropertyChangeListener();
- MockPropertyChangeListener l2 = new MockPropertyChangeListener();
- String propName = "property name";
- Object oldValue = null;
- Object newValue = null;
-
- support.addPropertyChangeListener(propName, l1);
- support.addPropertyChangeListener("xxx", l2);
- l1.clearLastEvent();
- l2.clearLastEvent();
- support.firePropertyChange(propName, oldValue, newValue);
- assertEquals(propName, l1.lastEvent.getPropertyName());
- assertNull(l1.lastEvent.getOldValue());
- assertNull(l1.lastEvent.getNewValue());
- assertSame(support, l1.lastEvent.getSource());
- assertNull(l2.lastEvent);
- }
-
- public void testFireVetoableChange_NullParam() throws PropertyVetoException {
- BeanContextChildSupport support = new MockBeanContextChildSupport();
- support.fireVetoableChange(null, "a", "b");
- }
-
- public void testFireVetoableChange() throws PropertyVetoException {
- BeanContextChildSupport support = new MockBeanContextChildSupport();
- MockVetoableChangeListener l1 = new MockVetoableChangeListener();
- MockVetoableChangeListener l2 = new MockVetoableChangeListener();
- String propName = "property name";
- Object oldValue = new Integer(1);
- Object newValue = new Integer(5);
-
- support.addVetoableChangeListener(propName, l1);
- support.addVetoableChangeListener("xxx", l2);
- l1.clearLastEvent();
- l2.clearLastEvent();
- support.fireVetoableChange(propName, oldValue, newValue);
- assertEquals(propName, l1.lastEvent.getPropertyName());
- assertSame(oldValue, l1.lastEvent.getOldValue());
- assertSame(newValue, l1.lastEvent.getNewValue());
- assertSame(support, l1.lastEvent.getSource());
- assertNull(l2.lastEvent);
- }
-
- public void testFireVetoableChange_Vetoed() {
- BeanContextChildSupport support = new MockBeanContextChildSupport();
- MockVetoableChangeListener l1 = new MockVetoableChangeListener();
- MockVetoableChangeListener l2 = new MockVetoableChangeListener();
- MockVetoChangeListener l3 = new MockVetoChangeListener();
- String propName = "property name";
- Object oldValue = new Integer(1);
- Object newValue = new Integer(5);
-
- support.addVetoableChangeListener(propName, l1);
- support.addVetoableChangeListener(propName, l2);
- support.addVetoableChangeListener(propName, l3);
- l1.clearLastEvent();
- l2.clearLastEvent();
- l3.clearLastEvent();
- try {
- support.fireVetoableChange(propName, oldValue, newValue);
- fail();
- } catch (PropertyVetoException e) {
- // expected
- }
- assertEquals(propName, l1.lastEvent.getPropertyName());
- assertSame(newValue, l1.lastEvent.getOldValue());
- assertSame(oldValue, l1.lastEvent.getNewValue());
- assertSame(support, l1.lastEvent.getSource());
- assertEquals(propName, l2.lastEvent.getPropertyName());
- assertSame(newValue, l2.lastEvent.getOldValue());
- assertSame(oldValue, l2.lastEvent.getNewValue());
- assertSame(support, l2.lastEvent.getSource());
- assertEquals(propName, l3.lastEvent.getPropertyName());
- assertSame(newValue, l3.lastEvent.getOldValue());
- assertSame(oldValue, l3.lastEvent.getNewValue());
- assertSame(support, l3.lastEvent.getSource());
- }
-
- public void testFireVetoableChange_OldEqualsNew()
- throws PropertyVetoException {
- BeanContextChildSupport support = new MockBeanContextChildSupport();
- MockVetoableChangeListener l1 = new MockVetoableChangeListener();
- MockVetoableChangeListener l2 = new MockVetoableChangeListener();
- String propName = "property name";
- Object oldValue = new Integer(1);
- Object newValue = new Integer(1);
-
- support.addVetoableChangeListener(propName, l1);
- support.addVetoableChangeListener("xxx", l2);
- l1.clearLastEvent();
- l2.clearLastEvent();
- support.fireVetoableChange(propName, oldValue, newValue);
- assertNull(l1.lastEvent);
- assertNull(l2.lastEvent);
- }
-
- public void testFireVetoableChange_OldEqualsNew_IsNull()
- throws PropertyVetoException {
- BeanContextChildSupport support = new MockBeanContextChildSupport();
- MockVetoableChangeListener l1 = new MockVetoableChangeListener();
- MockVetoableChangeListener l2 = new MockVetoableChangeListener();
- String propName = "property name";
- Object oldValue = null;
- Object newValue = null;
-
- support.addVetoableChangeListener(propName, l1);
- support.addVetoableChangeListener("xxx", l2);
- l1.clearLastEvent();
- l2.clearLastEvent();
- support.fireVetoableChange(propName, oldValue, newValue);
- assertEquals(propName, l1.lastEvent.getPropertyName());
- assertNull(l1.lastEvent.getOldValue());
- assertNull(l1.lastEvent.getNewValue());
- assertSame(support, l1.lastEvent.getSource());
- assertNull(l2.lastEvent);
- }
-
- public void testGetBeanContext() throws PropertyVetoException {
- BeanContextChildSupport support = new MockBeanContextChildSupport();
- MockBeanContext mockBeanContext = new MockBeanContext();
- assertNull(support.getBeanContext());
- support.setBeanContext(mockBeanContext);
- assertSame(mockBeanContext, support.getBeanContext());
- }
-
- public void testGetBeanContextChildPeer() throws Exception {
- BeanContextChildSupport support = new MockBeanContextChildSupport();
- assertSame(support, support.beanContextChildPeer);
- assertSame(support, support.getBeanContextChildPeer());
-
- BeanContextChild mockChild = new MockBeanContextChild();
- support = new MockBeanContextChildSupport(mockChild);
- assertSame(mockChild, support.beanContextChildPeer);
- assertSame(mockChild, support.getBeanContextChildPeer());
-
- BeanContextChildSupport sup = new BeanContextChildSupport();
-
- assertEquals(sup, sup.getBeanContextChildPeer());
- }
-
- public void testInitializeBeanContextResources()
- throws PropertyVetoException {
- MockBeanContextChildSupport support = new MockBeanContextChildSupport();
- assertNull(support.lastInitBeanContext);
- assertNull(support.lastReleaseBeanContext);
- MockBeanContext ctx1 = new MockBeanContext();
- MockBeanContext ctx2 = new MockBeanContext();
-
- support.clearLastRecords();
- support.setBeanContext(ctx1);
- assertSame(ctx1, support.lastInitBeanContext);
- assertNull(support.lastReleaseBeanContext);
-
- support.clearLastRecords();
- support.setBeanContext(ctx1);
- assertNull(support.lastInitBeanContext);
- assertNull(support.lastReleaseBeanContext);
-
- support.clearLastRecords();
- support.setBeanContext(ctx2);
- assertSame(ctx2, support.lastInitBeanContext);
- assertSame(ctx1, support.lastReleaseBeanContext);
-
- support.clearLastRecords();
- support.setBeanContext(null);
- assertNull(support.lastInitBeanContext);
- assertSame(ctx2, support.lastReleaseBeanContext);
- }
-
- public void testIsDelegated() throws Exception {
- BeanContextChildSupport support = new MockBeanContextChildSupport();
- assertFalse(support.isDelegated());
-
- BeanContextChild mockChild = new MockBeanContextChild();
- support = new MockBeanContextChildSupport(mockChild);
- assertTrue(support.isDelegated());
-
- support.beanContextChildPeer = support;
- assertFalse(support.isDelegated());
-
- BeanContextChildSupport sup = new BeanContextChildSupport();
-
- assertFalse("Child is not supposed to be delegated", sup.isDelegated());
- }
-
- public void testReleaseBeanContextResources() throws PropertyVetoException {
- MockBeanContextChildSupport support = new MockBeanContextChildSupport();
- assertNull(support.lastInitBeanContext);
- assertNull(support.lastReleaseBeanContext);
- MockBeanContext ctx1 = new MockBeanContext();
- MockBeanContext ctx2 = new MockBeanContext();
-
- support.clearLastRecords();
- support.setBeanContext(ctx1);
- assertSame(ctx1, support.lastInitBeanContext);
- assertNull(support.lastReleaseBeanContext);
-
- support.clearLastRecords();
- support.setBeanContext(ctx1);
- assertNull(support.lastInitBeanContext);
- assertNull(support.lastReleaseBeanContext);
-
- support.clearLastRecords();
- support.setBeanContext(ctx2);
- assertSame(ctx2, support.lastInitBeanContext);
- assertSame(ctx1, support.lastReleaseBeanContext);
-
- support.clearLastRecords();
- support.setBeanContext(null);
- assertNull(support.lastInitBeanContext);
- assertSame(ctx2, support.lastReleaseBeanContext);
- }
-
- public void testRemovePropertyChangeListener_NullParam() {
- BeanContextChildSupport support = new MockBeanContextChildSupport();
- support.removePropertyChangeListener("property name", null);
- }
-
- public void testRemovePropertyChangeListener() {
- BeanContextChildSupport support = new MockBeanContextChildSupport();
- MockPropertyChangeListener l1 = new MockPropertyChangeListener();
- MockPropertyChangeListener l2 = new MockPropertyChangeListener();
- String propName = "property name";
- Object oldValue = new Integer(1);
- Object newValue = new Integer(5);
-
- support.addPropertyChangeListener(propName, l1);
- support.addPropertyChangeListener(propName, l2);
- l1.clearLastEvent();
- l2.clearLastEvent();
- support.firePropertyChange(propName, oldValue, newValue);
- assertEquals(propName, l1.lastEvent.getPropertyName());
- assertSame(oldValue, l1.lastEvent.getOldValue());
- assertSame(newValue, l1.lastEvent.getNewValue());
- assertSame(support, l1.lastEvent.getSource());
- assertEquals(propName, l2.lastEvent.getPropertyName());
- assertSame(oldValue, l2.lastEvent.getOldValue());
- assertSame(newValue, l2.lastEvent.getNewValue());
- assertSame(support, l2.lastEvent.getSource());
-
- support.removePropertyChangeListener(propName, l1);
- l1.clearLastEvent();
- l2.clearLastEvent();
- support.firePropertyChange(propName, oldValue, newValue);
- assertNull(l1.lastEvent);
- assertEquals(propName, l2.lastEvent.getPropertyName());
- assertSame(oldValue, l2.lastEvent.getOldValue());
- assertSame(newValue, l2.lastEvent.getNewValue());
- assertSame(support, l2.lastEvent.getSource());
-
- support.removePropertyChangeListener(propName, l2);
- l1.clearLastEvent();
- l2.clearLastEvent();
- support.firePropertyChange(propName, oldValue, newValue);
- assertNull(l1.lastEvent);
- assertNull(l2.lastEvent);
-
- // remove not-registered listener
- support.removePropertyChangeListener(propName, l1);
- }
-
- public void testRemoveVetoableChangeListener_NullParam() {
- BeanContextChildSupport support = new MockBeanContextChildSupport();
- support.removeVetoableChangeListener("property name", null);
- }
-
- public void testRemoveVetoableChangeListener() throws PropertyVetoException {
- BeanContextChildSupport support = new MockBeanContextChildSupport();
- MockVetoableChangeListener l1 = new MockVetoableChangeListener();
- MockVetoableChangeListener l2 = new MockVetoableChangeListener();
- String propName = "property name";
- Object oldValue = new Integer(1);
- Object newValue = new Integer(5);
-
- support.addVetoableChangeListener(propName, l1);
- support.addVetoableChangeListener(propName, l2);
- l1.clearLastEvent();
- l2.clearLastEvent();
- support.fireVetoableChange(propName, oldValue, newValue);
- assertEquals(propName, l1.lastEvent.getPropertyName());
- assertSame(oldValue, l1.lastEvent.getOldValue());
- assertSame(newValue, l1.lastEvent.getNewValue());
- assertSame(support, l1.lastEvent.getSource());
- assertEquals(propName, l2.lastEvent.getPropertyName());
- assertSame(oldValue, l2.lastEvent.getOldValue());
- assertSame(newValue, l2.lastEvent.getNewValue());
- assertSame(support, l2.lastEvent.getSource());
-
- support.removeVetoableChangeListener(propName, l1);
- l1.clearLastEvent();
- l2.clearLastEvent();
- support.fireVetoableChange(propName, oldValue, newValue);
- assertNull(l1.lastEvent);
- assertEquals(l2.lastEvent.getPropertyName(), propName);
- assertSame(l2.lastEvent.getOldValue(), oldValue);
- assertSame(l2.lastEvent.getNewValue(), newValue);
- assertSame(l2.lastEvent.getSource(), support);
-
- support.removeVetoableChangeListener(propName, l2);
- l1.clearLastEvent();
- l2.clearLastEvent();
- support.fireVetoableChange(propName, oldValue, newValue);
- assertNull(l1.lastEvent);
- assertNull(l2.lastEvent);
-
- // remove not-registered listener
- support.removeVetoableChangeListener(propName, l1);
- }
-
- public void testServiceAvailable() {
- // guess the impl is empty
- BeanContextChildSupport support = new MockBeanContextChildSupport();
- support.serviceAvailable(null);
-
- // Regression for HARMONY-372
- (new java.beans.beancontext.BeanContextChildSupport())
- .serviceAvailable(null);
- (new java.beans.beancontext.BeanContextChildSupport())
- .serviceRevoked(null);
- }
-
- public void testServiceRevoked() {
- // guess the impl is empty
- BeanContextChildSupport support = new MockBeanContextChildSupport();
- support.serviceRevoked(null);
- }
-
- public void testSetBeanContext() throws PropertyVetoException {
- BeanContextChild peer = new MockBeanContextChild();
- MockBeanContextChildSupport support = new MockBeanContextChildSupport(
- peer);
- MockPropertyChangeListener l1 = new MockPropertyChangeListener();
- MockVetoableChangeListener l2 = new MockVetoableChangeListener();
- support.addPropertyChangeListener("beanContext", l1);
- support.addVetoableChangeListener("beanContext", l2);
-
- MockBeanContext ctx = new MockBeanContext();
- assertNull(support.getBeanContext());
-
- support.clearLastRecords();
- l1.clearLastEvent();
- l2.clearLastEvent();
- support.setBeanContext(null);
- assertNull(support.getBeanContext());
- assertNull(support.lastInitBeanContext);
- assertNull(l1.lastEvent);
- assertNull(l2.lastEvent);
-
- support.clearLastRecords();
- l1.clearLastEvent();
- l2.clearLastEvent();
- support.setBeanContext(ctx);
- assertSame(ctx, support.getBeanContext());
- assertSame(ctx, support.lastInitBeanContext);
- assertEquals("beanContext", l1.lastEvent.getPropertyName());
- assertNull(l1.lastEvent.getOldValue());
- assertSame(ctx, l1.lastEvent.getNewValue());
- assertSame(peer, l1.lastEvent.getSource());
- assertEquals("beanContext", l2.lastEvent.getPropertyName());
- assertNull(l2.lastEvent.getOldValue());
- assertSame(ctx, l2.lastEvent.getNewValue());
- assertSame(peer, l2.lastEvent.getSource());
-
- support.clearLastRecords();
- l1.clearLastEvent();
- l2.clearLastEvent();
- support.setBeanContext(ctx);
- assertSame(ctx, support.getBeanContext());
- assertNull(support.lastInitBeanContext);
- assertNull(l1.lastEvent);
- assertNull(l2.lastEvent);
-
- support.clearLastRecords();
- l1.clearLastEvent();
- l2.clearLastEvent();
- support.setBeanContext(null);
- assertNull(support.getBeanContext());
- assertNull(support.lastInitBeanContext);
- assertSame(ctx, support.lastReleaseBeanContext);
- assertEquals("beanContext", l1.lastEvent.getPropertyName());
- assertNull(l1.lastEvent.getNewValue());
- assertSame(ctx, l1.lastEvent.getOldValue());
- assertSame(peer, l1.lastEvent.getSource());
- assertEquals("beanContext", l2.lastEvent.getPropertyName());
- assertNull(l2.lastEvent.getNewValue());
- assertSame(ctx, l2.lastEvent.getOldValue());
- assertSame(peer, l2.lastEvent.getSource());
- }
-
- public void testSetBeanContext_VetoedByListener()
- throws PropertyVetoException {
- MockBeanContextChildSupport support = new MockBeanContextChildSupport();
- MockBeanContext oldCtx = new MockBeanContext();
- support.setBeanContext(oldCtx);
- MockPropertyChangeListener l1 = new MockPropertyChangeListener();
- MockVetoChangeListener l2 = new MockVetoChangeListener();
- support.addPropertyChangeListener("beanContext", l1);
- support.addVetoableChangeListener("beanContext", l2);
-
- MockBeanContext ctx = new MockBeanContext();
-
- support.clearLastRecords();
- l1.clearLastEvent();
- l2.clearLastEvent();
- try {
- support.setBeanContext(ctx);
- fail();
- } catch (PropertyVetoException e) {
- // expected
- }
- assertSame(oldCtx, support.getBeanContext());
- assertNull(support.lastInitBeanContext);
- assertNull(support.lastReleaseBeanContext);
- assertNull(l1.lastEvent);
- assertEquals("beanContext", l2.lastEvent.getPropertyName());
- assertSame(oldCtx, l2.lastEvent.getNewValue());
- assertSame(ctx, l2.lastEvent.getOldValue());
- assertSame(support, l2.lastEvent.getSource());
- assertTrue(support.rejectedSetBCOnce());
- }
-
- public void testSetBeanContext_VetoedByValidateMethod() {
- MockBeanContextChildSupport support = new MockBeanContextChildSupport();
- support.vetoBeanContext = true;
- MockPropertyChangeListener l1 = new MockPropertyChangeListener();
- MockVetoableChangeListener l2 = new MockVetoableChangeListener();
- support.addPropertyChangeListener("beanContext", l1);
- support.addVetoableChangeListener("beanContext", l2);
-
- MockBeanContext ctx = new MockBeanContext();
- assertNull(support.getBeanContext());
-
- support.clearLastRecords();
- l1.clearLastEvent();
- l2.clearLastEvent();
- try {
- support.setBeanContext(ctx);
- fail();
- } catch (PropertyVetoException e) {
- // expected
- }
- assertNull(support.getBeanContext());
- assertNull(support.lastInitBeanContext);
- assertNull(l1.lastEvent);
- assertNull(l2.lastEvent);
- assertTrue(support.rejectedSetBCOnce());
- }
-
- public void testValidatePendingSetBeanContext() {
- // guess the impl always returns true
- BeanContextChildSupport support = new MockBeanContextChildSupport();
- assertTrue(support.validatePendingSetBeanContext(new MockBeanContext()));
- assertTrue(support.validatePendingSetBeanContext(null));
- }
-
- public void testSerialization_NoPeer() throws IOException,
- ClassNotFoundException {
- BeanContextChildSupport support = new BeanContextChildSupport();
- MockPropertyChangeListener pcl1 = new MockPropertyChangeListener();
- MockPropertyChangeListenerS pcl2 = new MockPropertyChangeListenerS(
- "id of pcl2");
- MockVetoableChangeListener vcl1 = new MockVetoableChangeListener();
- MockVetoableChangeListenerS vcl2 = new MockVetoableChangeListenerS(
- "id of vcl2");
- support.addPropertyChangeListener("beanContext", pcl1);
- support.addPropertyChangeListener("beanContext", pcl2);
- support.addVetoableChangeListener("beanContext", vcl1);
- support.addVetoableChangeListener("beanContext", vcl2);
-
- assertEqualsSerially(support,
- (BeanContextChildSupport) SerializationTester
- .getDeserilizedObject(support));
- }
-
- public void testSerialization_WithNonSerializablePeer() throws IOException,
- ClassNotFoundException {
- MockBeanContextChild peer = new MockBeanContextChild();
- BeanContextChildSupport support = new BeanContextChildSupport(peer);
- MockPropertyChangeListener pcl1 = new MockPropertyChangeListener();
- MockPropertyChangeListenerS pcl2 = new MockPropertyChangeListenerS(
- "id of pcl2");
- MockVetoableChangeListener vcl1 = new MockVetoableChangeListener();
- MockVetoableChangeListenerS vcl2 = new MockVetoableChangeListenerS(
- "id of vcl2");
- support.addPropertyChangeListener("beanContext", pcl1);
- support.addPropertyChangeListener("beanContext", pcl2);
- support.addVetoableChangeListener("beanContext", vcl1);
- support.addVetoableChangeListener("beanContext", vcl2);
-
- try {
- SerializationTester.getDeserilizedObject(support);
- fail();
- } catch (IOException e) {
- // expected
- }
- }
-
- public void testSerialization_WithPeer() throws IOException,
- ClassNotFoundException {
- MockBeanContextChildDelegateS peer = new MockBeanContextChildDelegateS(
- "id of peer");
- BeanContextChildSupport support = peer.support;
- MockPropertyChangeListener pcl1 = new MockPropertyChangeListener();
- MockPropertyChangeListenerS pcl2 = new MockPropertyChangeListenerS(
- "id of pcl2");
- MockVetoableChangeListener vcl1 = new MockVetoableChangeListener();
- MockVetoableChangeListenerS vcl2 = new MockVetoableChangeListenerS(
- "id of vcl2");
- support.addPropertyChangeListener("beanContext", pcl1);
- support.addPropertyChangeListener("beanContext", pcl2);
- support.addVetoableChangeListener("beanContext", vcl1);
- support.addVetoableChangeListener("beanContext", vcl2);
-
- assertEqualsSerially(support,
- (BeanContextChildSupport) SerializationTester
- .getDeserilizedObject(support));
- }
-
- public void testSerialization_Compatibility() throws IOException,
- ClassNotFoundException, Exception {
- MockBeanContextChildDelegateS peer = new MockBeanContextChildDelegateS(
- "id of peer");
- BeanContextChildSupport support = peer.support;
- MockPropertyChangeListener pcl1 = new MockPropertyChangeListener();
- MockPropertyChangeListenerS pcl2 = new MockPropertyChangeListenerS(
- "id of pcl2");
- MockVetoableChangeListener vcl1 = new MockVetoableChangeListener();
- MockVetoableChangeListenerS vcl2 = new MockVetoableChangeListenerS(
- "id of vcl2");
- support.addPropertyChangeListener("beanContext", pcl1);
- support.addPropertyChangeListener("beanContext", pcl2);
- support.addVetoableChangeListener("beanContext", vcl1);
- support.addVetoableChangeListener("beanContext", vcl2);
- SerializationTest.verifyGolden(this, support, new SerializableAssert(){
- public void assertDeserialized(Serializable orig, Serializable ser) {
- assertEqualsSerially((BeanContextChildSupport) orig,
- (BeanContextChildSupport) ser);
- }
- });
- }
-
- public static void assertEqualsSerially(BeanContextChildSupport orig,
- BeanContextChildSupport ser) {
- // check peer
- if (orig == orig.getBeanContextChildPeer()) {
- assertSame(ser, ser.getBeanContextChildPeer());
- } else {
- assertSame(orig.getBeanContextChildPeer().getClass(), ser
- .getBeanContextChildPeer().getClass());
- if (orig.getBeanContextChildPeer() instanceof MockBeanContextChildDelegateS) {
- MockBeanContextChildDelegateS origPeer = (MockBeanContextChildDelegateS) orig
- .getBeanContextChildPeer();
- MockBeanContextChildDelegateS serPeer = (MockBeanContextChildDelegateS) ser
- .getBeanContextChildPeer();
- assertEquals(origPeer.id, serPeer.id);
- }
- }
-
- // check property change listeners
- PropertyChangeSupport origPCS = (PropertyChangeSupport) Utils.getField(
- orig, "pcSupport");
- PropertyChangeSupport serPCS = (PropertyChangeSupport) Utils.getField(
- ser, "pcSupport");
- PropertyChangeListener origPCL[] = origPCS
- .getPropertyChangeListeners("beanContext");
- PropertyChangeListener serPCL[] = serPCS
- .getPropertyChangeListeners("beanContext");
- int i = 0, j = 0;
- while (i < origPCL.length) {
- if (origPCL[i] instanceof Serializable) {
- assertSame(origPCL[i].getClass(), serPCL[j].getClass());
- if (origPCL[i] instanceof MockPropertyChangeListenerS) {
- assertEquals(((MockPropertyChangeListenerS) origPCL[i]).id,
- ((MockPropertyChangeListenerS) serPCL[j]).id);
- }
- i++;
- j++;
- } else {
- i++;
- }
- }
- assertEquals(serPCL.length, j);
-
- // check vetoable change listeners
- VetoableChangeSupport origVCS = (VetoableChangeSupport) Utils.getField(
- orig, "vcSupport");
- VetoableChangeSupport serVCS = (VetoableChangeSupport) Utils.getField(
- ser, "vcSupport");
- VetoableChangeListener origVCL[] = origVCS
- .getVetoableChangeListeners("beanContext");
- VetoableChangeListener serVCL[] = serVCS
- .getVetoableChangeListeners("beanContext");
- i = 0;
- j = 0;
- while (i < origVCL.length) {
- if (origVCL[i] instanceof Serializable) {
- assertSame(origVCL[i].getClass(), serVCL[j].getClass());
- if (origVCL[i] instanceof MockVetoableChangeListenerS) {
- assertEquals(((MockVetoableChangeListenerS) origVCL[i]).id,
- ((MockVetoableChangeListenerS) serVCL[j]).id);
- }
- i++;
- j++;
- } else {
- i++;
- }
- }
- assertEquals(serVCL.length, j);
- }
-
- /** TEST CONSTRUCTORS * */
-
- /**
- * * Test constructor with BeanContextChild parameter.
- * <p>
- *
- * @see BeanContextChildSupport#BeanContextChildSupport(BeanContextChild)
- */
- public void testConstructorBeanContextChild() throws Exception {
- new BeanContextChildSupport(null);
- }
-
- /**
- * * Test constructor with no parameters.
- * <p>
- *
- * @see BeanContextChildSupport#BeanContextChildSupport()
- */
- public void testConstructor() throws Exception {
- new BeanContextChildSupport();
- }
-
- /** TEST METHODS * */
-
- /**
- * Test method setBeanContext() with BeanContext parameter.
- * <p>
- */
- public void testSetBeanContextBeanContext() throws Exception {
- BeanContextChildSupport sup = new BeanContextChildSupport();
- sup.setBeanContext(new BeanContextSupport());
-
- assertNotNull("BeanContext should not be null", sup.getBeanContext());
- }
-
- public void testSetBeanContextBeanContextWithPropertyVetoException()
- throws Exception {
- MyBeanContextChildSupport myBeanContextChildSupport = new MyBeanContextChildSupport();
- VetoableChangeListener vcl = new MyVetoableChangeListener();
- myBeanContextChildSupport.addVetoableChangeListener("beanContext", vcl);
- BeanContext beanContext = new BeanContextSupport();
- try {
- myBeanContextChildSupport.setBeanContext(beanContext);
- fail("should throw PropertyVetoException");
- } catch (PropertyVetoException e) {
- // expected
- }
- assertTrue(myBeanContextChildSupport.getRejectedSetBCOnce());
- assertNull(myBeanContextChildSupport.getBeanContext());
-
- myBeanContextChildSupport.setBeanContext(beanContext);
- assertFalse(myBeanContextChildSupport.getRejectedSetBCOnce());
- assertNotNull(myBeanContextChildSupport.getBeanContext());
-
- try {
- myBeanContextChildSupport.setBeanContext(new BeanContextSupport());
- fail("should throw PropertyVetoException");
- } catch (PropertyVetoException e) {
- // expected
- }
-
- myBeanContextChildSupport
- .removeVetoableChangeListener("beanContext", vcl);
- myBeanContextChildSupport.setBeanContext(beanContext);
- assertTrue(myBeanContextChildSupport.getRejectedSetBCOnce());
- assertSame(beanContext, myBeanContextChildSupport.getBeanContext());
- }
-
-
- class MyVetoableChangeListener implements VetoableChangeListener
- {
-
- public void vetoableChange(PropertyChangeEvent arg0) throws PropertyVetoException {
- throw new PropertyVetoException("TESTSTRING", null);
- }
- }
-
- class MyBeanContextChildSupport extends BeanContextChildSupport {
- public boolean getRejectedSetBCOnce() {
- return rejectedSetBCOnce;
- }
- }
-
-
- /** UTILITY METHODS * */
-
- /** STANDARD ENDING * */
-
- /**
- * Start testing from the command line.
- * <p>
- */
- public static Test suite() {
- return new TestSuite(BeanContextChildSupportTest.class);
- }
-}
diff --git a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextEventTest.java b/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextEventTest.java
deleted file mode 100644
index 85cb2fe..0000000
--- a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextEventTest.java
+++ /dev/null
@@ -1,217 +0,0 @@
-/*
- * 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.java.beans.beancontext;
-
-import java.beans.beancontext.BeanContext;
-import java.beans.beancontext.BeanContextEvent;
-import java.beans.beancontext.BeanContextServicesSupport;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Locale;
-
-import junit.framework.TestCase;
-
-import org.apache.harmony.beans.tests.support.beancontext.Utils;
-import org.apache.harmony.beans.tests.support.beancontext.mock.MockBeanContext;
-import org.apache.harmony.beans.tests.support.beancontext.mock.MockBeanContextServiceProviderS;
-import org.apache.harmony.beans.tests.support.beancontext.mock.MockBeanContextServicesListenerS;
-import org.apache.harmony.testframework.serialization.SerializationTest;
-import org.apache.harmony.testframework.serialization.SerializationTest.SerializableAssert;
-
-/**
- * Test BeanContextEvent
- */
-public class BeanContextEventTest extends TestCase {
-
- private static class MockBeanContextEvent extends BeanContextEvent {
-
- private static final long serialVersionUID = -5990761357871915928L;
-
- /**
- * @param bc
- */
- protected MockBeanContextEvent(BeanContext bc) {
- super(bc);
-
- assertSame(bc, getSource());
- assertSame(bc, getBeanContext());
- assertNull(this.propagatedFrom);
- }
-
- }
-
- public void testBeanContextEvent_NullParam() {
- try {
- new MockBeanContextEvent(null);
- fail("IAE expected");
- } catch (IllegalArgumentException e) {
- // expected
- }
- }
-
- public void testBeanContextEvent() {
- BeanContext ctx = new MockBeanContext();
- BeanContextEvent event = new MockBeanContextEvent(ctx);
- assertSame(ctx, event.getSource());
- assertSame(ctx, event.getBeanContext());
- assertNull(event.getPropagatedFrom());
- assertFalse(event.isPropagated());
- }
-
- public void testGetBeanContext() {
- BeanContext ctx = new MockBeanContext();
- BeanContextEvent event = new MockBeanContextEvent(ctx);
- assertSame(ctx, event.getBeanContext());
- }
-
- public void testGetPropagatedFrom() {
- BeanContext ctx = new MockBeanContext();
- BeanContextEvent event = new MockBeanContextEvent(ctx);
- assertNull(event.getPropagatedFrom());
-
- BeanContext ctx2 = new MockBeanContext();
- event.setPropagatedFrom(ctx2);
- assertSame(ctx2, event.getPropagatedFrom());
-
- event.setPropagatedFrom(ctx);
- assertSame(ctx, event.getPropagatedFrom());
-
- event.setPropagatedFrom(null);
- assertNull(event.getPropagatedFrom());
- }
-
- public void testIsPropagated() {
- BeanContext ctx = new MockBeanContext();
- BeanContextEvent event = new MockBeanContextEvent(ctx);
- assertFalse(event.isPropagated());
-
- BeanContext ctx2 = new MockBeanContext();
- event.setPropagatedFrom(ctx2);
- assertTrue(event.isPropagated());
-
- event.setPropagatedFrom(ctx);
- assertTrue(event.isPropagated());
-
- event.setPropagatedFrom(null);
- assertFalse(event.isPropagated());
- }
-
- public void testSetPropagatedFrom() {
- BeanContext ctx = new MockBeanContext();
- BeanContextEvent event = new MockBeanContextEvent(ctx);
- assertNull(event.getPropagatedFrom());
-
- BeanContext ctx2 = new MockBeanContext();
- event.setPropagatedFrom(ctx2);
- assertSame(ctx2, event.getPropagatedFrom());
-
- event.setPropagatedFrom(ctx);
- assertSame(ctx, event.getPropagatedFrom());
-
- event.setPropagatedFrom(null);
- assertNull(event.getPropagatedFrom());
- }
-
- public void testSerialization() throws Exception {
- final BeanContextServicesSupport ctx = new BeanContextServicesSupport(
- null, Locale.FRANCE, false, false);
- final BeanContextServicesSupport ctx2 = new BeanContextServicesSupport(
- ctx, Locale.ITALY, true, true);
- BeanContextEvent event = new MockBeanContextEvent(ctx2);
- event.setPropagatedFrom(ctx);
- SerializationTest.verifySelf(event, new SerializableAssert(){
- public void assertDeserialized(Serializable arg0, Serializable arg1) {
- BeanContextEvent e1 = (BeanContextEvent)arg0;
- BeanContextEvent e2 = (BeanContextEvent)arg1;
- assertNull((BeanContextServicesSupport)e2.getSource());
- assertNotNull((BeanContextServicesSupport)e1.getSource());
- assertEqualsSerially((BeanContextServicesSupport)e1.getPropagatedFrom(), (BeanContextServicesSupport)e2.getPropagatedFrom());
- assertEqualsSerially(ctx, (BeanContextServicesSupport)e2.getPropagatedFrom());
- }
- });
- }
-
- public static void assertEqualsSerially(BeanContextServicesSupport orig,
- BeanContextServicesSupport ser) {
-
- // check bcsListeners
- ArrayList origBcsListeners = (ArrayList) Utils.getField(orig,
- "bcsListeners");
- ArrayList serBcsListeners = (ArrayList) Utils.getField(ser,
- "bcsListeners");
- int i = 0, j = 0;
- while (i < origBcsListeners.size()) {
- Object l1 = origBcsListeners.get(i);
- if (l1 instanceof Serializable) {
- Object l2 = serBcsListeners.get(j);
- assertSame(l1.getClass(), l2.getClass());
- if (l1 instanceof MockBeanContextServicesListenerS) {
- assertEquals(((MockBeanContextServicesListenerS) l1).id,
- ((MockBeanContextServicesListenerS) l2).id);
- }
- j++;
- }
- i++;
- }
- assertEquals(j, serBcsListeners.size());
-
- // check services
- HashMap origServices = (HashMap) Utils.getField(orig, "services");
- HashMap serServices = (HashMap) Utils.getField(ser, "services");
- int count = 0;
- for (Iterator iter = origServices.keySet().iterator(); iter.hasNext();) {
- Object serviceClass = iter.next();
- Object bcssProvider = origServices.get(serviceClass);
- Object provider = Utils.getField(bcssProvider, "serviceProvider");
- if (provider instanceof Serializable) {
- assertTrue(serServices.containsKey(serviceClass));
- if (provider instanceof MockBeanContextServiceProviderS) {
- Object serProvider = Utils.getField(serServices
- .get(serviceClass), "serviceProvider");
- assertEquals(
- ((MockBeanContextServiceProviderS) provider).id,
- ((MockBeanContextServiceProviderS) serProvider).id);
- }
- count++;
- }
- }
- assertEquals(count, serServices.size());
- }
-
- public void testSerializationComptibility() throws Exception {
- final BeanContextServicesSupport ctx = new BeanContextServicesSupport(
- null, Locale.ITALY, true, true);
- final BeanContextServicesSupport ctx2 = new BeanContextServicesSupport(
- null, Locale.CHINA, true, true);
-
- BeanContextEvent event = new MockBeanContextEvent(ctx);
- event.setPropagatedFrom(ctx2);
- SerializationTest.verifyGolden(this, event, new SerializableAssert(){
- public void assertDeserialized(Serializable arg0, Serializable arg1) {
- BeanContextEvent e1 = (BeanContextEvent)arg0;
- BeanContextEvent e2 = (BeanContextEvent)arg1;
- assertNull((BeanContextServicesSupport)e2.getSource());
- assertNotNull((BeanContextServicesSupport)e1.getSource());
- assertEqualsSerially((BeanContextServicesSupport)e1.getPropagatedFrom(), (BeanContextServicesSupport)e2.getPropagatedFrom());
- assertEqualsSerially(ctx2, (BeanContextServicesSupport)e2.getPropagatedFrom());
- }
- });
- }
-}
diff --git a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextMembershipEventTest.java b/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextMembershipEventTest.java
deleted file mode 100644
index f90fb3d..0000000
--- a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextMembershipEventTest.java
+++ /dev/null
@@ -1,286 +0,0 @@
-/*
- * 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.java.beans.beancontext;
-
-import java.beans.beancontext.BeanContext;
-import java.beans.beancontext.BeanContextMembershipEvent;
-import java.beans.beancontext.BeanContextServiceAvailableEvent;
-import java.io.IOException;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-
-import junit.framework.TestCase;
-
-import org.apache.harmony.beans.tests.support.beancontext.Utils;
-import org.apache.harmony.beans.tests.support.beancontext.mock.MockBeanContext;
-import org.apache.harmony.beans.tests.support.beancontext.mock.MockBeanContextDelegateS;
-import org.apache.harmony.testframework.serialization.SerializationTest;
-import org.apache.harmony.testframework.serialization.SerializationTest.SerializableAssert;
-
-import tests.util.SerializationTester;
-
-/**
- * Test BeanContextMembershipEvent
- */
-@SuppressWarnings("unchecked")
-public class BeanContextMembershipEventTest extends TestCase {
-
- private static class MockBeanContextMembershipEvent extends
- BeanContextMembershipEvent {
-
- private static final long serialVersionUID = -4761911723636245515L;
-
- /**
- * @param bc
- * @param changes
- */
- public MockBeanContextMembershipEvent(BeanContext bc, Object[] changes) {
- super(bc, changes);
- }
-
- /**
- * @param bc
- * @param changes
- */
- public MockBeanContextMembershipEvent(BeanContext bc, Collection<String> changes) {
- super(bc, changes);
- }
-
- public Collection collection() {
- return this.children;
- }
- }
-
- public void testBeanContextMembershipEvent_NullParam() {
- BeanContext ctx = new MockBeanContext();
- Collection<String> c = new ArrayList<String>();
- c.add("1");
- c.add("2");
- c.add("3");
- String array[] = new String[] { "1", "2", "3" };
-
- try {
- new MockBeanContextMembershipEvent(null, c);
- fail("IAE expected");
- } catch (IllegalArgumentException e) {
- // expected
- }
-
- try {
- new MockBeanContextMembershipEvent(null, array);
- fail("IAE expected");
- } catch (IllegalArgumentException e) {
- // expected
- }
-
- try {
- new MockBeanContextMembershipEvent(ctx, (Collection<String>) null);
- fail("NPE expected");
- } catch (NullPointerException e) {
- // expected
- }
-
- try {
- new MockBeanContextMembershipEvent(ctx, (Object[]) null);
- fail("NPE expected");
- } catch (NullPointerException e) {
- // expected
- }
- }
-
- /*
- * Class under test for void
- * BeanContextMembershipEvent(java.beans.beancontext.BeanContext,
- * java.util.Collection)
- */
- public void testBeanContextMembershipEventBeanContextCollection() {
- BeanContext ctx = new MockBeanContext();
- Collection<String> c = new ArrayList<String>();
- c.add("1");
- c.add("2");
- c.add("3");
- MockBeanContextMembershipEvent event = new MockBeanContextMembershipEvent(
- ctx, c);
- assertSame(c, event.collection());
- }
-
- /*
- * Class under test for void
- * BeanContextMembershipEvent(java.beans.beancontext.BeanContext,
- * java.lang.Object[])
- */
- public void testBeanContextMembershipEventBeanContextObjectArray() {
- BeanContext ctx = new MockBeanContext();
- String array[] = new String[] { "1", "2", "3" };
- new MockBeanContextMembershipEvent(ctx, array);
- }
-
- public void testSize_Collection() {
- BeanContext ctx = new MockBeanContext();
- Collection<String> c = new ArrayList<String>();
- c.add("1");
- c.add("2");
- c.add("3");
- MockBeanContextMembershipEvent event = new MockBeanContextMembershipEvent(
- ctx, c);
- assertEquals(3, event.size());
- }
-
- public void testSize_Array() {
- BeanContext ctx = new MockBeanContext();
- String array[] = new String[] { "1", "2", "3" };
- MockBeanContextMembershipEvent event = new MockBeanContextMembershipEvent(
- ctx, array);
- assertEquals(3, event.size());
- }
-
- public void testContains_Collection() {
- BeanContext ctx = new MockBeanContext();
- Collection<String> c = new ArrayList<String>();
- c.add("1");
- c.add("2");
- c.add("3");
- MockBeanContextMembershipEvent event = new MockBeanContextMembershipEvent(
- ctx, c);
- assertTrue(event.contains("1"));
- assertTrue(event.contains("2"));
- assertTrue(event.contains("3"));
- assertFalse(event.contains(null));
- assertFalse(event.contains("4"));
- }
-
- public void testContains_Array() {
- BeanContext ctx = new MockBeanContext();
- String array[] = new String[] { "1", "2", "3" };
- MockBeanContextMembershipEvent event = new MockBeanContextMembershipEvent(
- ctx, array);
- assertTrue(event.contains("1"));
- assertTrue(event.contains("2"));
- assertTrue(event.contains("3"));
- assertFalse(event.contains(null));
- assertFalse(event.contains("4"));
- }
-
- public void testToArray_Collection() {
- BeanContext ctx = new MockBeanContext();
- Collection<String> c = new ArrayList<String>();
- c.add("1");
- c.add("2");
- c.add("3");
- MockBeanContextMembershipEvent event = new MockBeanContextMembershipEvent(
- ctx, c);
- Object resultArray[] = event.toArray();
- assertEquals(3, resultArray.length);
- assertEquals("1", resultArray[0]);
- assertEquals("2", resultArray[1]);
- assertEquals("3", resultArray[2]);
- }
-
- public void testToArray_Array() {
- BeanContext ctx = new MockBeanContext();
- String array[] = new String[] { "1", "2", "3" };
- MockBeanContextMembershipEvent event = new MockBeanContextMembershipEvent(
- ctx, array);
- Object resultArray[] = event.toArray();
- assertEquals(3, resultArray.length);
- assertEquals("1", resultArray[0]);
- assertEquals("2", resultArray[1]);
- assertEquals("3", resultArray[2]);
- }
-
- public void testIterator_Collection() {
- BeanContext ctx = new MockBeanContext();
- Collection<String> c = new ArrayList<String>();
- c.add("1");
- c.add("2");
- c.add("3");
- MockBeanContextMembershipEvent event = new MockBeanContextMembershipEvent(
- ctx, c);
- Iterator it = event.iterator();
- assertEquals("1", it.next());
- assertEquals("2", it.next());
- assertEquals("3", it.next());
- assertFalse(it.hasNext());
- }
-
- public void testIterator_Array() {
- BeanContext ctx = new MockBeanContext();
- String array[] = new String[] { "1", "2", "3" };
- MockBeanContextMembershipEvent event = new MockBeanContextMembershipEvent(
- ctx, array);
- Iterator it = event.iterator();
- assertEquals("1", it.next());
- assertEquals("2", it.next());
- assertEquals("3", it.next());
- assertFalse(it.hasNext());
- }
-
- public void testSerialization() throws IOException, ClassNotFoundException {
- ArrayList<String> things = new ArrayList<String>();
- things.add("1");
- things.add("2");
- things.add("3");
- BeanContextMembershipEvent event = new BeanContextMembershipEvent(
- new MockBeanContext(), things);
- event.setPropagatedFrom(new MockBeanContextDelegateS("from ID"));
-
- assertEqualsSerially(event,
- (BeanContextMembershipEvent) SerializationTester
- .getDeserilizedObject(event));
- }
-
- public void testSerialization_Compatibility() throws Exception {
- ArrayList<String> things = new ArrayList<String>();
- things.add("1");
- things.add("2");
- things.add("3");
- BeanContextMembershipEvent event = new BeanContextMembershipEvent(
- new MockBeanContext(), things);
- event.setPropagatedFrom(new MockBeanContextDelegateS("from ID"));
- SerializationTest.verifyGolden(this, event, new SerializableAssert(){
- public void assertDeserialized(Serializable orig, Serializable ser) {
- assertEqualsSerially((BeanContextMembershipEvent) orig,
- (BeanContextMembershipEvent) ser);
- }
- });
- }
-
- private void assertEqualsSerially(BeanContextMembershipEvent orig,
- BeanContextMembershipEvent ser) {
- assertNull(ser.getSource());
-
- // check propagatedFrom
- if (orig.getPropagatedFrom() instanceof Serializable) {
- BeanContext origFrom = orig.getPropagatedFrom();
- BeanContext serFrom = ser.getPropagatedFrom();
- assertEquals(origFrom.getClass(), serFrom.getClass());
- if (origFrom instanceof MockBeanContextDelegateS) {
- assertEquals(((MockBeanContextDelegateS) origFrom).id,
- ((MockBeanContextDelegateS) serFrom).id);
- }
- }
-
- // check children
- Collection origChildren = (Collection) Utils.getField(orig, "children");
- Collection serChildren = (Collection) Utils.getField(ser, "children");
- assertEquals(origChildren, serChildren);
- }
-
-}
diff --git a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServiceAvailableEventTest.java b/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServiceAvailableEventTest.java
deleted file mode 100644
index 58aef44..0000000
--- a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServiceAvailableEventTest.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * 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.java.beans.beancontext;
-
-import java.beans.beancontext.BeanContext;
-import java.beans.beancontext.BeanContextServiceAvailableEvent;
-import java.beans.beancontext.BeanContextServiceRevokedEvent;
-import java.beans.beancontext.BeanContextServices;
-import java.io.IOException;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Iterator;
-
-import junit.framework.TestCase;
-
-import org.apache.harmony.beans.tests.support.beancontext.mock.MockBeanContextDelegateS;
-import org.apache.harmony.beans.tests.support.beancontext.mock.MockBeanContextServices;
-import org.apache.harmony.testframework.serialization.SerializationTest;
-import org.apache.harmony.testframework.serialization.SerializationTest.SerializableAssert;
-
-import tests.util.SerializationTester;
-
-/**
- * Test BeanContextServiceAvailableEvent
- */
-@SuppressWarnings("unchecked")
-public class BeanContextServiceAvailableEventTest extends TestCase {
-
- private static class MockBeanContextServiceAvailableEvent extends
- BeanContextServiceAvailableEvent {
-
- private static final long serialVersionUID = 796722290390289532L;
-
- /**
- * @param bcs
- * @param sc
- */
- public MockBeanContextServiceAvailableEvent(BeanContextServices bcs,
- Class sc) {
- super(bcs, sc);
- assertSame(sc, this.serviceClass);
- }
- }
-
- public void testBeanContextServiceAvailableEvent_NullParam() {
- BeanContextServices services = new MockBeanContextServices();
-
- try {
- new MockBeanContextServiceAvailableEvent(null, BeanContext.class);
- fail("IAE expected");
- } catch (IllegalArgumentException e) {
- // expected
- }
-
- BeanContextServiceAvailableEvent event = new MockBeanContextServiceAvailableEvent(
- services, null);
- assertNull(event.getServiceClass());
- assertSame(services, event.getSource());
- assertSame(services, event.getSourceAsBeanContextServices());
- }
-
- public void testBeanContextServiceAvailableEvent() {
- BeanContextServices services = new MockBeanContextServices();
- BeanContextServiceAvailableEvent event = new MockBeanContextServiceAvailableEvent(
- services, BeanContext.class);
- assertSame(BeanContext.class, event.getServiceClass());
- assertSame(services, event.getSource());
- assertSame(services, event.getSourceAsBeanContextServices());
- }
-
- public void testGetSourceAsBeanContextServices() {
- BeanContextServices services = new MockBeanContextServices();
- BeanContextServiceAvailableEvent event = new MockBeanContextServiceAvailableEvent(
- services, BeanContext.class);
- assertSame(services, event.getSource());
- assertSame(services, event.getSourceAsBeanContextServices());
- }
-
- public void testGetServiceClass() {
- BeanContextServices services = new MockBeanContextServices();
- BeanContextServiceAvailableEvent event = new MockBeanContextServiceAvailableEvent(
- services, BeanContext.class);
- assertSame(BeanContext.class, event.getServiceClass());
- }
-
- public void testGetCurrentServiceSelectors() {
- BeanContextServices services = new MockBeanContextServices();
- BeanContextServiceAvailableEvent event = new MockBeanContextServiceAvailableEvent(
- services, BeanContext.class);
-
- Iterator expectedIt = services
- .getCurrentServiceSelectors(BeanContext.class);
- Iterator it = event.getCurrentServiceSelectors();
- while (expectedIt.hasNext()) {
- assertSame(expectedIt.next(), it.next());
- }
- assertFalse(expectedIt.hasNext());
- assertFalse(it.hasNext());
- }
-
- public void testSerialization() throws IOException, ClassNotFoundException {
- BeanContextServiceAvailableEvent event = new BeanContextServiceAvailableEvent(
- new MockBeanContextServices(), ArrayList.class);
- event.setPropagatedFrom(new MockBeanContextDelegateS("from ID"));
-
- assertEqualsSerially(event,
- (BeanContextServiceAvailableEvent) SerializationTester
- .getDeserilizedObject(event));
- }
-
-
- public void testSerialization_Compatibility() throws Exception {
- BeanContextServiceAvailableEvent event = new BeanContextServiceAvailableEvent(
- new MockBeanContextServices(), ArrayList.class);
- event.setPropagatedFrom(new MockBeanContextDelegateS("from ID"));
- SerializationTest.verifyGolden(this, event, new SerializableAssert(){
- public void assertDeserialized(Serializable orig, Serializable ser) {
- assertEqualsSerially((BeanContextServiceAvailableEvent) orig,
- (BeanContextServiceAvailableEvent) ser);
- }
- });
- }
-
- private void assertEqualsSerially(BeanContextServiceAvailableEvent orig,
- BeanContextServiceAvailableEvent ser) {
- assertNull(ser.getSource());
-
- // check propagatedFrom
- if (orig.getPropagatedFrom() instanceof Serializable) {
- BeanContext origFrom = orig.getPropagatedFrom();
- BeanContext serFrom = ser.getPropagatedFrom();
- assertEquals(origFrom.getClass(), serFrom.getClass());
- if (origFrom instanceof MockBeanContextDelegateS) {
- assertEquals(((MockBeanContextDelegateS) origFrom).id,
- ((MockBeanContextDelegateS) serFrom).id);
- }
- }
-
- // check serviceClass
- assertEquals(orig.getServiceClass(), ser.getServiceClass());
- }
-}
diff --git a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServiceRevokedEventTest.java b/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServiceRevokedEventTest.java
deleted file mode 100644
index 7ec9200..0000000
--- a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServiceRevokedEventTest.java
+++ /dev/null
@@ -1,548 +0,0 @@
-/*
- * 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.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;
-
-import org.apache.harmony.beans.tests.support.beancontext.mock.MockBeanContextDelegateS;
-import org.apache.harmony.beans.tests.support.beancontext.mock.MockBeanContextServices;
-import org.apache.harmony.testframework.serialization.SerializationTest;
-import org.apache.harmony.testframework.serialization.SerializationTest.SerializableAssert;
-
-import tests.util.SerializationTester;
-
-/**
- * Test BeanContextServiceRevokedEvent
- */
-@SuppressWarnings("unchecked")
-public class BeanContextServiceRevokedEventTest extends TestCase {
-
- private static class MockBeanContextServiceRevokedEvent extends
- BeanContextServiceRevokedEvent {
-
- private static final long serialVersionUID = -705194281645674622L;
-
- /**
- * @param bcs
- * @param sc
- * @param invalidate
- */
- public MockBeanContextServiceRevokedEvent(BeanContextServices bcs,
- Class sc, boolean invalidate) {
- super(bcs, sc, invalidate);
- assertSame(sc, this.serviceClass);
- }
-
- }
-
- public void testBeanContextServiceRevokedEvent_NullParam() {
- BeanContextServices services = new MockBeanContextServices();
-
- try {
- new MockBeanContextServiceRevokedEvent(null, BeanContext.class,
- true);
- fail("IAE expected");
- } catch (IllegalArgumentException e) {
- // expected
- }
-
- BeanContextServiceRevokedEvent event = new MockBeanContextServiceRevokedEvent(
- services, null, true);
- assertNull(event.getServiceClass());
- assertSame(services, event.getSource());
- assertSame(services, event.getSourceAsBeanContextServices());
- assertTrue(event.isCurrentServiceInvalidNow());
- try {
- event.isServiceClass(Integer.class);
- fail("NPE expected");
- } 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));
- }
-
- public void testBeanContextServiceRevokedEvent() {
- BeanContextServices services = new MockBeanContextServices();
- BeanContextServiceRevokedEvent event = new MockBeanContextServiceRevokedEvent(
- services, BeanContext.class, true);
- assertSame(BeanContext.class, event.getServiceClass());
- assertSame(services, event.getSource());
- assertSame(services, event.getSourceAsBeanContextServices());
- assertTrue(event.isCurrentServiceInvalidNow());
- }
-
- public void testGetSourceAsBeanContextServices() {
- BeanContextServices services = new MockBeanContextServices();
- BeanContextServiceRevokedEvent event = new MockBeanContextServiceRevokedEvent(
- services, BeanContext.class, true);
- assertSame(services, event.getSource());
- assertSame(services, event.getSourceAsBeanContextServices());
-
- // Regression for HARMONY-1153
- BeanContextServicesSupport sup = new BeanContextServicesSupport(
- new MockBeanContextServices(), new Locale("ru", "RU"), false,
- false);
- 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() {
- BeanContextServices services = new MockBeanContextServices();
- BeanContextServiceRevokedEvent event = new MockBeanContextServiceRevokedEvent(
- services, BeanContext.class, true);
- assertSame(BeanContext.class, event.getServiceClass());
- }
-
- public void testIsServiceClass() {
- BeanContextServices services = new MockBeanContextServices();
- BeanContextServiceRevokedEvent event = new MockBeanContextServiceRevokedEvent(
- services, BeanContext.class, true);
- assertTrue(event.isServiceClass(BeanContext.class));
- assertFalse(event.isServiceClass(Integer.class));
-
- // Regression for HARMONY-1516
- assertFalse(event.isServiceClass(null));
- }
-
- public void testIsCurrentServiceInvalidNow() {
- BeanContextServices services = new MockBeanContextServices();
- BeanContextServiceRevokedEvent event = new MockBeanContextServiceRevokedEvent(
- services, BeanContext.class, true);
- assertTrue(event.isCurrentServiceInvalidNow());
- event = new MockBeanContextServiceRevokedEvent(services,
- BeanContext.class, false);
- assertFalse(event.isCurrentServiceInvalidNow());
- }
-
- public void testSerialization() throws IOException, ClassNotFoundException {
- BeanContextServiceRevokedEvent event = new BeanContextServiceRevokedEvent(
- new MockBeanContextServices(), ArrayList.class, true);
- event.setPropagatedFrom(new MockBeanContextDelegateS("from ID"));
-
- assertEqualsSerially(event,
- (BeanContextServiceRevokedEvent) SerializationTester
- .getDeserilizedObject(event));
-
- }
-
- 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);
- assertEquals(null, event.getPropagatedFrom());
- assertEquals(ArrayList.class, event.getServiceClass());
- assertSame(bcs, event.getSource());
- assertSame(bcs, event.getBeanContext());
- assertSame(bcs, event.getSourceAsBeanContextServices());
- assertFalse(event.isPropagated());
- }
-
- private void assertEqualsSerially(BeanContextServiceRevokedEvent orig,
- BeanContextServiceRevokedEvent ser) {
- assertNull(ser.getSource());
-
- // check propagatedFrom
- if (orig.getPropagatedFrom() instanceof Serializable) {
- BeanContext origFrom = orig.getPropagatedFrom();
- BeanContext serFrom = ser.getPropagatedFrom();
- assertEquals(origFrom.getClass(), serFrom.getClass());
- if (origFrom instanceof MockBeanContextDelegateS) {
- assertEquals(((MockBeanContextDelegateS) origFrom).id,
- ((MockBeanContextDelegateS) serFrom).id);
- }
- }
-
- // check serviceClass
- assertEquals(orig.getServiceClass(), ser.getServiceClass());
-
- // check invalidateRefs
- assertEquals(orig.isCurrentServiceInvalidNow(), ser
- .isCurrentServiceInvalidNow());
- }
-}
diff --git a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServicesSupport2Test.java b/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServicesSupport2Test.java
deleted file mode 100644
index 415ff48..0000000
--- a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServicesSupport2Test.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * 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.java.beans.beancontext;
-
-import java.beans.beancontext.BeanContextServiceProvider;
-import java.beans.beancontext.BeanContextServices;
-import java.beans.beancontext.BeanContextServicesSupport;
-import java.util.Iterator;
-
-import junit.framework.TestCase;
-
-/*
- * Regression test for HARMONY-1369
- */
-public class BeanContextServicesSupport2Test extends TestCase {
-
- public void test() {
- BeanContextServiceProvider bcsp = new BCSP();
- BCSS serviceSupport = new BCSS(new BeanContextServicesSupport());
- assertTrue("Expected first addService to return true", serviceSupport
- .addService(Boolean.TYPE, bcsp, false));
- assertFalse("Expected second addService to return false", serviceSupport
- .addService(Boolean.TYPE, bcsp, false));
- }
-
- class BCSP implements BeanContextServiceProvider {
- public Iterator getCurrentServiceSelectors(BeanContextServices p0,
- Class p1) {
- return null;
- }
-
- public void releaseService(BeanContextServices p0, Object p1, Object p2) {
- return;
- }
-
- public Object getService(BeanContextServices p0, Object p1, Class p2,
- Object p3) {
- return null;
- }
- }
-
- class BCSS extends BeanContextServicesSupport {
- public BCSS() {
- super();
- }
-
- public BCSS(BeanContextServicesSupport peer) {
- super(peer);
- }
-
- public boolean addService(Class serviceClass,
- BeanContextServiceProvider bcsp, boolean firevent) {
- return super.addService(serviceClass, bcsp, firevent);
- }
- }
-
-}
diff --git a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServicesSupportTest.java b/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServicesSupportTest.java
deleted file mode 100644
index ee147a8..0000000
--- a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServicesSupportTest.java
+++ /dev/null
@@ -1,1534 +0,0 @@
-/*
- * 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.java.beans.beancontext;
-
-import java.beans.PropertyVetoException;
-import java.beans.beancontext.BeanContextServiceAvailableEvent;
-import java.beans.beancontext.BeanContextServiceProvider;
-import java.beans.beancontext.BeanContextServiceRevokedEvent;
-import java.beans.beancontext.BeanContextServices;
-import java.beans.beancontext.BeanContextServicesListener;
-import java.beans.beancontext.BeanContextServicesSupport;
-import java.io.IOException;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Set;
-import java.util.TooManyListenersException;
-
-import junit.framework.TestCase;
-
-import org.apache.harmony.beans.tests.support.beancontext.MethodInvocationRecords;
-import org.apache.harmony.beans.tests.support.beancontext.Utils;
-import org.apache.harmony.beans.tests.support.beancontext.mock.MockBeanContextChild;
-import org.apache.harmony.beans.tests.support.beancontext.mock.MockBeanContextServiceProvider;
-import org.apache.harmony.beans.tests.support.beancontext.mock.MockBeanContextServiceProviderS;
-import org.apache.harmony.beans.tests.support.beancontext.mock.MockBeanContextServiceRevokedListener;
-import org.apache.harmony.beans.tests.support.beancontext.mock.MockBeanContextServices;
-import org.apache.harmony.beans.tests.support.beancontext.mock.MockBeanContextServicesListener;
-import org.apache.harmony.beans.tests.support.beancontext.mock.MockBeanContextServicesListenerS;
-import org.apache.harmony.testframework.serialization.SerializationTest;
-import org.apache.harmony.testframework.serialization.SerializationTest.SerializableAssert;
-
-import tests.util.SerializationTester;
-
-/**
- * Test BeanContextServicesSupport
- */
-@SuppressWarnings("unchecked")
-public class BeanContextServicesSupportTest extends TestCase {
-
- public static class MockBeanContextServicesSupport extends
- BeanContextServicesSupport {
-
- private static final long serialVersionUID = -5521269152428572350L;
-
- public MethodInvocationRecords records;
-
- public MockBeanContextServicesSupport() {
- super();
- }
-
- public MockBeanContextServicesSupport(BeanContextServices peer) {
- super(peer);
- }
-
- public MockBeanContextServicesSupport(BeanContextServices peer,
- Locale lcle) {
- super(peer, lcle);
- }
-
- public MockBeanContextServicesSupport(BeanContextServices peer,
- Locale lcle, boolean dtime) {
- super(peer, lcle, dtime);
- }
-
- public MockBeanContextServicesSupport(BeanContextServices peer,
- Locale lcle, boolean dTime, boolean visible) {
- super(peer, lcle, dTime, visible);
- }
-
- public ArrayList bcsListeners() {
- return bcsListeners;
- }
-
- public BeanContextServicesSupport.BCSSProxyServiceProvider proxy() {
- return proxy;
- }
-
- public int serializable() {
- return serializable;
- }
-
- public HashMap services() {
- return services;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.beancontext.BeanContextSupport#initialize()
- */
- @Override
- public void initialize() {
- super.initialize();
- if (records == null) {
- records = new MethodInvocationRecords();
- }
- records.add("initialize", null);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.beancontext.BeanContextServicesSupport#addService(java.lang.Class,
- * java.beans.beancontext.BeanContextServiceProvider, boolean)
- */
- @Override
- public boolean addService(Class serviceClass,
- BeanContextServiceProvider bcsp, boolean fireEvent) {
- return super.addService(serviceClass, bcsp, fireEvent);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.beancontext.BeanContextSupport#childJustRemovedHook(java.lang.Object,
- * java.beans.beancontext.BeanContextSupport.BCSChild)
- */
- @Override
- protected void childJustRemovedHook(Object child, BCSChild bcsc) {
- super.childJustRemovedHook(child, bcsc);
- records.add("childJustRemovedHook", child, bcsc, null);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.beancontext.BeanContextServicesSupport#createBCSSServiceProvider(java.lang.Class,
- * java.beans.beancontext.BeanContextServiceProvider)
- */
- @Override
- protected BCSSServiceProvider createBCSSServiceProvider(Class sc,
- BeanContextServiceProvider bcsp) {
- BCSSServiceProvider result = super.createBCSSServiceProvider(sc,
- bcsp);
- records.add("createBCSSServiceProvider", sc, bcsp, result);
- return result;
- }
-
- public static BeanContextServicesListener publicGetChildBeanContextServicesListener(
- Object child) {
- return getChildBeanContextServicesListener(child);
- }
-
- public void publicFireServiceAdded(BeanContextServiceAvailableEvent evt) {
- fireServiceAdded(evt);
- }
-
- public void publicFireServiceAdded(Class cls) {
- fireServiceAdded(cls);
- }
-
- public void publicFireServiceRevoked(BeanContextServiceRevokedEvent evt) {
- fireServiceRevoked(evt);
- }
-
- public void publicFireServiceRevoked(Class cls, boolean revokeNow) {
- fireServiceRevoked(cls, revokeNow);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.beancontext.BeanContextServicesListener#serviceAvailable(java.beans.beancontext.BeanContextServiceAvailableEvent)
- */
- @Override
- public void serviceAvailable(BeanContextServiceAvailableEvent bcssae) {
- super.serviceAvailable(bcssae);
- records.add("serviceAvailable", bcssae, null);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.beancontext.BeanContextServiceRevokedListener#serviceRevoked(java.beans.beancontext.BeanContextServiceRevokedEvent)
- */
- @Override
- public void serviceRevoked(BeanContextServiceRevokedEvent bcssre) {
- super.serviceRevoked(bcssre);
- records.add("serviceRevoked", bcssre, null);
- }
- }
-
- public void testAddBeanContextServicesListener_NullParam() {
- MockBeanContextServicesSupport support = new MockBeanContextServicesSupport();
- try {
- support.addBeanContextServicesListener(null);
- fail();
- } catch (NullPointerException e) {
- // expected
- }
- }
-
- public void testAddBeanContextServicesListener() {
- MockBeanContextServicesSupport support = new MockBeanContextServicesSupport();
- MockBeanContextServicesListener l1 = new MockBeanContextServicesListener();
-
- support.addBeanContextServicesListener(l1);
- assertEquals(1, support.bcsListeners().size());
- assertTrue(support.bcsListeners().contains(l1));
- }
-
- /*
- * Class under test for boolean addService(java.lang.Class,
- * java.beans.beancontext.BeanContextServiceProvider)
- */
- public void testAddServiceClassBeanContextServiceProvider_NullParam() {
- MockBeanContextServicesSupport support = new MockBeanContextServicesSupport();
- MockBeanContextServiceProvider provider = new MockBeanContextServiceProvider();
-
- try {
- support.addService(null, provider);
- fail();
- } catch (NullPointerException e) {
- // expected
- }
-
- try {
- support.addService(Collection.class, null);
- fail();
- } catch (NullPointerException e) {
- // expected
- }
- }
-
- /*
- * Class under test for boolean addService(java.lang.Class,
- * java.beans.beancontext.BeanContextServiceProvider)
- */
- public void testAddServiceClassBeanContextServiceProvider_ParentContext() {
- MockBeanContextServicesSupport support = new MockBeanContextServicesSupport();
- MockBeanContextServicesSupport childSupport = new MockBeanContextServicesSupport();
- support.add(childSupport);
- MockBeanContextServicesListener l1 = new MockBeanContextServicesListener();
- MockBeanContextServicesListener l2 = new MockBeanContextServicesListener();
- support.addBeanContextServicesListener(l1);
- childSupport.addBeanContextServicesListener(l2);
- support.records.assertRecord("initialize", null);
- childSupport.records.assertRecord("initialize", null);
-
- MockBeanContextServiceProvider provider = new MockBeanContextServiceProvider();
- boolean result = support.addService(Collection.class, provider);
- assertTrue(result);
- assertEquals(1, support.services().size());
- assertEquals(0, childSupport.services().size());
- Object bcssProvider = support.services().get(Collection.class);
- support.records.assertRecord("createBCSSServiceProvider",
- Collection.class, provider, bcssProvider);
- support.records.assertEndOfRecords();
- BeanContextServiceAvailableEvent evt = (BeanContextServiceAvailableEvent) childSupport.records
- .getArg(0);
- childSupport.records.assertRecord("serviceAvailable", evt, null);
- assertSame(support, evt.getSourceAsBeanContextServices());
- assertSame(Collection.class, evt.getServiceClass());
- childSupport.records.assertEndOfRecords();
- assertSame(support, l1.lastAvailableEvent
- .getSourceAsBeanContextServices());
- assertSame(Collection.class, l1.lastAvailableEvent.getServiceClass());
- assertSame(support, l2.lastAvailableEvent
- .getSourceAsBeanContextServices());
- assertSame(Collection.class, l2.lastAvailableEvent.getServiceClass());
- }
-
- /*
- * Class under test for boolean addService(java.lang.Class,
- * java.beans.beancontext.BeanContextServiceProvider)
- */
- public void testAddServiceClassBeanContextServiceProvider_ChildContext() {
- MockBeanContextServicesSupport support = new MockBeanContextServicesSupport();
- MockBeanContextServicesSupport childSupport = new MockBeanContextServicesSupport();
- support.add(childSupport);
- MockBeanContextServicesListener l1 = new MockBeanContextServicesListener();
- MockBeanContextServicesListener l2 = new MockBeanContextServicesListener();
- support.addBeanContextServicesListener(l1);
- childSupport.addBeanContextServicesListener(l2);
- support.records.assertRecord("initialize", null);
- childSupport.records.assertRecord("initialize", null);
-
- MockBeanContextServiceProvider provider = new MockBeanContextServiceProvider();
- boolean result = childSupport.addService(Collection.class, provider);
- assertTrue(result);
- assertEquals(0, support.services().size());
- assertEquals(1, childSupport.services().size());
- Object bcssProvider = childSupport.services().get(Collection.class);
- childSupport.records.assertRecord("createBCSSServiceProvider",
- Collection.class, provider, bcssProvider);
- childSupport.records.assertEndOfRecords();
- support.records.assertEndOfRecords();
- assertNull(l1.lastAvailableEvent);
- assertSame(childSupport, l2.lastAvailableEvent
- .getSourceAsBeanContextServices());
- assertSame(Collection.class, l2.lastAvailableEvent.getServiceClass());
- }
-
- /*
- * Class under test for boolean addService(java.lang.Class,
- * java.beans.beancontext.BeanContextServiceProvider)
- */
- public void testAddServiceClassBeanContextServiceProvider_Exist() {
- MockBeanContextServicesSupport support = new MockBeanContextServicesSupport();
- MockBeanContextServicesSupport childSupport = new MockBeanContextServicesSupport();
- support.add(childSupport);
- MockBeanContextServicesListener l1 = new MockBeanContextServicesListener();
- MockBeanContextServicesListener l2 = new MockBeanContextServicesListener();
- support.addBeanContextServicesListener(l1);
- childSupport.addBeanContextServicesListener(l2);
- support.records.assertRecord("initialize", null);
- childSupport.records.assertRecord("initialize", null);
-
- MockBeanContextServiceProvider provider = new MockBeanContextServiceProvider();
- boolean result = support.addService(Collection.class, provider);
- assertTrue(result);
- assertEquals(1, support.services().size());
- assertEquals(0, childSupport.services().size());
- Object bcssProvider = support.services().get(Collection.class);
- support.records.assertRecord("createBCSSServiceProvider",
- Collection.class, provider, bcssProvider);
- support.records.assertEndOfRecords();
- BeanContextServiceAvailableEvent evt = (BeanContextServiceAvailableEvent) childSupport.records
- .getArg(0);
- childSupport.records.assertRecord("serviceAvailable", evt, null);
- assertSame(support, evt.getSourceAsBeanContextServices());
- assertSame(Collection.class, evt.getServiceClass());
- childSupport.records.assertEndOfRecords();
- assertSame(support, l1.lastAvailableEvent
- .getSourceAsBeanContextServices());
- assertSame(Collection.class, l1.lastAvailableEvent.getServiceClass());
- assertSame(support, l2.lastAvailableEvent
- .getSourceAsBeanContextServices());
- assertSame(Collection.class, l2.lastAvailableEvent.getServiceClass());
- l1.clearLastEvent();
- l2.clearLastEvent();
-
- // add exist
- MockBeanContextServiceProvider another = new MockBeanContextServiceProvider();
- result = support.addService(Collection.class, another);
- assertFalse(result);
- support.records.assertEndOfRecords();
- childSupport.records.assertEndOfRecords();
- assertNull(l1.lastAvailableEvent);
- assertNull(l2.lastAvailableEvent);
- }
-
- /*
- * Class under test for boolean addService(java.lang.Class,
- * java.beans.beancontext.BeanContextServiceProvider, boolean)
- */
- public void testAddServiceClassBeanContextServiceProviderboolean_FalseParam() {
- MockBeanContextServicesSupport support = new MockBeanContextServicesSupport();
- MockBeanContextServicesSupport childSupport = new MockBeanContextServicesSupport();
- support.add(childSupport);
- MockBeanContextServicesListener l1 = new MockBeanContextServicesListener();
- MockBeanContextServicesListener l2 = new MockBeanContextServicesListener();
- support.addBeanContextServicesListener(l1);
- childSupport.addBeanContextServicesListener(l2);
- support.records.assertRecord("initialize", null);
- childSupport.records.assertRecord("initialize", null);
-
- MockBeanContextServiceProvider provider = new MockBeanContextServiceProvider();
- boolean result = support.addService(Collection.class, provider, false);
- assertTrue(result);
- assertEquals(1, support.services().size());
- assertEquals(0, childSupport.services().size());
- Object bcssProvider = support.services().get(Collection.class);
- support.records.assertRecord("createBCSSServiceProvider",
- Collection.class, provider, bcssProvider);
- support.records.assertEndOfRecords();
- childSupport.records.assertEndOfRecords();
- assertNull(l1.lastAvailableEvent);
- assertNull(l2.lastAvailableEvent);
- }
-
- public void testBcsPreDeserializationHook() {
- // covered by serialization test
- }
-
- public void testBcsPreSerializationHook() {
- // covered by serialization test
- }
-
- /*
- * Class under test for void BeanContextServicesSupport()
- */
- public void testBeanContextServicesSupport() {
- MockBeanContextServicesSupport support = new MockBeanContextServicesSupport();
- assertEquals(0, support.bcsListeners().size());
- assertNull(support.proxy());
- assertEquals(0, support.serializable());
- assertTrue(support.services().isEmpty());
- assertSame(support, support.getBeanContextServicesPeer());
- assertSame(Locale.getDefault(), support.getLocale());
- assertFalse(support.isDesignTime());
- }
-
- /*
- * Class under test for void
- * BeanContextServicesSupport(java.beans.beancontext.BeanContextServices)
- */
- public void testBeanContextServicesSupportBeanContextServices() {
- MockBeanContextServices services = new MockBeanContextServices();
- MockBeanContextServicesSupport support = new MockBeanContextServicesSupport(
- services);
- assertEquals(0, support.bcsListeners().size());
- assertNull(support.proxy());
- assertEquals(0, support.serializable());
- assertTrue(support.services().isEmpty());
- assertSame(services, support.getBeanContextServicesPeer());
- assertSame(Locale.getDefault(), support.getLocale());
- assertFalse(support.isDesignTime());
- }
-
- /*
- * Class under test for void
- * BeanContextServicesSupport(java.beans.beancontext.BeanContextServices,
- * java.util.Locale)
- */
- public void testBeanContextServicesSupportBeanContextServicesLocale() {
- MockBeanContextServices services = new MockBeanContextServices();
- MockBeanContextServicesSupport support = new MockBeanContextServicesSupport(
- services, Locale.ITALY);
- assertEquals(0, support.bcsListeners().size());
- assertNull(support.proxy());
- assertEquals(0, support.serializable());
- assertTrue(support.services().isEmpty());
- assertSame(services, support.getBeanContextServicesPeer());
- assertSame(Locale.ITALY, support.getLocale());
- assertFalse(support.isDesignTime());
- }
-
- /*
- * Class under test for void
- * BeanContextServicesSupport(java.beans.beancontext.BeanContextServices,
- * java.util.Locale, boolean)
- */
- public void testBeanContextServicesSupportBeanContextServicesLocaleboolean() {
- MockBeanContextServices services = new MockBeanContextServices();
- MockBeanContextServicesSupport support = new MockBeanContextServicesSupport(
- services, Locale.ITALY, true);
- assertEquals(0, support.bcsListeners().size());
- assertNull(support.proxy());
- assertEquals(0, support.serializable());
- assertTrue(support.services().isEmpty());
- assertSame(services, support.getBeanContextServicesPeer());
- assertSame(Locale.ITALY, support.getLocale());
- assertTrue(support.isDesignTime());
- }
-
- /*
- * Class under test for void
- * BeanContextServicesSupport(java.beans.beancontext.BeanContextServices,
- * java.util.Locale, boolean, boolean)
- */
- public void testBeanContextServicesSupportBeanContextServicesLocalebooleanboolean() {
- MockBeanContextServices services = new MockBeanContextServices();
- MockBeanContextServicesSupport support = new MockBeanContextServicesSupport(
- services, Locale.ITALY, true, true);
- assertEquals(0, support.bcsListeners().size());
- assertNull(support.proxy());
- assertEquals(0, support.serializable());
- assertTrue(support.services().isEmpty());
- assertSame(services, support.getBeanContextServicesPeer());
- assertSame(Locale.ITALY, support.getLocale());
- assertTrue(support.isDesignTime());
- }
-
- public void testChildJustRemovedHook() throws TooManyListenersException {
- MockBeanContextServicesSupport support = new MockBeanContextServicesSupport();
- MockBeanContextChild child = new MockBeanContextChild();
- support.add(child);
- MockBeanContextServiceProvider provider = new MockBeanContextServiceProvider();
- support.addService(Collection.class, provider);
-
- MockBeanContextServiceRevokedListener rl = new MockBeanContextServiceRevokedListener();
- Object service = support.getService(child, child, Collection.class,
- null, rl);
- assertSame(Collections.EMPTY_SET, service);
- assertNull(rl.lastEvent);
- support.records.clear();
- provider.records.clear();
-
- support.remove(child);
- support.records.assertRecord("childJustRemovedHook", child,
- MethodInvocationRecords.IGNORE, null);
- support.records.assertEndOfRecords();
- provider.records.assertRecord("releaseService", support, child,
- service, null);
- provider.records.assertEndOfRecords();
- assertNull(rl.lastEvent);
- }
-
- public void testCreateBCSChild() {
- // covered in super's testcase
- }
-
- public void testCreateBCSSServiceProvider() {
- // covered by addService
- }
-
- /*
- * Class under test for void
- * fireServiceAdded(java.beans.beancontext.BeanContextServiceAvailableEvent)
- */
- public void testFireServiceAddedBeanContextServiceAvailableEvent() {
- MockBeanContextServicesSupport support = new MockBeanContextServicesSupport();
- MockBeanContextServicesSupport childSupport = new MockBeanContextServicesSupport();
- support.add(childSupport);
- MockBeanContextServicesListener l1 = new MockBeanContextServicesListener();
- MockBeanContextServicesListener l2 = new MockBeanContextServicesListener();
- support.addBeanContextServicesListener(l1);
- childSupport.addBeanContextServicesListener(l2);
- support.records.assertRecord("initialize", null);
- childSupport.records.assertRecord("initialize", null);
-
- BeanContextServiceAvailableEvent evt = new BeanContextServiceAvailableEvent(
- support, Collection.class);
- support.publicFireServiceAdded(evt);
-
- support.records.assertEndOfRecords();
- childSupport.records.assertEndOfRecords();
- assertSame(evt, l1.lastAvailableEvent);
- assertNull(l2.lastAvailableEvent);
- }
-
- /*
- * Class under test for void fireServiceAdded(java.lang.Class)
- */
- public void testFireServiceAddedClass() {
- MockBeanContextServicesSupport support = new MockBeanContextServicesSupport();
- MockBeanContextServicesSupport childSupport = new MockBeanContextServicesSupport();
- support.add(childSupport);
- MockBeanContextServicesListener l1 = new MockBeanContextServicesListener();
- MockBeanContextServicesListener l2 = new MockBeanContextServicesListener();
- support.addBeanContextServicesListener(l1);
- childSupport.addBeanContextServicesListener(l2);
- support.records.assertRecord("initialize", null);
- childSupport.records.assertRecord("initialize", null);
-
- support.publicFireServiceAdded(Collection.class);
-
- support.records.assertEndOfRecords();
- childSupport.records.assertEndOfRecords();
- assertSame(Collection.class, l1.lastAvailableEvent.getServiceClass());
- assertSame(support, l1.lastAvailableEvent
- .getSourceAsBeanContextServices());
- assertNull(l2.lastAvailableEvent);
- }
-
- /*
- * Class under test for void
- * fireServiceRevoked(java.beans.beancontext.BeanContextServiceRevokedEvent)
- */
- public void testFireServiceRevokedBeanContextServiceRevokedEvent() {
- MockBeanContextServicesSupport support = new MockBeanContextServicesSupport();
- MockBeanContextServicesSupport childSupport = new MockBeanContextServicesSupport();
- support.add(childSupport);
- MockBeanContextServicesListener l1 = new MockBeanContextServicesListener();
- MockBeanContextServicesListener l2 = new MockBeanContextServicesListener();
- support.addBeanContextServicesListener(l1);
- childSupport.addBeanContextServicesListener(l2);
- support.records.assertRecord("initialize", null);
- childSupport.records.assertRecord("initialize", null);
-
- BeanContextServiceRevokedEvent evt = new BeanContextServiceRevokedEvent(
- support, Collection.class, false);
- support.publicFireServiceRevoked(evt);
-
- support.records.assertEndOfRecords();
- childSupport.records.assertEndOfRecords();
- assertSame(evt, l1.lastRevokedEvent);
- assertNull(l2.lastRevokedEvent);
- }
-
- /*
- * Class under test for void fireServiceRevoked(java.lang.Class, boolean)
- */
- public void testFireServiceRevokedClassboolean() {
- MockBeanContextServicesSupport support = new MockBeanContextServicesSupport();
- MockBeanContextServicesSupport childSupport = new MockBeanContextServicesSupport();
- support.add(childSupport);
- MockBeanContextServicesListener l1 = new MockBeanContextServicesListener();
- MockBeanContextServicesListener l2 = new MockBeanContextServicesListener();
- support.addBeanContextServicesListener(l1);
- childSupport.addBeanContextServicesListener(l2);
- support.records.assertRecord("initialize", null);
- childSupport.records.assertRecord("initialize", null);
-
- support.publicFireServiceRevoked(Collection.class, false);
-
- support.records.assertEndOfRecords();
- childSupport.records.assertEndOfRecords();
- assertSame(Collection.class, l1.lastRevokedEvent.getServiceClass());
- assertSame(support, l1.lastRevokedEvent
- .getSourceAsBeanContextServices());
- assertFalse(l1.lastRevokedEvent.isCurrentServiceInvalidNow());
- assertNull(l2.lastRevokedEvent);
- }
-
- public void testGetBeanContextServicesPeer_Self() {
- MockBeanContextServicesSupport support = new MockBeanContextServicesSupport();
- assertSame(support, support.getBeanContextServicesPeer());
- }
-
- public void testGetBeanContextServicesPeer_Another() {
- MockBeanContextServices services = new MockBeanContextServices();
- MockBeanContextServicesSupport support = new MockBeanContextServicesSupport(
- services);
- assertSame(services, support.getBeanContextServicesPeer());
- }
-
- public void testGetChildBeanContextServicesListener_NullParam() {
- BeanContextServicesListener result = MockBeanContextServicesSupport
- .publicGetChildBeanContextServicesListener(null);
- assertNull(result);
- }
-
- public void testGetChildBeanContextServicesListener_Is() {
- MockBeanContextServicesListener l = new MockBeanContextServicesListener();
- BeanContextServicesListener result = MockBeanContextServicesSupport
- .publicGetChildBeanContextServicesListener(l);
- assertSame(l, result);
- }
-
- public void testGetChildBeanContextServicesListener_IsNot() {
- BeanContextServicesListener result = MockBeanContextServicesSupport
- .publicGetChildBeanContextServicesListener("is not");
- assertNull(result);
- }
-
- public void testGetCurrentServiceClasses() {
- MockBeanContextServicesSupport support = new MockBeanContextServicesSupport();
- MockBeanContextServicesSupport childSupport = new MockBeanContextServicesSupport();
- support.add(childSupport);
- Iterator iter = support.getCurrentServiceClasses();
- assertFalse(iter.hasNext());
-
- MockBeanContextServiceProvider provider = new MockBeanContextServiceProvider();
- support.addService(Collection.class, provider);
- iter = support.getCurrentServiceClasses();
- assertTrue(iter.hasNext());
- assertSame(Collection.class, iter.next());
- iter.remove();
- assertFalse(iter.hasNext());
- assertEquals(1, support.services().size());
-
- iter = childSupport.getCurrentServiceClasses();
- assertFalse(iter.hasNext());
- }
-
- public void testGetCurrentServiceSelectors_NullParam() {
- MockBeanContextServicesSupport support = new MockBeanContextServicesSupport();
- Iterator iter = support.getCurrentServiceSelectors(null);
- assertNull(iter);
- }
-
- public void testGetCurrentServiceSelectors_NonExist() {
- MockBeanContextServicesSupport support = new MockBeanContextServicesSupport();
- Iterator iter = support.getCurrentServiceSelectors(Collection.class);
- assertNull(iter);
- // Regression for HARMONY-1397
- class TestServiceProvider implements BeanContextServiceProvider {
- public Object getService(BeanContextServices p0, Object p1,
- Class p2, Object p3) {
- return null;
- }
-
- public void releaseService(BeanContextServices p0, Object p1,
- Object p2) {
- }
-
- public Iterator getCurrentServiceSelectors(BeanContextServices p0,
- Class p1) {
- return null;
- }
- }
- support.addService(BeanContextServicesSupportTest.class,
- new TestServiceProvider());
- assertNotNull(support
- .getCurrentServiceSelectors(BeanContextServicesSupportTest.class));
- }
-
- public void testGetCurrentServiceSelectors() {
- MockBeanContextServicesSupport support = new MockBeanContextServicesSupport();
- MockBeanContextServiceProvider provider = new MockBeanContextServiceProvider();
- support.addService(Collection.class, provider);
-
- Iterator iter = support.getCurrentServiceSelectors(Collection.class);
- assertTrue(iter.hasNext());
- assertSame(Integer.class, iter.next());
- iter.remove();
- assertFalse(iter.hasNext());
- provider.records.assertRecord("getCurrentServiceSelectors", support,
- Collection.class, MethodInvocationRecords.IGNORE);
- provider.records.assertEndOfRecords();
- }
-
- public void testGetService_NullParam() throws TooManyListenersException {
- MockBeanContextServicesSupport support = new MockBeanContextServicesSupport();
- MockBeanContextServiceProvider provider = new MockBeanContextServiceProvider();
- support.addService(Collection.class, provider);
- MockBeanContextChild child = new MockBeanContextChild();
- support.add(child);
- Object requestor = "a requestor";
- Object selector = "a selector";
- MockBeanContextServiceRevokedListener l = new MockBeanContextServiceRevokedListener();
-
- try {
- support.getService(null, requestor, Collection.class, selector, l);
- fail();
- } catch (NullPointerException e) {
- // expected
- }
-
- try {
- support.getService(child, null, Collection.class, selector, l);
- fail();
- } catch (NullPointerException e) {
- // expected
- }
-
- try {
- support.getService(child, requestor, null, selector, l);
- fail();
- } catch (NullPointerException e) {
- // expected
- }
-
- Object result = support.getService(child, requestor, Collection.class,
- null, l);
- assertSame(Collections.EMPTY_SET, result);
- provider.records.assertRecord("getService", support, requestor,
- Collection.class, null, result);
- provider.records.assertEndOfRecords();
-
- try {
- support.getService(child, requestor, Collection.class, selector,
- null);
- fail("NPE expected");
- } catch (NullPointerException e) {
- // expected
- }
- }
-
- public void testGetService_NonChild() throws TooManyListenersException {
- MockBeanContextServicesSupport support = new MockBeanContextServicesSupport();
- MockBeanContextServiceProvider provider = new MockBeanContextServiceProvider();
- support.addService(Collection.class, provider);
- MockBeanContextChild child = new MockBeanContextChild();
- support.add(child);
- Object requestor = "a requestor";
- Object selector = "a selector";
- MockBeanContextServiceRevokedListener l = new MockBeanContextServiceRevokedListener();
-
- try {
- support.getService(new MockBeanContextChild(), requestor,
- Collection.class, selector, l);
- fail();
- } catch (IllegalArgumentException e) {
- // expected
- }
- provider.records.assertEndOfRecords();
- }
-
- public void testGetService_NoService() throws TooManyListenersException {
- MockBeanContextServicesSupport support = new MockBeanContextServicesSupport();
- MockBeanContextServiceProvider provider = new MockBeanContextServiceProvider();
- support.addService(Collection.class, provider);
- MockBeanContextChild child = new MockBeanContextChild();
- support.add(child);
- Object requestor = "a requestor";
- Object selector = "a selector";
- MockBeanContextServiceRevokedListener l = new MockBeanContextServiceRevokedListener();
-
- Object result = support.getService(child, requestor, List.class,
- selector, l);
- assertNull(result);
- }
-
- public void testGetService_ThisContext() throws TooManyListenersException {
- MockBeanContextServicesSupport support = new MockBeanContextServicesSupport();
- MockBeanContextServiceProvider provider = new MockBeanContextServiceProvider();
- support.addService(Collection.class, provider);
- MockBeanContextChild child = new MockBeanContextChild();
- support.add(child);
- Object requestor = "a requestor";
- Object selector = "a selector";
- MockBeanContextServicesListener l = new MockBeanContextServicesListener();
- support.records.clear();
-
- Object result = support.getService(child, requestor, Collection.class,
- selector, l);
- assertSame(Collections.EMPTY_SET, result);
- provider.records.assertRecord("getService", support, requestor,
- Collection.class, selector, result);
- provider.records.assertEndOfRecords();
- support.records.assertEndOfRecords();
-
- support.remove(child);
- support.records.assertRecord("childJustRemovedHook", child,
- MethodInvocationRecords.IGNORE, null);
- support.records.assertEndOfRecords();
- provider.records.assertRecord("releaseService", support, requestor,
- result, null);
- provider.records.assertEndOfRecords();
- assertNull(l.lastRevokedEvent);
- }
-
- public void testGetService_ParentContext() throws TooManyListenersException {
- MockBeanContextServicesSupport support = new MockBeanContextServicesSupport();
- MockBeanContextServicesSupport childSupport = new MockBeanContextServicesSupport();
- support.add(childSupport);
- MockBeanContextServiceProvider provider = new MockBeanContextServiceProvider();
- support.addService(Collection.class, provider);
- MockBeanContextChild child = new MockBeanContextChild();
- childSupport.add(child);
- Object requestor = "a requestor";
- Object selector = "a selector";
- MockBeanContextServicesListener l = new MockBeanContextServicesListener();
- support.records.clear();
- childSupport.records.clear();
-
- Object result = childSupport.getService(child, requestor,
- Collection.class, selector, l);
- assertSame(Collections.EMPTY_SET, result);
- provider.records.assertRecord("getService", support, requestor,
- Collection.class, selector, result);
- provider.records.assertEndOfRecords();
- support.records.assertEndOfRecords();
- childSupport.records.assertEndOfRecords();
-
- childSupport.remove(child);
- childSupport.records.assertRecord("childJustRemovedHook", child,
- MethodInvocationRecords.IGNORE, null);
- childSupport.records.assertEndOfRecords();
- provider.records.assertRecord("releaseService", support, requestor,
- result, null);
- provider.records.assertEndOfRecords();
- assertNull(l.lastRevokedEvent);
- }
-
- public void testHasService_NullParam() {
- MockBeanContextServicesSupport support = new MockBeanContextServicesSupport();
- try {
- support.hasService(null);
- fail();
- } catch (NullPointerException e) {
- // expected
- }
- }
-
- public void testHasService_ParentService() {
- MockBeanContextServicesSupport support = new MockBeanContextServicesSupport();
- MockBeanContextServicesSupport childSupport = new MockBeanContextServicesSupport();
- support.add(childSupport);
- assertFalse(childSupport.hasService(Collection.class));
-
- MockBeanContextServiceProvider provider = new MockBeanContextServiceProvider();
- support.addService(Collection.class, provider);
- assertTrue(childSupport.hasService(Collection.class));
- }
-
- public void testHasService_ThisService() {
- MockBeanContextServicesSupport support = new MockBeanContextServicesSupport();
- assertFalse(support.hasService(Collection.class));
-
- MockBeanContextServiceProvider provider = new MockBeanContextServiceProvider();
- support.addService(Collection.class, provider);
- assertTrue(support.hasService(Collection.class));
- }
-
- public void testInitialize() {
- // covered by other testcases
- }
-
- public void testInitializeBeanContextResources() {
- // covered by super testcases, nothing more to test here
- }
-
- public void testReleaseBeanContextResources()
- throws TooManyListenersException, PropertyVetoException {
- MockBeanContextServicesSupport support = new MockBeanContextServicesSupport();
- MockBeanContextServicesSupport childSupport = new MockBeanContextServicesSupport();
- support.add(childSupport);
- MockBeanContextServiceProvider provider = new MockBeanContextServiceProvider();
- support.addService(Collection.class, provider);
- MockBeanContextChild child = new MockBeanContextChild();
- childSupport.add(child);
- Object requestor = "a requestor";
- Object selector = "a selector";
- MockBeanContextServicesListener l = new MockBeanContextServicesListener();
- support.records.clear();
- childSupport.records.clear();
-
- Object result = childSupport.getService(child, requestor,
- Collection.class, selector, l);
- assertSame(Collections.EMPTY_SET, result);
- provider.records.assertRecord("getService", support, requestor,
- Collection.class, selector, result);
- provider.records.assertEndOfRecords();
- support.records.assertEndOfRecords();
- childSupport.records.assertEndOfRecords();
-
- childSupport.setBeanContext(null);
- support.records.assertRecord("childJustRemovedHook", childSupport,
- MethodInvocationRecords.IGNORE, null);
- support.records.assertEndOfRecords();
- childSupport.records.assertEndOfRecords();
- provider.records.assertRecord("releaseService", support, requestor,
- result, null);
- provider.records.assertEndOfRecords();
- assertSame(Collection.class, l.lastRevokedEvent.getServiceClass());
- assertSame(childSupport, l.lastRevokedEvent
- .getSourceAsBeanContextServices());
- assertTrue(l.lastRevokedEvent.isCurrentServiceInvalidNow());
- }
-
- public void testReleaseService_NullParam() throws TooManyListenersException {
- MockBeanContextServicesSupport support = new MockBeanContextServicesSupport();
- MockBeanContextServiceProvider provider = new MockBeanContextServiceProvider();
- support.addService(Collection.class, provider);
- MockBeanContextChild child = new MockBeanContextChild();
- support.add(child);
- Object requestor = "a requestor";
- Object selector = "a selector";
- MockBeanContextServicesListener l = new MockBeanContextServicesListener();
- support.records.clear();
-
- Object service = support.getService(child, requestor, Collection.class,
- selector, l);
- assertSame(Collections.EMPTY_SET, service);
- provider.records.assertRecord("getService", support, requestor,
- Collection.class, selector, service);
- provider.records.assertEndOfRecords();
- support.records.assertEndOfRecords();
-
- try {
- support.releaseService(null, requestor, service);
- fail();
- } catch (NullPointerException e) {
- // expected
- }
-
- try {
- support.releaseService(child, null, service);
- fail();
- } catch (NullPointerException e) {
- // expected
- }
-
- try {
- support.releaseService(child, requestor, null);
- fail();
- } catch (NullPointerException e) {
- // expected
- }
- }
-
- public void testReleaseService_WrongChildOrRequestor()
- throws TooManyListenersException {
- MockBeanContextServicesSupport support = new MockBeanContextServicesSupport();
- MockBeanContextServiceProvider provider = new MockBeanContextServiceProvider();
- support.addService(Collection.class, provider);
- MockBeanContextChild child = new MockBeanContextChild();
- support.add(child);
- Object requestor = "a requestor";
- Object selector = "a selector";
- MockBeanContextServiceRevokedListener l = new MockBeanContextServiceRevokedListener();
- support.records.clear();
-
- Object service = support.getService(child, requestor, Collection.class,
- selector, l);
- assertSame(Collections.EMPTY_SET, service);
- provider.records.assertRecord("getService", support, requestor,
- Collection.class, selector, service);
- provider.records.assertEndOfRecords();
- support.records.assertEndOfRecords();
-
- try {
- support.releaseService(new MockBeanContextChild(), requestor,
- service);
- fail();
- } catch (IllegalArgumentException e) {
- // expected
- }
-
- support.releaseService(child, "xxx", service); // nothing happens
- provider.records.assertEndOfRecords();
- assertNull(l.lastEvent);
- }
-
- public void testReleaseService_WrongService()
- throws TooManyListenersException {
- MockBeanContextServicesSupport support = new MockBeanContextServicesSupport();
- MockBeanContextServiceProvider provider = new MockBeanContextServiceProvider();
- support.addService(Collection.class, provider);
- MockBeanContextChild child = new MockBeanContextChild();
- support.add(child);
- Object requestor = "a requestor";
- Object selector = "a selector";
- MockBeanContextServiceRevokedListener l = new MockBeanContextServiceRevokedListener();
- support.records.clear();
-
- Object service = support.getService(child, requestor, Collection.class,
- selector, l);
- assertSame(Collections.EMPTY_SET, service);
- provider.records.assertRecord("getService", support, requestor,
- Collection.class, selector, service);
- provider.records.assertEndOfRecords();
- support.records.assertEndOfRecords();
-
- support.releaseService(child, requestor, "xxxx service"); // nothing
- // happens
- provider.records.assertEndOfRecords();
- assertNull(l.lastEvent);
- }
-
- /*
- * regression test for HARMONY-4272
- */
- public void testReleaseService_WithNullServiceRecords()
- throws TooManyListenersException {
- MockBeanContextServicesSupport support = new MockBeanContextServicesSupport();
- MockBeanContextChild child = new MockBeanContextChild();
- support.add(child);
- support.releaseService(child, child, new Object());
- }
-
- public void testReleaseService() throws TooManyListenersException,
- PropertyVetoException {
- MockBeanContextServicesSupport support = new MockBeanContextServicesSupport();
- MockBeanContextServicesSupport childSupport = new MockBeanContextServicesSupport();
- support.add(childSupport);
- MockBeanContextServiceProvider provider = new MockBeanContextServiceProvider();
- support.addService(Collection.class, provider);
- MockBeanContextChild child = new MockBeanContextChild();
- childSupport.add(child);
- Object requestor = "a requestor";
- Object selector = "a selector";
- MockBeanContextServicesListener l = new MockBeanContextServicesListener();
- support.records.clear();
- childSupport.records.clear();
-
- Object service = childSupport.getService(child, requestor,
- Collection.class, selector, l);
- assertSame(Collections.EMPTY_SET, service);
- provider.records.assertRecord("getService", support, requestor,
- Collection.class, selector, service);
- provider.records.assertEndOfRecords();
- support.records.assertEndOfRecords();
- childSupport.records.assertEndOfRecords();
-
- try {
- support.releaseService(child, requestor, service);
- fail();
- } catch (IllegalArgumentException e) {
- // expected
- }
-
- childSupport.releaseService(child, requestor, service);
- childSupport.records.assertEndOfRecords();
- support.records.assertEndOfRecords();
- provider.records.assertRecord("releaseService", support, requestor,
- service, null);
- provider.records.assertEndOfRecords();
- }
-
- public void testRemoveBeanContextServicesListener_NullParam() {
- MockBeanContextServicesSupport support = new MockBeanContextServicesSupport();
- try {
- support.removeBeanContextServicesListener(null);
- fail();
- } catch (NullPointerException e) {
- // expected
- }
- }
-
- public void testRemoveBeanContextServicesListener() {
- MockBeanContextServicesSupport support = new MockBeanContextServicesSupport();
- MockBeanContextServicesListener l = new MockBeanContextServicesListener();
- assertEquals(0, support.bcsListeners().size());
-
- support.addBeanContextServicesListener(l);
- assertEquals(1, support.bcsListeners().size());
- assertSame(l, support.bcsListeners().get(0));
-
- support.removeBeanContextServicesListener(l);
- assertEquals(0, support.bcsListeners().size());
- }
-
- public void testRevokeService_NullParam() {
- MockBeanContextServicesSupport support = new MockBeanContextServicesSupport();
- MockBeanContextServiceProvider provider = new MockBeanContextServiceProvider();
- support.addService(Collection.class, provider);
-
- try {
- support.revokeService(null, provider, false);
- fail();
- } catch (NullPointerException e) {
- // expected
- }
-
- try {
- support.revokeService(Collection.class, null, false);
- fail();
- } catch (NullPointerException e) {
- // expected
- }
- }
-
- public void testRevokeService_NonServiceClass() {
- MockBeanContextServicesSupport support = new MockBeanContextServicesSupport();
- MockBeanContextServicesListener l1 = new MockBeanContextServicesListener();
- support.addBeanContextServicesListener(l1);
- MockBeanContextServiceProvider provider = new MockBeanContextServiceProvider();
- support.addService(Collection.class, provider);
- support.records.clear();
- provider.records.clear();
-
- support.revokeService(List.class, provider, false);
- assertNull(l1.lastRevokedEvent);
- support.records.assertEndOfRecords();
- provider.records.assertEndOfRecords();
- }
-
- public void testRevokeService_NonWrongProvider() {
- MockBeanContextServicesSupport support = new MockBeanContextServicesSupport();
- MockBeanContextServicesListener l1 = new MockBeanContextServicesListener();
- support.addBeanContextServicesListener(l1);
- MockBeanContextServiceProvider provider = new MockBeanContextServiceProvider();
- support.addService(Collection.class, provider);
- support.records.clear();
- provider.records.clear();
-
- try {
- support.revokeService(Collection.class,
- new MockBeanContextServiceProvider(), false);
- fail();
- } catch (IllegalArgumentException e) {
- // expected
- }
- assertNull(l1.lastRevokedEvent);
- support.records.assertEndOfRecords();
- provider.records.assertEndOfRecords();
- }
-
- public void testRevokeService_ParentContext()
- throws TooManyListenersException {
- MockBeanContextServicesSupport support = new MockBeanContextServicesSupport();
- MockBeanContextServicesSupport childSupport = new MockBeanContextServicesSupport();
- support.add(childSupport);
- MockBeanContextServicesListener l1 = new MockBeanContextServicesListener();
- MockBeanContextServicesListener l2 = new MockBeanContextServicesListener();
- support.addBeanContextServicesListener(l1);
- childSupport.addBeanContextServicesListener(l2);
- support.records.assertRecord("initialize", null);
- childSupport.records.assertRecord("initialize", null);
-
- MockBeanContextServiceProvider provider = new MockBeanContextServiceProvider();
- support.addService(Collection.class, provider);
- MockBeanContextChild child = new MockBeanContextChild();
- childSupport.add(child);
- String requestor = "requestor";
- String selector = "selector";
- MockBeanContextServiceRevokedListener rl = new MockBeanContextServiceRevokedListener();
- Object service = childSupport.getService(child, requestor,
- Collection.class, selector, rl);
- assertNotNull(service);
-
- support.records.clear();
- childSupport.records.clear();
- provider.records.clear();
- l1.clearLastEvent();
- l2.clearLastEvent();
-
- support.revokeService(Collection.class, provider, false);
- assertEquals(0, support.services().size());
-
- support.records.assertEndOfRecords();
- childSupport.records.assertEndOfRecords();
- provider.records.assertEndOfRecords();
- assertSame(support, l1.lastRevokedEvent
- .getSourceAsBeanContextServices());
- assertSame(Collection.class, l1.lastRevokedEvent.getServiceClass());
- assertFalse(l1.lastRevokedEvent.isCurrentServiceInvalidNow());
- assertNull(l2.lastRevokedEvent);
- assertSame(childSupport, rl.lastEvent.getSourceAsBeanContextServices());
- assertSame(Collection.class, rl.lastEvent.getServiceClass());
- assertFalse(rl.lastEvent.isCurrentServiceInvalidNow());
-
- support.records.clear();
- childSupport.records.clear();
- provider.records.clear();
- l1.clearLastEvent();
- l2.clearLastEvent();
- rl.clearLastEvent();
-
- childSupport.releaseService(child, requestor, service);
-
- support.records.assertEndOfRecords();
- childSupport.records.assertEndOfRecords();
- provider.records.assertRecord("releaseService", support, requestor,
- service, null);
- provider.records.assertEndOfRecords();
- assertNull(rl.lastEvent);
- }
-
- public void testRevokeService_ChildContext()
- throws TooManyListenersException {
- MockBeanContextServicesSupport support = new MockBeanContextServicesSupport();
- MockBeanContextServicesSupport childSupport = new MockBeanContextServicesSupport();
- support.add(childSupport);
- MockBeanContextServicesListener l1 = new MockBeanContextServicesListener();
- MockBeanContextServicesListener l2 = new MockBeanContextServicesListener();
- support.addBeanContextServicesListener(l1);
- childSupport.addBeanContextServicesListener(l2);
- support.records.assertRecord("initialize", null);
- childSupport.records.assertRecord("initialize", null);
-
- MockBeanContextServiceProvider provider = new MockBeanContextServiceProvider();
- childSupport.addService(Collection.class, provider);
- MockBeanContextServices child = new MockBeanContextServices();
- childSupport.add(child);
- String requestor = "requestor";
- String selector = "selector";
- MockBeanContextServiceRevokedListener rl = new MockBeanContextServiceRevokedListener();
- Object service = childSupport.getService(child, requestor,
- Collection.class, selector, rl);
- assertNotNull(service);
-
- support.records.clear();
- childSupport.records.clear();
- provider.records.clear();
- l1.clearLastEvent();
- l2.clearLastEvent();
-
- childSupport.revokeService(Collection.class, provider, true);
- assertTrue(support.services().size() == 0);
-
- support.records.assertEndOfRecords();
- childSupport.records.assertEndOfRecords();
- provider.records.assertEndOfRecords();
- assertNull(l1.lastRevokedEvent);
- assertSame(childSupport, l2.lastRevokedEvent
- .getSourceAsBeanContextServices());
- assertSame(Collection.class, l2.lastRevokedEvent.getServiceClass());
- assertTrue(l2.lastRevokedEvent.isCurrentServiceInvalidNow());
- assertSame(childSupport, rl.lastEvent.getSourceAsBeanContextServices());
- assertSame(Collection.class, rl.lastEvent.getServiceClass());
- assertTrue(rl.lastEvent.isCurrentServiceInvalidNow());
- }
-
- public void testServiceAvailable() {
- // covered by testAddService
- }
-
- public void testServiceRevoked() {
- MockChildBeanContextServicesSupport mockChildBeanContextServicesSupport = new MockChildBeanContextServicesSupport();
- BeanContextServicesSupport beanContextServicesSupport = new BeanContextServicesSupport();
- beanContextServicesSupport.add(mockChildBeanContextServicesSupport);
- BeanContextServiceRevokedEvent beanContextServiceRevokedEvent = new BeanContextServiceRevokedEvent(new BeanContextServicesSupport(), Collection.class,false);
- beanContextServicesSupport.serviceRevoked(beanContextServiceRevokedEvent);
- assertTrue(mockChildBeanContextServicesSupport.revokeCalled);
- }
-
- public static class MockChildBeanContextServicesSupport extends
- BeanContextServicesSupport {
- private static final long serialVersionUID = 1L;
-
- public boolean revokeCalled = false;
-
- public void serviceRevoked(BeanContextServiceRevokedEvent bcssre) {
- revokeCalled = true;
- }
- }
-
- public void testSerialization() throws IOException, ClassNotFoundException {
- BeanContextServicesSupport support = new BeanContextServicesSupport(
- null, Locale.ITALY, true, true);
- support
- .addBeanContextServicesListener(new MockBeanContextServicesListener());
- support
- .addBeanContextServicesListener(new MockBeanContextServicesListenerS(
- "l2"));
- support
- .addBeanContextServicesListener(new MockBeanContextServicesListenerS(
- "l3"));
- support
- .addBeanContextServicesListener(new MockBeanContextServicesListener());
- support.addService(Collection.class,
- new MockBeanContextServiceProvider());
- support.addService(List.class,
- new MockBeanContextServiceProviderS("p1"));
- support
- .addService(Set.class,
- new MockBeanContextServiceProviderS("p2"));
- support.addService(Map.class, new MockBeanContextServiceProvider());
-
- assertEqualsSerially(support,
- (BeanContextServicesSupport) SerializationTester
- .getDeserilizedObject(support));
- }
-
-
- static int serviceRevoked = 0;
-
- static int serviceAvailable = 0;
-
- private static class MyListener implements BeanContextServicesListener {
-
- public void serviceRevoked(BeanContextServiceRevokedEvent event) {
- serviceRevoked++;
- }
-
- public void serviceAvailable(BeanContextServiceAvailableEvent event) {
- serviceAvailable++;
- }
-
- }
-
- private static class MySupport extends BeanContextServicesSupport {
-
- public void serviceRevoked(BeanContextServiceRevokedEvent event) {
- serviceRevoked++;
- }
-
- public void serviceAvailable(BeanContextServiceAvailableEvent event) {
- serviceAvailable++;
- }
- }
-
- private static class MyProvider implements BeanContextServiceProvider {
-
- public void releaseService(BeanContextServices s, Object requestor,
- Object service) {
- }
-
- public Iterator getCurrentServiceSelectors(BeanContextServices s,
- Class serviceClass) {
-
- return null;
- }
-
- public Object getService(BeanContextServices s, Object requestor,
- Class serviceClass, Object serviceSelector) {
-
- return null;
-
- }
-
- }
-
- public void test_serviceRevoked_LBeanContextServiceRevokedEvent() {
- BeanContextServicesSupport support = new BeanContextServicesSupport();
-
- support.add(new MySupport());
- support.addBeanContextServicesListener(new MyListener());
- Class c = Object.class;
-
- support.addService(c, new MyProvider());
-
- BeanContextServiceRevokedEvent revokeEvent = new BeanContextServiceRevokedEvent(
- support, c, false);
-
- support.serviceRevoked(revokeEvent);
- assertEquals(0, serviceRevoked);
- assertEquals(2, serviceAvailable);
-
- }
-
- public void test_serviceAvailable_LBeanContextServiceRevokedEvent() {
- BeanContextServicesSupport support = new BeanContextServicesSupport();
-
- support.add(new MySupport());
- support.addBeanContextServicesListener(new MyListener());
- Class c = Object.class;
-
- support.addService(c, new MyProvider());
-
- BeanContextServiceAvailableEvent availableEvent = new BeanContextServiceAvailableEvent(
- support, c);
- support.serviceAvailable(availableEvent);
- assertEquals(0, serviceRevoked);
- assertEquals(2, serviceAvailable);
-
- }
-
-
-
- public void testSerialization_Compatibility() throws Exception {
- BeanContextServicesSupport support = new BeanContextServicesSupport(
- null, Locale.ITALY, true, true);
- support
- .addBeanContextServicesListener(new MockBeanContextServicesListener());
- support
- .addBeanContextServicesListener(new MockBeanContextServicesListenerS(
- "l2"));
- support
- .addBeanContextServicesListener(new MockBeanContextServicesListenerS(
- "l3"));
- support
- .addBeanContextServicesListener(new MockBeanContextServicesListener());
- support.addService(Collection.class,
- new MockBeanContextServiceProvider());
- support.addService(List.class,
- new MockBeanContextServiceProviderS("p1"));
- support
- .addService(Set.class,
- new MockBeanContextServiceProviderS("p2"));
- support.addService(Map.class, new MockBeanContextServiceProvider());
- SerializationTest.verifyGolden(this, support, new SerializableAssert(){
- public void assertDeserialized(Serializable initial, Serializable deserialized) {
- assertEqualsSerially((BeanContextServicesSupport) initial,
- (BeanContextServicesSupport) deserialized);
- }
- });
- }
-
-
- public static void assertEqualsSerially(BeanContextServicesSupport orig,
- BeanContextServicesSupport ser) {
-
- // check bcsListeners
- ArrayList origBcsListeners = (ArrayList) Utils.getField(orig,
- "bcsListeners");
- ArrayList serBcsListeners = (ArrayList) Utils.getField(ser,
- "bcsListeners");
- int i = 0, j = 0;
- while (i < origBcsListeners.size()) {
- Object l1 = origBcsListeners.get(i);
- if (l1 instanceof Serializable) {
- Object l2 = serBcsListeners.get(j);
- assertSame(l1.getClass(), l2.getClass());
- if (l1 instanceof MockBeanContextServicesListenerS) {
- assertEquals(((MockBeanContextServicesListenerS) l1).id,
- ((MockBeanContextServicesListenerS) l2).id);
- }
- j++;
- }
- i++;
- }
- assertEquals(j, serBcsListeners.size());
-
- // check services
- HashMap origServices = (HashMap) Utils.getField(orig, "services");
- HashMap serServices = (HashMap) Utils.getField(ser, "services");
- int count = 0;
- for (Iterator iter = origServices.keySet().iterator(); iter.hasNext();) {
- Object serviceClass = iter.next();
- Object bcssProvider = origServices.get(serviceClass);
- Object provider = Utils.getField(bcssProvider, "serviceProvider");
- if (provider instanceof Serializable) {
- assertTrue(serServices.containsKey(serviceClass));
- if (provider instanceof MockBeanContextServiceProviderS) {
- Object serProvider = Utils.getField(serServices
- .get(serviceClass), "serviceProvider");
- assertEquals(
- ((MockBeanContextServiceProviderS) provider).id,
- ((MockBeanContextServiceProviderS) serProvider).id);
- }
- count++;
- }
- }
- assertEquals(count, serServices.size());
- }
-
- //Regression for HARMONY-3830
- public void testAddService_with_fireEvent_false() {
- MyBeanContextServicesSupport myBeanContextServicesSupport = new MyBeanContextServicesSupport();
- boolean result = myBeanContextServicesSupport.addService(
- MyService.class, new MyBeanContextServiceProvider(), false);
- assertTrue(result);
- }
-
- public static class MyBeanContextServicesSupport extends
- BeanContextServicesSupport {
- private static final long serialVersionUID = 1L;
-
- public boolean addService(Class serviceClass,
- BeanContextServiceProvider bcsp, boolean fireEvent) {
- return super.addService(serviceClass, bcsp, fireEvent);
- }
- }
-
- public static class MyService implements Serializable {
- private static final long serialVersionUID = 1L;
- }
-
- public static class MyBeanContextServiceProvider implements
- BeanContextServiceProvider {
- public Iterator getCurrentServiceSelectors(BeanContextServices arg0,
- Class arg1) {
- return null;
- }
-
- public Object getService(BeanContextServices arg0, Object arg1,
- Class arg2, Object arg3) {
- return null;
- }
-
- public void releaseService(BeanContextServices arg0, Object arg1,
- Object arg2) {
- }
- }
-
- /*
- * @see TestCase#setUp()
- */
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- serviceRevoked = 0;
- serviceAvailable = 0;
- }
-}
diff --git a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextSupport2Test.java b/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextSupport2Test.java
deleted file mode 100644
index 273d76f..0000000
--- a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextSupport2Test.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * 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.java.beans.beancontext;
-
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.beans.beancontext.BeanContextSupport;
-import java.beans.beancontext.BeanContextMembershipListener;
-import java.beans.beancontext.BeanContextMembershipEvent;
-import java.beans.beancontext.BeanContextChildSupport;
-import java.util.Locale;
-
-import junit.framework.TestCase;
-
-public class BeanContextSupport2Test extends TestCase {
-
- //Regression for HARMONY-3774.
- public void test_setLocale_null() throws Exception
- {
- Locale locale = Locale.FRANCE;
- BeanContextSupport beanContextSupport = new BeanContextSupport(null, locale);
- assertEquals(Locale.FRANCE, beanContextSupport.getLocale());
- MyPropertyChangeListener myPropertyChangeListener = new MyPropertyChangeListener();
- beanContextSupport.addPropertyChangeListener("locale", myPropertyChangeListener);
- beanContextSupport.setLocale(null);
- assertEquals(Locale.FRANCE, beanContextSupport.getLocale());
- assertFalse(myPropertyChangeListener.changed);
- }
-
- /**
- * Regression test for HARMONY-4011
- */
- public void test4011() {
- BeanContextSupport context = new BeanContextSupport();
- final int[] k = { 0 };
- BeanContextMembershipListener listener =
- new BeanContextMembershipListener() {
-
- public void childrenAdded(BeanContextMembershipEvent bcme) {
- k[0]++;
- }
-
- public void childrenRemoved(BeanContextMembershipEvent bcme) {}
- };
-
- // add listener
- context.addBeanContextMembershipListener(listener);
- context.add(new BeanContextChildSupport());
- assertEquals(1, k[0]);
-
- // add the same listener onse again
- context.addBeanContextMembershipListener(listener);
- context.add(new BeanContextChildSupport());
- assertEquals(2, k[0]);
- }
-
- private class MyPropertyChangeListener implements PropertyChangeListener {
- public boolean changed = false;
-
- public void propertyChange(PropertyChangeEvent event) {
- changed = true;
- }
-
- public void reset() {
- changed = false;
- }
-
- }
-
-}
diff --git a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextSupportTest.java b/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextSupportTest.java
deleted file mode 100644
index 06a1027..0000000
--- a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextSupportTest.java
+++ /dev/null
@@ -1,2270 +0,0 @@
-/*
- * 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.java.beans.beancontext;
-
-import java.awt.Button;
-import java.awt.Component;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyChangeSupport;
-import java.beans.PropertyVetoException;
-import java.beans.VetoableChangeListener;
-import java.beans.Visibility;
-import java.beans.beancontext.BeanContext;
-import java.beans.beancontext.BeanContextChild;
-import java.beans.beancontext.BeanContextChildSupport;
-import java.beans.beancontext.BeanContextMembershipEvent;
-import java.beans.beancontext.BeanContextMembershipListener;
-import java.beans.beancontext.BeanContextProxy;
-import java.beans.beancontext.BeanContextServicesSupport;
-import java.beans.beancontext.BeanContextSupport;
-import java.io.BufferedReader;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.Serializable;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Locale;
-
-import junit.framework.TestCase;
-
-import org.apache.harmony.beans.tests.support.beancontext.MethodInvocationRecords;
-import org.apache.harmony.beans.tests.support.beancontext.Utils;
-import org.apache.harmony.beans.tests.support.beancontext.mock.MockBeanContext;
-import org.apache.harmony.beans.tests.support.beancontext.mock.MockBeanContextChild;
-import org.apache.harmony.beans.tests.support.beancontext.mock.MockBeanContextChildS;
-import org.apache.harmony.beans.tests.support.beancontext.mock.MockBeanContextDelegateS;
-import org.apache.harmony.beans.tests.support.beancontext.mock.MockBeanContextMembershipListener;
-import org.apache.harmony.beans.tests.support.beancontext.mock.MockBeanContextMembershipListenerS;
-import org.apache.harmony.beans.tests.support.beancontext.mock.MockBeanContextProxy;
-import org.apache.harmony.beans.tests.support.beancontext.mock.MockBeanContextProxyS;
-import org.apache.harmony.beans.tests.support.beancontext.mock.MockPropertyChangeListener;
-import org.apache.harmony.beans.tests.support.beancontext.mock.MockVetoChangeListener;
-import org.apache.harmony.beans.tests.support.beancontext.mock.MockVetoableChangeListener;
-import org.apache.harmony.beans.tests.support.beancontext.mock.MockVisibility;
-import org.apache.harmony.testframework.serialization.SerializationTest;
-import org.apache.harmony.testframework.serialization.SerializationTest.SerializableAssert;
-
-import tests.util.SerializationTester;
-
-/**
- * Test BeanContextSupport
- */
-@SuppressWarnings("unchecked")
-public class BeanContextSupportTest extends TestCase {
-
- private static class MockBeanContextSupport extends BeanContextSupport {
-
- private static final long serialVersionUID = -4165267256277214588L;
-
- transient MethodInvocationRecords records;
-
- transient boolean vetoAddRemove = false;
-
- transient boolean waitOnChildInHooks = true;
-
- /**
- *
- */
- public MockBeanContextSupport() {
- super();
- }
-
- /**
- * @param peer
- */
- public MockBeanContextSupport(BeanContext peer) {
- super(peer);
- }
-
- /**
- * @param peer
- * @param lcle
- */
- public MockBeanContextSupport(BeanContext peer, Locale lcle) {
- super(peer, lcle);
- }
-
- /**
- * @param peer
- * @param lcle
- * @param dtime
- */
- public MockBeanContextSupport(BeanContext peer, Locale lcle,
- boolean dtime) {
- super(peer, lcle, dtime);
- }
-
- /**
- * @param peer
- * @param lcle
- * @param dTime
- * @param visible
- */
- public MockBeanContextSupport(BeanContext peer, Locale lcle,
- boolean dTime, boolean visible) {
- super(peer, lcle, dTime, visible);
- }
-
- public ArrayList bcmListeners() {
- return bcmListeners;
- }
-
- public Iterator publicBcsChildren() {
- return this.bcsChildren();
- }
-
- public static boolean publicClassEquals(Class c1, Class c2) {
- return classEquals(c1, c2);
- }
-
- public Object[] publicCopyChildren() {
- return copyChildren();
- }
-
- public static BeanContextChild publicGetChildBeanContextChild(
- Object child) {
- return getChildBeanContextChild(child);
- }
-
- public static BeanContextMembershipListener publicGetChildBeanContextMembershipListener(
- Object child) {
- return getChildBeanContextMembershipListener(child);
- }
-
- public static PropertyChangeListener publicGetChildPropertyChangeListener(
- Object child) {
- return getChildPropertyChangeListener(child);
- }
-
- public static Serializable publicGetChildSerializable(Object child) {
- return getChildSerializable(child);
- }
-
- public static VetoableChangeListener publicGetChildVetoableChangeListener(
- Object child) {
- return getChildVetoableChangeListener(child);
- }
-
- public static Visibility publicGetChildVisibility(Object child) {
- return getChildVisibility(child);
- }
-
- public boolean publicRemove(Object targetChild, boolean callChildBC) {
- return remove(targetChild, callChildBC);
- }
-
- public HashMap children() {
- return children;
- }
-
- public boolean designTime() {
- return designTime;
- }
-
- public Locale locale() {
- return locale;
- }
-
- public boolean isOkToUseGui() {
- return okToUseGui;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.beancontext.BeanContextSupport#bcsPreDeserializationHook(java.io.ObjectInputStream)
- */
- @Override
- protected void bcsPreDeserializationHook(ObjectInputStream ois)
- throws IOException, ClassNotFoundException {
- super.bcsPreDeserializationHook(ois);
- if (records == null) {
- records = new MethodInvocationRecords();
- }
- records.add("bcsPreDeserializationHook", ois, null);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.beancontext.BeanContextSupport#bcsPreSerializationHook(java.io.ObjectOutputStream)
- */
- @Override
- protected void bcsPreSerializationHook(ObjectOutputStream oos)
- throws IOException {
- super.bcsPreSerializationHook(oos);
- records.add("bcsPreSerializationHook", oos, null);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.beancontext.BeanContextSupport#childDeserializedHook(java.lang.Object,
- * java.beans.beancontext.BeanContextSupport.BCSChild)
- */
- @Override
- protected void childDeserializedHook(Object child, BCSChild bcsc) {
- super.childDeserializedHook(child, bcsc);
- records.add("childDeserializedHook", child, bcsc, null);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.beancontext.BeanContextSupport#childJustAddedHook(java.lang.Object,
- * java.beans.beancontext.BeanContextSupport.BCSChild)
- */
- @Override
- protected void childJustAddedHook(Object child, BCSChild bcsc) {
- if (waitOnChildInHooks) {
- // check lock
- try {
- child.wait(1);
- } catch (InterruptedException e) {
- // never occur
- }
- }
- super.childJustAddedHook(child, bcsc);
- records.add("childJustAddedHook", child, bcsc, null);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.beancontext.BeanContextSupport#childJustRemovedHook(java.lang.Object,
- * java.beans.beancontext.BeanContextSupport.BCSChild)
- */
- @Override
- protected void childJustRemovedHook(Object child, BCSChild bcsc) {
- if (waitOnChildInHooks) {
- // check lock
- try {
- child.wait(1);
- } catch (InterruptedException e) {
- // never occur
- }
- }
- super.childJustRemovedHook(child, bcsc);
- records.add("childJustRemovedHook", child, bcsc, null);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.beancontext.BeanContextSupport#createBCSChild(java.lang.Object,
- * java.lang.Object)
- */
- @Override
- protected BCSChild createBCSChild(Object targetChild, Object peer) {
- BCSChild result = super.createBCSChild(targetChild, peer);
- records.add("createBCSChild", targetChild, peer, result);
- return result;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.beancontext.BeanContextSupport#initialize()
- */
- @Override
- protected void initialize() {
- super.initialize();
- if (records == null) {
- records = new MethodInvocationRecords();
- }
- records.add("initialize", null);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
- */
- @Override
- public void propertyChange(PropertyChangeEvent pce) {
- super.propertyChange(pce);
- records.add("propertyChange", pce, null);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.beancontext.BeanContextSupport#validatePendingAdd(java.lang.Object)
- */
- @Override
- protected boolean validatePendingAdd(Object targetChild) {
- boolean result = vetoAddRemove ? false : super
- .validatePendingAdd(targetChild);
- records.add("validatePendingAdd", targetChild, Boolean
- .valueOf(result));
- return result;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.beancontext.BeanContextSupport#validatePendingRemove(java.lang.Object)
- */
- @Override
- protected boolean validatePendingRemove(Object targetChild) {
- boolean result = vetoAddRemove ? false : super
- .validatePendingRemove(targetChild);
- records.add("validatePendingRemove", targetChild, Boolean
- .valueOf(result));
- return result;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.VetoableChangeListener#vetoableChange(java.beans.PropertyChangeEvent)
- */
- @Override
- public void vetoableChange(PropertyChangeEvent pce)
- throws PropertyVetoException {
- super.vetoableChange(pce);
- records.add("vetoableChange", pce, null);
- }
- }
-
- private static class BadChild implements BeanContextChild, BeanContextProxy {
-
- public void setBeanContext(BeanContext bc) throws PropertyVetoException {
- // Auto-generated method stub
- }
-
- public BeanContext getBeanContext() {
- // Auto-generated method stub
- return null;
- }
-
- public void addPropertyChangeListener(String name,
- PropertyChangeListener pcl) {
- // Auto-generated method stub
- }
-
- public void removePropertyChangeListener(String name,
- PropertyChangeListener pcl) {
- // Auto-generated method stub
- }
-
- public void addVetoableChangeListener(String name,
- VetoableChangeListener vcl) {
- // Auto-generated method stub
- }
-
- public void removeVetoableChangeListener(String name,
- VetoableChangeListener vcl) {
- // Auto-generated method stub
- }
-
- public BeanContextChild getBeanContextProxy() {
- // Auto-generated method stub
- return null;
- }
- }
-
- public void testAdd_NullParam() {
- MockBeanContextSupport support = new MockBeanContextSupport();
-
- try {
- support.add(null);
- fail();
- } catch (IllegalArgumentException e) {
- // expected
- }
- }
-
- public void testAdd_NonBCC() {
- MockBeanContextSupport support = new MockBeanContextSupport();
- MockBeanContextMembershipListener l1 = new MockBeanContextMembershipListener();
- MockPropertyChangeListener l2 = new MockPropertyChangeListener();
- MockVetoableChangeListener l3 = new MockVetoableChangeListener();
- support.addBeanContextMembershipListener(l1);
- support.addPropertyChangeListener("children", l2);
- support.addVetoableChangeListener("children", l3);
-
- Integer child = new Integer(1000);
- support.add(child);
- support.records.assertRecord("initialize", null);
- support.records.assertRecord("validatePendingAdd", child, Boolean.TRUE);
- support.records.assertRecord("createBCSChild", child, null, support
- .children().get(child));
- support.records.assertRecord("childJustAddedHook", child, support
- .children().get(child), null);
- support.records.assertEndOfRecords();
- assertTrue(l1.lastEventAdd);
- assertMembershipEvent(l1.lastEvent, support, null, child);
- assertNull(l2.lastEvent);
- assertNull(l3.lastEvent);
- }
-
- public void testAdd_BCC() {
- MockBeanContextSupport support = new MockBeanContextSupport();
- MockBeanContextMembershipListener l1 = new MockBeanContextMembershipListener();
- MockPropertyChangeListener l2 = new MockPropertyChangeListener();
- MockVetoableChangeListener l3 = new MockVetoableChangeListener();
- support.addBeanContextMembershipListener(l1);
- support.addPropertyChangeListener("children", l2);
- support.addVetoableChangeListener("children", l3);
-
- BeanContextChild child = new MockBeanContextChild();
- support.add(child);
- support.records.assertRecord("initialize", null);
- support.records.assertRecord("validatePendingAdd", child, Boolean.TRUE);
- support.records.assertRecord("createBCSChild", child, null, support
- .children().get(child));
- support.records.assertRecord("childJustAddedHook", child, support
- .children().get(child), null);
- support.records.assertEndOfRecords();
- assertTrue(l1.lastEventAdd);
- assertMembershipEvent(l1.lastEvent, support, null, child);
- assertNull(l2.lastEvent);
- assertNull(l3.lastEvent);
-
- assertSame(support, child.getBeanContext());
- }
-
- public void testAdd_BCP() {
- MockBeanContextSupport support = new MockBeanContextSupport();
- support.waitOnChildInHooks = false;
- MockBeanContextMembershipListener l1 = new MockBeanContextMembershipListener();
- MockPropertyChangeListener l2 = new MockPropertyChangeListener();
- MockVetoableChangeListener l3 = new MockVetoableChangeListener();
- support.addBeanContextMembershipListener(l1);
- support.addPropertyChangeListener("children", l2);
- support.addVetoableChangeListener("children", l3);
-
- BeanContextChild childPeer = new MockBeanContextChild();
- BeanContextProxy child = new MockBeanContextProxy(childPeer);
- support.add(child);
- support.records.assertRecord("initialize", null);
- support.records.assertRecord("validatePendingAdd", child, Boolean.TRUE);
- support.records.assertRecord("createBCSChild", child, childPeer,
- support.children().get(child));
- support.records.assertRecord("createBCSChild", childPeer, child,
- support.children().get(childPeer));
- support.records.assertRecord("childJustAddedHook", child, support
- .children().get(child), null);
- support.records.assertRecord("childJustAddedHook", childPeer, support
- .children().get(childPeer), null);
- support.records.assertEndOfRecords();
- assertTrue(l1.lastEventAdd);
- assertMembershipEvent(l1.lastEvent, support, null, Arrays
- .asList(new Object[] { child, childPeer }));
- assertNull(l2.lastEvent);
- assertNull(l3.lastEvent);
-
- assertSame(support, childPeer.getBeanContext());
- assertEquals(2, support.size());
- }
-
- public void testAdd_Exist() {
- MockBeanContextSupport support = new MockBeanContextSupport();
- MockBeanContextMembershipListener l1 = new MockBeanContextMembershipListener();
- support.addBeanContextMembershipListener(l1);
- Integer child = new Integer(1000);
- support.add(child);
- support.records.assertRecord("initialize", null);
- support.records.assertRecord("validatePendingAdd", child, Boolean.TRUE);
- support.records.assertRecord("createBCSChild", child, null, support
- .children().get(child));
- support.records.assertRecord("childJustAddedHook", child, support
- .children().get(child), null);
- support.records.assertEndOfRecords();
- assertTrue(l1.lastEventAdd);
- assertMembershipEvent(l1.lastEvent, support, null, child);
- support.records.clear();
- l1.clearLastEvent();
-
- support.add(child);
- support.records.assertEndOfRecords();
- assertNull(l1.lastEvent);
- }
-
- public void testAdd_Veto() {
- MockBeanContextSupport support = new MockBeanContextSupport();
- MockBeanContextMembershipListener l1 = new MockBeanContextMembershipListener();
- MockPropertyChangeListener l2 = new MockPropertyChangeListener();
- MockVetoableChangeListener l3 = new MockVetoableChangeListener();
- support.addBeanContextMembershipListener(l1);
- support.addPropertyChangeListener("children", l2);
- support.addVetoableChangeListener("children", l3);
-
- support.vetoAddRemove = true;
- BeanContextChild child = new MockBeanContextChild();
- try {
- support.add(child);
- fail();
- } catch (IllegalStateException e) {
- // expected
- }
- support.records.assertRecord("initialize", null);
- support.records
- .assertRecord("validatePendingAdd", child, Boolean.FALSE);
- support.records.assertEndOfRecords();
- assertNull(l1.lastEvent);
- assertNull(l2.lastEvent);
- assertNull(l3.lastEvent);
-
- assertNull(child.getBeanContext());
- }
-
- public void testAddAll() {
- MockBeanContextSupport support = new MockBeanContextSupport();
- MockBeanContextMembershipListener l1 = new MockBeanContextMembershipListener();
- MockPropertyChangeListener l2 = new MockPropertyChangeListener();
- MockVetoableChangeListener l3 = new MockVetoableChangeListener();
- support.addBeanContextMembershipListener(l1);
- support.addPropertyChangeListener("children", l2);
- support.addVetoableChangeListener("children", l3);
- support.records.assertRecord("initialize", null);
-
- try {
- //Regression for HARMONY-2350
- support.addAll(Collections.EMPTY_LIST);
- fail();
- } catch (UnsupportedOperationException e) {
- // expected
- }
- support.records.assertEndOfRecords();
- assertNull(l1.lastEvent);
- assertNull(l2.lastEvent);
- assertNull(l3.lastEvent);
- }
-
- public void testAddBeanContextMembershipListener_NullParam() {
- MockBeanContextSupport support = new MockBeanContextSupport();
- try {
- support.addBeanContextMembershipListener(null);
- fail();
- } catch (NullPointerException e) {
- // expected
- }
- }
-
- public void testAddBeanContextMembershipListener() {
- MockBeanContextSupport support = new MockBeanContextSupport();
- MockBeanContextMembershipListener l1 = new MockBeanContextMembershipListener();
- MockBeanContextMembershipListener l2 = new MockBeanContextMembershipListener();
-
- support.addBeanContextMembershipListener(l1);
- support.addBeanContextMembershipListener(l2);
-
- l1.clearLastEvent();
- l2.clearLastEvent();
- Object child = new MockBeanContextChild();
- support.add(child);
- assertTrue(l1.lastEventAdd);
- assertMembershipEvent(l1.lastEvent, support, null, child);
- assertTrue(l2.lastEventAdd);
- assertMembershipEvent(l2.lastEvent, support, null, child);
-
- l1.clearLastEvent();
- l2.clearLastEvent();
- support.add(child);
- assertNull(l1.lastEvent);
- assertNull(l2.lastEvent);
-
- support.removeBeanContextMembershipListener(l1);
- l1.clearLastEvent();
- l2.clearLastEvent();
- support.remove(child);
- assertNull(l1.lastEvent);
- assertTrue(l2.lastEventRemove);
- assertMembershipEvent(l2.lastEvent, support, null, child);
- }
-
- public void testAvoidingGui() {
- MockBeanContextSupport support = new MockBeanContextSupport();
-
- assertTrue(support.isOkToUseGui());
- assertFalse(support.avoidingGui());
- assertFalse(support.needsGui());
-
- support.dontUseGui();
- assertFalse(support.isOkToUseGui());
- // assertFalse(support.avoidingGui());
- assertFalse(support.needsGui());
-
- support.okToUseGui();
- assertTrue(support.isOkToUseGui());
- assertFalse(support.avoidingGui());
- assertFalse(support.needsGui());
- }
-
- public void testAvoidingGui_VisibleChild() {
- MockBeanContextSupport support = new MockBeanContextSupport();
- support.add(new MockVisibility(true, false));
- assertFalse(support.avoidingGui());
- }
-
- public void testBcsChildren() {
- MockBeanContextSupport support = new MockBeanContextSupport();
- support.add(new Integer(1));
- support.add(new MockBeanContextChild());
-
- Collection expectedChildren = support.children().values();
- Iterator it = support.publicBcsChildren();
- int count = 0;
- while (it.hasNext()) {
- count++;
- assertTrue(expectedChildren.contains(it.next()));
- }
- assertEquals(count, expectedChildren.size());
- }
-
- public void testBcsPreDeserializationHook() {
- MockBeanContextSupport support = new MockBeanContextSupport();
- support.add("string value");
- support.add(new Integer(129));
- support.add(Locale.CHINESE);
- support.records.clear();
-
- byte bytes[] = serialize(support);
- support.records.assertRecord("bcsPreSerializationHook",
- MethodInvocationRecords.IGNORE, null);
- support.records.assertEndOfRecords();
-
- MockBeanContextSupport copy = (MockBeanContextSupport) deserialize(bytes);
- copy.records.assertRecord("initialize", null);
- copy.records.assertRecord("bcsPreDeserializationHook",
- MethodInvocationRecords.IGNORE, null);
- Iterator it = support.iterator();
- while (it.hasNext()) {
- Object expectedChild = it.next();
- assertTrue(copy.contains(expectedChild));
- copy.records.assertRecord("childDeserializedHook", expectedChild,
- MethodInvocationRecords.IGNORE, null);
- }
- copy.records.assertEndOfRecords();
- }
-
- public void testBcsPreSerializationHook() {
- MockBeanContextSupport support = new MockBeanContextSupport();
- support.add("string value");
- support.add(new Integer(129));
- support.add(Locale.CHINESE);
- support.records.clear();
-
- serialize(support);
- support.records.assertRecord("bcsPreSerializationHook",
- MethodInvocationRecords.IGNORE, null);
- support.records.assertEndOfRecords();
- }
-
- /*
- * Class under test for void BeanContextSupport()
- */
- public void testBeanContextSupport() {
- MockBeanContextSupport support = new MockBeanContextSupport();
-
- assertSame(support, support.getBeanContextPeer());
- assertTrue(support.bcmListeners().isEmpty());
- assertTrue(support.children().isEmpty());
- assertFalse(support.designTime());
- assertEquals(Locale.getDefault(), support.locale());
- assertTrue(support.isOkToUseGui());
- }
-
- /*
- * Class under test for void
- * BeanContextSupport(java.beans.beancontext.BeanContext)
- */
- public void testBeanContextSupportBeanContext() {
- BeanContext ctx = new MockBeanContext();
- MockBeanContextSupport support = new MockBeanContextSupport(ctx);
-
- assertSame(ctx, support.getBeanContextPeer());
- assertTrue(support.bcmListeners().isEmpty());
- assertTrue(support.children().isEmpty());
- assertFalse(support.designTime());
- assertEquals(Locale.getDefault(), support.locale());
- assertTrue(support.isOkToUseGui());
- }
-
- /*
- * Class under test for void
- * BeanContextSupport(java.beans.beancontext.BeanContext, java.util.Locale)
- */
- public void testBeanContextSupportBeanContextLocale() {
- BeanContext ctx = new MockBeanContext();
- MockBeanContextSupport support = new MockBeanContextSupport(ctx,
- Locale.CANADA_FRENCH);
-
- assertSame(ctx, support.getBeanContextPeer());
- assertTrue(support.bcmListeners().isEmpty());
- assertTrue(support.children().isEmpty());
- assertFalse(support.designTime());
- assertEquals(Locale.CANADA_FRENCH, support.locale());
- assertTrue(support.isOkToUseGui());
- }
-
- /*
- * Class under test for void
- * BeanContextSupport(java.beans.beancontext.BeanContext, java.util.Locale,
- * boolean)
- */
- public void testBeanContextSupportBeanContextLocaleboolean() {
- BeanContext ctx = new MockBeanContext();
- MockBeanContextSupport support = new MockBeanContextSupport(ctx,
- Locale.CANADA_FRENCH, true);
-
- assertSame(ctx, support.getBeanContextPeer());
- assertTrue(support.bcmListeners().isEmpty());
- assertTrue(support.children().isEmpty());
- assertTrue(support.designTime());
- assertEquals(Locale.CANADA_FRENCH, support.locale());
- assertTrue(support.isOkToUseGui());
- }
-
- /*
- * Class under test for void
- * BeanContextSupport(java.beans.beancontext.BeanContext, java.util.Locale,
- * boolean, boolean)
- */
- public void testBeanContextSupportBeanContextLocalebooleanboolean() {
- BeanContext ctx = new MockBeanContext();
- MockBeanContextSupport support = new MockBeanContextSupport(ctx,
- Locale.CANADA_FRENCH, true, false);
-
- assertSame(ctx, support.getBeanContextPeer());
- assertTrue(support.bcmListeners().isEmpty());
- assertTrue(support.children().isEmpty());
- assertTrue(support.designTime());
- assertEquals(Locale.CANADA_FRENCH, support.locale());
- assertFalse(support.isOkToUseGui());
- }
-
- public void testBeanContextSupport_NullParam() {
- MockBeanContextSupport support = new MockBeanContextSupport(null, null,
- true, true);
- assertSame(support, support.getBeanContextPeer());
- assertTrue(support.children().isEmpty());
- assertTrue(support.designTime());
- assertEquals(Locale.getDefault(), support.locale());
- assertTrue(support.isOkToUseGui());
- }
-
- public void testChildDeserializedHook() {
- MockBeanContextSupport support = new MockBeanContextSupport();
- support.add("string value");
- support.add(new Integer(129));
- support.add(Locale.CHINESE);
- support.records.clear();
-
- byte bytes[] = serialize(support);
- support.records.assertRecord("bcsPreSerializationHook",
- MethodInvocationRecords.IGNORE, null);
- support.records.assertEndOfRecords();
-
- MockBeanContextSupport copy = (MockBeanContextSupport) deserialize(bytes);
- copy.records.assertRecord("initialize", null);
- copy.records.assertRecord("bcsPreDeserializationHook",
- MethodInvocationRecords.IGNORE, null);
- Iterator it = support.iterator();
- while (it.hasNext()) {
- Object expectedChild = it.next();
- assertTrue(copy.contains(expectedChild));
- copy.records.assertRecord("childDeserializedHook", expectedChild,
- MethodInvocationRecords.IGNORE, null);
- }
- copy.records.assertEndOfRecords();
- }
-
- public void testChildJustAddedHook() {
- // covered by testAdd
- }
-
- public void testChildJustRemovedHook() {
- // covered by testRemove
- }
-
- public void testClassEquals() {
- assertTrue(MockBeanContextSupport.publicClassEquals(Integer.class,
- Integer.class));
- assertFalse(MockBeanContextSupport.publicClassEquals(Integer.class,
- Double.class));
- try {
- MockBeanContextSupport.publicClassEquals(null, null);
- fail("should throw NullPointerException");
- } catch (NullPointerException e) {
- // expected.
- }
- }
-
- public void testClear() {
- MockBeanContextSupport support = new MockBeanContextSupport();
- try {
- support.clear();
- fail();
- } catch (UnsupportedOperationException e) {
- // expected
- }
- }
-
- public void testContains() {
- MockBeanContextSupport support = new MockBeanContextSupport();
- Object c1 = "string value";
- Object c2 = new Integer(129);
- Object c3 = new MockBeanContextChild();
- support.add(c1);
- support.add(c2);
- support.add(c3);
-
- assertTrue(support.children().containsKey(c1));
- assertTrue(support.children().containsKey(c2));
- assertTrue(support.children().containsKey(c3));
- assertFalse(support.children().containsKey(null));
- assertFalse(support.children().containsKey("xxx"));
- assertEquals(3, support.children().size());
-
- assertTrue(support.contains(c1));
- assertTrue(support.contains(c2));
- assertTrue(support.contains(c3));
- assertFalse(support.contains(null));
- assertFalse(support.contains("xxx"));
- assertEquals(3, support.size());
- }
-
- public void testContainsAll() {
- MockBeanContextSupport support = new MockBeanContextSupport();
- Object c1 = "string value";
- Object c2 = new Integer(129);
- Object c3 = new MockBeanContextChild();
- support.add(c1);
- support.add(c2);
- support.add(c3);
- ArrayList<Object> l = new ArrayList<Object>();
- l.add(c1);
- l.add(c2);
- l.add(c3);
-
- assertTrue(support.containsAll(l));
- l.add(null);
- assertFalse(support.containsAll(l));
- }
-
- public void testContainsKey() {
- MockBeanContextSupport support = new MockBeanContextSupport();
- Object c1 = "string value";
- Object c2 = new Integer(129);
- Object c3 = new MockBeanContextChild();
- support.add(c1);
- support.add(c2);
- support.add(c3);
-
- assertTrue(support.children().containsKey(c1));
- assertTrue(support.children().containsKey(c2));
- assertTrue(support.children().containsKey(c3));
- assertFalse(support.children().containsKey(null));
- assertFalse(support.children().containsKey("xxx"));
- assertEquals(3, support.children().size());
-
- assertTrue(support.containsKey(c1));
- assertTrue(support.containsKey(c2));
- assertTrue(support.containsKey(c3));
- assertFalse(support.containsKey(null));
- assertFalse(support.containsKey("xxx"));
- assertEquals(3, support.size());
- }
-
- public void testCopyChildren() {
- MockBeanContextSupport support = new MockBeanContextSupport();
- Object c1 = "string value";
- Object c2 = new Integer(129);
- Object c3 = new MockBeanContextChild();
- support.add(c1);
- support.add(c2);
- support.add(c3);
-
- Object children[] = support.publicCopyChildren();
- List<Object> childrenList = Arrays.asList(children);
- assertEquals(3, childrenList.size());
- assertTrue(childrenList.contains(c1));
- assertTrue(childrenList.contains(c2));
- assertTrue(childrenList.contains(c3));
- }
-
- public void testCreateBCSChild() {
- // covered by testAdd
- }
-
- public void testDeserialize() {
- // covered by testBcsPreDeserializationHook()
- }
-
- public void testDontUseGui() {
- MockBeanContextSupport support = new MockBeanContextSupport();
-
- assertTrue(support.isOkToUseGui());
- assertFalse(support.avoidingGui()); // always false
- assertFalse(support.needsGui()); // always false
-
- support.dontUseGui();
- assertFalse(support.isOkToUseGui());
- // assertFalse(support.avoidingGui()); // always false?
- assertFalse(support.needsGui()); // always false
- }
-
- public void testFireChildrenAdded() {
- // covered by testAdd
- }
-
- public void testFireChildrenRemoved() {
- // covered by testRemove
- }
-
- public void testGetBeanContextPeer() {
- // covered by testConstructor
- }
-
- public void testGetChildBeanContextChild_NullParam() {
- BeanContextChild result = MockBeanContextSupport
- .publicGetChildBeanContextChild(null);
- assertNull(result);
- }
-
- public void testGetChildBeanContextChild_BeanContextChild() {
- MockBeanContextChild child = new MockBeanContextChild();
- BeanContextChild result = MockBeanContextSupport
- .publicGetChildBeanContextChild(child);
- assertSame(child, result);
-
- // Regression for HARMONY-1393
- class TestBeanException extends BeanContextChildSupport implements
- BeanContextProxy {
- private static final long serialVersionUID = -8544245159647566063L;
- private final BeanContextChildSupport childSupport = new BeanContextChildSupport();
-
- public BeanContextChild getBeanContextProxy() {
- return childSupport;
- }
- }
- TestBeanException bean = new TestBeanException();
- try {
- MockBeanContextSupport.publicGetChildBeanContextChild(bean);
- fail("IllegalArgumentException expected");
- } catch (IllegalArgumentException e) {
- // expected
- }
- }
-
- public void testGetChildBeanContextChild_BeanContextProxy() {
- MockBeanContextChild child = new MockBeanContextChild();
- MockBeanContextProxy proxy = new MockBeanContextProxy(child);
- BeanContextChild result = MockBeanContextSupport
- .publicGetChildBeanContextChild(proxy);
- assertSame(child, result);
- }
-
- public void testGetChildBeanContextChild_Neither() {
- Integer child = new Integer(129);
- BeanContextChild result = MockBeanContextSupport
- .publicGetChildBeanContextChild(child);
- assertNull(result);
- }
-
- public void testGetChildBeanContextChild_Both() {
- try {
- MockBeanContextSupport
- .publicGetChildBeanContextChild(new BadChild());
- fail();
- } catch (IllegalArgumentException e) {
- // expected
- }
- }
-
- public void testGetChildBeanContextMembershipListener_NullParam() {
- BeanContextMembershipListener result = MockBeanContextSupport
- .publicGetChildBeanContextMembershipListener(null);
- assertNull(result);
- }
-
- public void testGetChildBeanContextMembershipListener() {
- MockBeanContextMembershipListener child = new MockBeanContextMembershipListener();
- BeanContextMembershipListener result = MockBeanContextSupport
- .publicGetChildBeanContextMembershipListener(child);
- assertSame(child, result);
- }
-
- public void testGetChildBeanContextMembershipListener_WrongClass() {
- BeanContextMembershipListener result = MockBeanContextSupport
- .publicGetChildBeanContextMembershipListener(new Integer(129));
- assertNull(result);
- }
-
- public void testGetChildPropertyChangeListener_NullParam() {
- PropertyChangeListener result = MockBeanContextSupport
- .publicGetChildPropertyChangeListener(null);
- assertNull(result);
- }
-
- public void testGetChildPropertyChangeListener() {
- MockBeanContextSupport child = new MockBeanContextSupport();
- PropertyChangeListener result = MockBeanContextSupport
- .publicGetChildPropertyChangeListener(child);
- assertSame(child, result);
- }
-
- public void testGetChildPropertyChangeListener_WrongClass() {
- PropertyChangeListener result = MockBeanContextSupport
- .publicGetChildPropertyChangeListener(new Integer(129));
- assertNull(result);
- }
-
- public void testGetChildSerializable_NullParam() {
- Serializable result = MockBeanContextSupport
- .publicGetChildSerializable(null);
- assertNull(result);
- }
-
- public void testGetChildSerializable() {
- MockBeanContextSupport child = new MockBeanContextSupport();
- Serializable result = MockBeanContextSupport
- .publicGetChildSerializable(child);
- assertSame(child, result);
- }
-
- public void testGetChildSerializable_WrongClass() {
- Serializable result = MockBeanContextSupport
- .publicGetChildSerializable(new BadChild());
- assertNull(result);
- }
-
- public void testGetChildVetoableChangeListener_NullParam() {
- VetoableChangeListener result = MockBeanContextSupport
- .publicGetChildVetoableChangeListener(null);
- assertNull(result);
- }
-
- public void testGetChildVetoableChangeListener() {
- MockBeanContextSupport child = new MockBeanContextSupport();
- VetoableChangeListener result = MockBeanContextSupport
- .publicGetChildVetoableChangeListener(child);
- assertSame(child, result);
- }
-
- public void testGetChildVetoableChangeListener_WrongClass() {
- VetoableChangeListener result = MockBeanContextSupport
- .publicGetChildVetoableChangeListener(new Integer(129));
- assertNull(result);
- }
-
- public void testGetChildVisibility_NullParam() {
- Visibility result = MockBeanContextSupport
- .publicGetChildVisibility(null);
- assertNull(result);
- }
-
- public void testGetChildVisibility() {
- MockBeanContextSupport child = new MockBeanContextSupport();
- Visibility result = MockBeanContextSupport
- .publicGetChildVisibility(child);
- assertSame(child, result);
- }
-
- public void testGetChildVisibility_WrongClass() {
- Visibility result = MockBeanContextSupport
- .publicGetChildVisibility(new Integer(129));
- assertNull(result);
- }
-
- public void testGetLocale() throws PropertyVetoException {
- BeanContext ctx = new MockBeanContext();
- MockBeanContextSupport support = new MockBeanContextSupport(ctx,
- Locale.CANADA_FRENCH);
-
- assertSame(Locale.CANADA_FRENCH, support.getLocale());
-
- support.setLocale(Locale.CHINA);
- assertSame(Locale.CHINA, support.getLocale());
- }
-
- public void testGetResource_NullParam() {
- MockBeanContextSupport support = new MockBeanContextSupport();
- MockBeanContextChild child = new MockBeanContextChild();
- support.add(child);
-
- try {
- support.getResource(null, child);
- fail();
- } catch (NullPointerException e) {
- // expected
- }
-
- try {
- support.getResource("", null);
- fail("NPE expected");
- } catch (NullPointerException e) {
- // expected
- }
- }
-
- public void testGetResource_NonChild() {
- MockBeanContextSupport support = new MockBeanContextSupport();
- MockBeanContextChild child = new MockBeanContextChild();
-
- try {
- support.getResource("", child);
- fail("IAE expected");
- } catch (IllegalArgumentException e) {
- // expected
- }
- }
-
- public void testGetResource_NotExist() {
- MockBeanContextSupport support = new MockBeanContextSupport();
- MockBeanContextChild child = new MockBeanContextChild();
- support.add(child);
-
- URL url = support
- .getResource(
- "org/apache/harmony/beans/tests/java/beans/beancontext/mock/nonexist",
- child);
- assertNull(url);
- }
-
- public void testGetResource() {
- MockBeanContextSupport support = new MockBeanContextSupport();
- MockBeanContextChild child = new MockBeanContextChild();
- support.add(child);
-
- final String RESOURCE_NAME = "org/apache/harmony/beans/tests/support/beancontext/mock/mockdata.txt";
- URL url = support.getResource(RESOURCE_NAME, child);
- assertTrue(url.toString().endsWith(RESOURCE_NAME));
-
- BeanContextSupport beanContextSupport = new BeanContextSupport();
- beanContextSupport.add(child);
- url = beanContextSupport.getResource(RESOURCE_NAME, child);
- assertTrue(url.toString().endsWith(RESOURCE_NAME));
- }
-
- public void testGetResourceAsStream_NullParam() {
- MockBeanContextSupport support = new MockBeanContextSupport();
- MockBeanContextChild child = new MockBeanContextChild();
- support.add(child);
-
- try {
- support.getResourceAsStream(null, child);
- fail("NPE expected");
- } catch (NullPointerException e) {
- // expected
- }
-
- try {
- support.getResourceAsStream("", null);
- fail("NPE expected");
- } catch (NullPointerException e) {
- // expected
- }
- }
-
- public void testGetResourceAsStream_NonChild() {
- MockBeanContextSupport support = new MockBeanContextSupport();
- MockBeanContextChild child = new MockBeanContextChild();
-
- try {
- support.getResourceAsStream("", child);
- fail("IAE expected");
- } catch (IllegalArgumentException e) {
- // expected
- }
- }
-
- public void testGetResourceAsStream_NotExist() {
- MockBeanContextSupport support = new MockBeanContextSupport();
- MockBeanContextChild child = new MockBeanContextChild();
- support.add(child);
-
- InputStream ins = support
- .getResourceAsStream(
- "org/apache/harmony/beans/tests/java/beans/beancontext/mock/nonexist",
- child);
- assertNull(ins);
- }
-
- public void testGetResourceAsStream() throws IOException {
- MockBeanContextSupport support = new MockBeanContextSupport();
- MockBeanContextChild child = new MockBeanContextChild();
- support.add(child);
-
- final String RESOURCE_NAME = "org/apache/harmony/beans/tests/support/beancontext/mock/mockdata.txt";
- InputStream ins = support.getResourceAsStream(RESOURCE_NAME, child);
- assertEquals("mockdata", new BufferedReader(new InputStreamReader(ins))
- .readLine());
- ins.close();
- }
-
- public void testInitialize() {
- // covered by other testcases
- }
-
- public void testInstantiateChild_NullParam() throws IOException,
- ClassNotFoundException {
- MockBeanContextSupport support = new MockBeanContextSupport();
-
- try {
- support.instantiateChild(null);
- fail("NPE expected");
- } catch (NullPointerException e) {
- // expected
- }
- }
-
- public void testInstantiateChild() throws IOException,
- ClassNotFoundException {
- MockBeanContextSupport support = new MockBeanContextSupport();
-
- MockBeanContextChild child = (MockBeanContextChild) support
- .instantiateChild(MockBeanContextChild.class.getName());
- assertTrue(support.contains(child));
- assertEquals(1, support.size());
- }
-
- public void testIsDesignTime() {
- MockBeanContextSupport support = new MockBeanContextSupport();
-
- assertFalse(support.isDesignTime());
-
- support.setDesignTime(true);
- assertTrue(support.isDesignTime());
- }
-
- public void testIsEmpty() {
- MockBeanContextSupport support = new MockBeanContextSupport();
-
- assertTrue(support.isEmpty());
-
- support.add("a child");
- assertFalse(support.isEmpty());
- }
-
- public void testIsSerializing() {
- MockBeanContextSupport support = new MockBeanContextSupport();
- assertFalse(support.isSerializing());
- }
-
- public void testIterator() {
- MockBeanContextSupport support = new MockBeanContextSupport();
- support.add("string value");
- support.add(new Integer(129));
- support.add(Locale.CHINESE);
-
- Iterator iter = support.iterator();
- for (int i = 0; i < 3; i++) {
- assertTrue(support.contains(iter.next()));
- iter.remove();
- }
- assertFalse(iter.hasNext());
- assertEquals(3, support.size());
- }
-
- public void testNeedsGui_NoVisibleChild() {
- MockBeanContextSupport support = new MockBeanContextSupport();
- assertFalse(support.needsGui());
-
- support.add("a child");
- assertFalse(support.needsGui());
-
- support.add(new MockBeanContextChild());
- assertFalse(support.needsGui());
- }
-
- public void testNeedsGui_ComponentChild() {
- /*
- * MockBeanContextSupport support = new MockBeanContextSupport();
- * assertFalse(support.needsGui());
- *
- * Component child = new Component() {/* mock
- */
- // };
- /*
- * support.add(child); assertTrue(support.needsGui());
- */
- }
-
- public void testNeedsGui_ContainerChild() {
- // MockBeanContextSupport support = new MockBeanContextSupport();
- // assertFalse(support.needsGui());
- //
- // Container child = new Container() {/* mock */
- // };
- // support.add(child);
- // assertTrue(support.needsGui());
- }
-
- public void testNeedsGui_VisibilityChild() {
- MockBeanContextSupport support = new MockBeanContextSupport();
- assertFalse(support.needsGui());
-
- Visibility child = new MockVisibility(false, true);
- support.add(child);
- assertTrue(support.needsGui());
- }
-
- public void testNeedsGui_VisiblePeer() {
- // MockBeanContextSupport peer = new MockBeanContextSupport();
- // peer.add(new Container() {/* mock */
- // });
- // MockBeanContextSupport support = new MockBeanContextSupport(peer);
- //
- // assertTrue(support.needsGui());
- }
-
- public void testOkToUseGui() {
- MockBeanContextSupport support = new MockBeanContextSupport();
-
- assertTrue(support.isOkToUseGui());
- assertFalse(support.avoidingGui());
- assertFalse(support.needsGui());
-
- support.dontUseGui();
- assertFalse(support.isOkToUseGui());
- // assertFalse(support.avoidingGui());
- assertFalse(support.needsGui());
-
- support.okToUseGui();
- assertTrue(support.isOkToUseGui());
- assertFalse(support.avoidingGui());
- assertFalse(support.needsGui());
- }
-
- public void testPropertyChange() throws PropertyVetoException {
- MockBeanContextSupport support = new MockBeanContextSupport();
- MockPropertyChangeListener l1 = new MockPropertyChangeListener();
- support.addPropertyChangeListener("locale", l1);
- support.records.assertRecord("initialize", null);
-
- support.setLocale(Locale.ITALY);
- support.records.assertEndOfRecords();
- assertSame(support, l1.lastEvent.getSource());
- assertSame(Locale.getDefault(), l1.lastEvent.getOldValue());
- assertSame(Locale.ITALY, l1.lastEvent.getNewValue());
-
- support.addPropertyChangeListener("locale", support);
- support.setLocale(Locale.CANADA);
- PropertyChangeEvent evt = (PropertyChangeEvent) support.records
- .getArg(0);
- assertSame(support, evt.getSource());
- assertSame(Locale.ITALY, l1.lastEvent.getOldValue());
- assertSame(Locale.CANADA, l1.lastEvent.getNewValue());
- support.records.assertRecord("propertyChange", evt, null);
- support.records.assertEndOfRecords();
- }
-
- public void testReadChildren() throws PropertyVetoException, IOException,
- ClassNotFoundException {
- MockBeanContextSupport support = new MockBeanContextSupport();
- support.setLocale(Locale.ITALY);
- support.add("string value");
- support.add(new Integer(129));
- support.add(Locale.CHINESE);
-
- byte data[] = null;
- ByteArrayOutputStream bout = new ByteArrayOutputStream();
- ObjectOutputStream oout = new ObjectOutputStream(bout);
- support.writeChildren(oout);
- oout.close();
- data = bout.toByteArray();
- support.records.clear();
-
- ByteArrayInputStream bin = new ByteArrayInputStream(data);
- ObjectInputStream oin = new ObjectInputStream(bin);
- support.readChildren(oin);
- oin.close();
-
- Iterator it = support.iterator();
- while (it.hasNext()) {
- Object expectedChild = it.next();
- support.records.assertRecord("childDeserializedHook",
- expectedChild, MethodInvocationRecords.IGNORE, null);
- }
- assertEquals(3, support.size());
- support.records.assertEndOfRecords();
- }
-
- public void test_readChildren_NPE_scenario1() throws Exception {
- BeanContextSupport beanContextSupport = new BeanContextSupport();
- beanContextSupport.add(beanContextSupport);
- assertEquals(1, beanContextSupport.size());
- assertFalse(beanContextSupport.isSerializing());
- try {
- beanContextSupport.readChildren((ObjectInputStream) null);
- fail("should throw NullPointerException");
- } catch (NullPointerException e) {
- // Expected
- }
- }
-
- public void test_readChildren_NPE_scenario2() throws Exception {
- BeanContextSupport beanContextSupport = new BeanContextSupport();
- beanContextSupport.readChildren((ObjectInputStream) null);
- }
-
- public void test_readChildren_NPE_scenario3() throws Exception {
- BeanContextSupport beanContextSupport = new BeanContextSupport();
- beanContextSupport.add(new Object());
- beanContextSupport.readChildren((ObjectInputStream) null);
- }
-
- public void test_readChildren_NPE_scenario4() throws Exception {
- BeanContextSupport beanContextSupport = new BeanContextSupport();
- beanContextSupport.add("Serializable");
- try {
- beanContextSupport.readChildren((ObjectInputStream) null);
- fail("should throw NullPointerException");
- } catch (NullPointerException e) {
- // Expected
- }
- beanContextSupport.remove("Serializable");
- beanContextSupport.readChildren((ObjectInputStream) null);
- }
-
- public void testRemoveAll() {
- MockBeanContextSupport support = new MockBeanContextSupport();
- support.records.assertRecord("initialize", null);
- try {
- support.removeAll(Collections.EMPTY_LIST);
- fail("UnsupportedOperationException expected");
- } catch (UnsupportedOperationException e) {
- // expected
- }
- support.records.assertEndOfRecords();
- }
-
- public void testRemoveBeanContextMembershipListener_NullParam() {
- MockBeanContextSupport support = new MockBeanContextSupport();
-
- try {
- support.removeBeanContextMembershipListener(null);
- fail("NPE expected");
- } catch (NullPointerException e) {
- // expected
- }
- }
-
- public void testRemoveBeanContextMembershipListener() {
- MockBeanContextSupport support = new MockBeanContextSupport();
- MockBeanContextMembershipListener l1 = new MockBeanContextMembershipListener();
- MockBeanContextMembershipListener l2 = new MockBeanContextMembershipListener();
-
- support.addBeanContextMembershipListener(l1);
- support.addBeanContextMembershipListener(l2);
-
- l1.clearLastEvent();
- l2.clearLastEvent();
- Object child = new MockBeanContextChild();
- support.add(child);
- assertTrue(l1.lastEventAdd);
- assertMembershipEvent(l1.lastEvent, support, null, child);
- assertTrue(l2.lastEventAdd);
- assertMembershipEvent(l2.lastEvent, support, null, child);
-
- support.removeBeanContextMembershipListener(l1);
- l1.clearLastEvent();
- l2.clearLastEvent();
- support.remove(child);
- assertNull(l1.lastEvent);
- assertTrue(l2.lastEventRemove);
- assertMembershipEvent(l2.lastEvent, support, null, child);
-
- support.removeBeanContextMembershipListener(l1);
- l1.clearLastEvent();
- l2.clearLastEvent();
- support.remove(child);
- assertNull(l1.lastEvent);
- assertNull(l2.lastEvent);
- }
-
- /*
- * Class under test for boolean remove(java.lang.Object)
- */
- public void testRemoveObject_NullParam() {
- MockBeanContextSupport support = new MockBeanContextSupport();
-
- try {
- support.remove(null);
- fail("IAE expected");
- } catch (IllegalArgumentException e) {
- // expected
- }
- }
-
- /*
- * Class under test for boolean remove(java.lang.Object)
- */
- public void testRemoveObject_NonBCC() {
- MockBeanContextSupport support = new MockBeanContextSupport();
- MockBeanContextMembershipListener l1 = new MockBeanContextMembershipListener();
- support.addBeanContextMembershipListener(l1);
- Integer child = new Integer(1000);
- support.add(child);
- support.records.assertRecord("initialize", null);
- support.records.assertRecord("validatePendingAdd", child, Boolean.TRUE);
- support.records.assertRecord("createBCSChild", child, null, support
- .children().get(child));
- support.records.assertRecord("childJustAddedHook", child, support
- .children().get(child), null);
- support.records.assertEndOfRecords();
- assertTrue(l1.lastEventAdd);
- assertMembershipEvent(l1.lastEvent, support, null, child);
- support.records.clear();
- l1.clearLastEvent();
-
- Object bcsChild = support.children().get(child);
- support.remove(child);
- support.records.assertRecord("validatePendingRemove", child,
- Boolean.TRUE);
- support.records.assertRecord("childJustRemovedHook", child, bcsChild,
- null);
- support.records.assertEndOfRecords();
- assertTrue(l1.lastEventRemove);
- assertMembershipEvent(l1.lastEvent, support, null, child);
-
- assertEquals(0, support.size());
- }
-
- /*
- * Class under test for boolean remove(java.lang.Object)
- */
- public void testRemoveObject_BCC() {
- MockBeanContextSupport support = new MockBeanContextSupport();
- MockBeanContextMembershipListener l1 = new MockBeanContextMembershipListener();
- support.addBeanContextMembershipListener(l1);
-
- BeanContextChild child = new MockBeanContextChild();
- support.add(child);
- support.records.assertRecord("initialize", null);
- support.records.assertRecord("validatePendingAdd", child, Boolean.TRUE);
- support.records.assertRecord("createBCSChild", child, null, support
- .children().get(child));
- support.records.assertRecord("childJustAddedHook", child, support
- .children().get(child), null);
- support.records.assertEndOfRecords();
- assertTrue(l1.lastEventAdd);
- assertMembershipEvent(l1.lastEvent, support, null, child);
- support.records.clear();
- l1.clearLastEvent();
-
- Object bcsChild = support.children().get(child);
- support.remove(child);
- support.records.assertRecord("validatePendingRemove", child,
- Boolean.TRUE);
- support.records.assertRecord("childJustRemovedHook", child, bcsChild,
- null);
- support.records.assertEndOfRecords();
- assertTrue(l1.lastEventRemove);
- assertMembershipEvent(l1.lastEvent, support, null, child);
-
- assertNull(child.getBeanContext());
- assertEquals(0, support.size());
- }
-
- /*
- * Class under test for boolean remove(java.lang.Object)
- */
- public void testRemoveObject_BCP() {
- MockBeanContextSupport support = new MockBeanContextSupport();
- support.waitOnChildInHooks = false;
- MockBeanContextMembershipListener l1 = new MockBeanContextMembershipListener();
- support.addBeanContextMembershipListener(l1);
-
- BeanContextChild childPeer = new MockBeanContextChild();
- BeanContextProxy child = new MockBeanContextProxy(childPeer);
- support.add(child);
- support.records.assertRecord("initialize", null);
- support.records.assertRecord("validatePendingAdd", child, Boolean.TRUE);
- support.records.assertRecord("createBCSChild", child, childPeer,
- support.children().get(child));
- support.records.assertRecord("createBCSChild", childPeer, child,
- support.children().get(childPeer));
- support.records.assertRecord("childJustAddedHook", child, support
- .children().get(child), null);
- support.records.assertRecord("childJustAddedHook", childPeer, support
- .children().get(childPeer), null);
- support.records.assertEndOfRecords();
- assertTrue(l1.lastEventAdd);
- assertMembershipEvent(l1.lastEvent, support, null, Arrays
- .asList(new Object[] { child, childPeer }));
- support.records.clear();
- l1.clearLastEvent();
-
- Object bcsChild = support.children().get(child);
- Object bcsChildPeer = support.children().get(childPeer);
- support.remove(child);
- support.records.assertRecord("validatePendingRemove", child,
- Boolean.TRUE);
- support.records.assertRecord("childJustRemovedHook", child, bcsChild,
- null);
- support.records.assertRecord("childJustRemovedHook", childPeer,
- bcsChildPeer, null);
- support.records.assertEndOfRecords();
- assertTrue(l1.lastEventRemove);
- assertMembershipEvent(l1.lastEvent, support, null, Arrays
- .asList(new Object[] { child, childPeer }));
-
- assertNull(childPeer.getBeanContext());
- assertEquals(0, support.size());
- }
-
- /*
- * Class under test for boolean remove(java.lang.Object)
- */
- public void testRemoveObject_BCP2() {
- MockBeanContextSupport support = new MockBeanContextSupport();
- support.waitOnChildInHooks = false;
- MockBeanContextMembershipListener l1 = new MockBeanContextMembershipListener();
- support.addBeanContextMembershipListener(l1);
-
- BeanContextChild childPeer = new MockBeanContextChild();
- BeanContextProxy child = new MockBeanContextProxy(childPeer);
- support.add(child);
- support.records.assertRecord("initialize", null);
- support.records.assertRecord("validatePendingAdd", child, Boolean.TRUE);
- support.records.assertRecord("createBCSChild", child, childPeer,
- support.children().get(child));
- support.records.assertRecord("createBCSChild", childPeer, child,
- support.children().get(childPeer));
- support.records.assertRecord("childJustAddedHook", child, support
- .children().get(child), null);
- support.records.assertRecord("childJustAddedHook", childPeer, support
- .children().get(childPeer), null);
- support.records.assertEndOfRecords();
- assertTrue(l1.lastEventAdd);
- assertMembershipEvent(l1.lastEvent, support, null, Arrays
- .asList(new Object[] { child, childPeer }));
- support.records.clear();
- l1.clearLastEvent();
-
- Object bcsChild = support.children().get(child);
- Object bcsChildPeer = support.children().get(childPeer);
- support.remove(childPeer);
- support.records.assertRecord("validatePendingRemove", childPeer,
- Boolean.TRUE);
- support.records.assertRecord("childJustRemovedHook", childPeer,
- bcsChildPeer, null);
- support.records.assertRecord("childJustRemovedHook", child, bcsChild,
- null);
- support.records.assertEndOfRecords();
- assertTrue(l1.lastEventRemove);
- assertMembershipEvent(l1.lastEvent, support, null, Arrays
- .asList(new Object[] { child, childPeer }));
-
- assertNull(childPeer.getBeanContext());
- assertEquals(0, support.size());
- }
-
- /*
- * Class under test for boolean remove(java.lang.Object)
- */
- public void testRemoveObject_NonExist() {
- MockBeanContextSupport support = new MockBeanContextSupport();
- MockBeanContextMembershipListener l1 = new MockBeanContextMembershipListener();
- support.addBeanContextMembershipListener(l1);
-
- support.remove(new MockBeanContextChild());
- support.records.assertRecord("initialize", null);
- support.records.assertEndOfRecords();
- assertNull(l1.lastEvent);
-
- assertEquals(0, support.size());
- }
-
- /*
- * Class under test for boolean remove(java.lang.Object)
- */
- public void testRemoveObject_Veto() {
- MockBeanContextSupport support = new MockBeanContextSupport();
- MockBeanContextMembershipListener l1 = new MockBeanContextMembershipListener();
- support.addBeanContextMembershipListener(l1);
-
- BeanContextChild child = new MockBeanContextChild();
- support.add(child);
- support.records.assertRecord("initialize", null);
- support.records.assertRecord("validatePendingAdd", child, Boolean.TRUE);
- support.records.assertRecord("createBCSChild", child, null, support
- .children().get(child));
- support.records.assertRecord("childJustAddedHook", child, support
- .children().get(child), null);
- support.records.assertEndOfRecords();
- assertTrue(l1.lastEventAdd);
- assertMembershipEvent(l1.lastEvent, support, null, child);
- support.records.clear();
- l1.clearLastEvent();
-
- support.children().get(child);
- support.vetoAddRemove = true;
- try {
- support.remove(child);
- fail("IllegalStateException expected");
- } catch (IllegalStateException e) {
- // expected
- }
- support.records.assertRecord("validatePendingRemove", child,
- Boolean.FALSE);
- support.records.assertEndOfRecords();
- assertNull(l1.lastEvent);
-
- assertSame(support, child.getBeanContext());
- assertEquals(1, support.size());
- }
-
- /*
- * Class under test for boolean remove(java.lang.Object, boolean)
- */
- public void testRemoveObjectboolean() {
- MockBeanContextSupport support = new MockBeanContextSupport();
- MockBeanContextMembershipListener l1 = new MockBeanContextMembershipListener();
- support.addBeanContextMembershipListener(l1);
-
- BeanContextChild child = new MockBeanContextChild();
- support.add(child);
- support.records.assertRecord("initialize", null);
- support.records.assertRecord("validatePendingAdd", child, Boolean.TRUE);
- support.records.assertRecord("createBCSChild", child, null, support
- .children().get(child));
- support.records.assertRecord("childJustAddedHook", child, support
- .children().get(child), null);
- support.records.assertEndOfRecords();
- assertTrue(l1.lastEventAdd);
- assertMembershipEvent(l1.lastEvent, support, null, child);
- support.records.clear();
- l1.clearLastEvent();
-
- Object bcsChild = support.children().get(child);
- support.publicRemove(child, false); // don't call child's setBeanContext
- support.records.assertRecord("validatePendingRemove", child,
- Boolean.TRUE);
- support.records.assertRecord("childJustRemovedHook", child, bcsChild,
- null);
- support.records.assertEndOfRecords();
- assertTrue(l1.lastEventRemove);
- assertMembershipEvent(l1.lastEvent, support, null, child);
-
- assertSame(support, child.getBeanContext());
- assertEquals(0, support.size());
- }
-
- public void testRetainAll() {
- MockBeanContextSupport support = new MockBeanContextSupport();
- try {
- support.retainAll(Collections.EMPTY_LIST);
- fail("UnsupportedOperationException expected");
- } catch (UnsupportedOperationException e) {
- // expected
- }
- }
-
- public void testSerialize() {
- // covered by testBcsPreSerializationHook
- }
-
- public void testSetDesignTime() {
- MockBeanContextSupport support = new MockBeanContextSupport();
- MockPropertyChangeListener l1 = new MockPropertyChangeListener();
- MockVetoableChangeListener l2 = new MockVetoableChangeListener();
- support.addPropertyChangeListener("designTime", l1);
- support.addVetoableChangeListener("designTime", l2);
- assertFalse(support.isDesignTime());
- support.records.assertRecord("initialize", null);
- support.records.assertEndOfRecords();
-
- support.setDesignTime(true);
- support.records.assertEndOfRecords();
- assertNull(l1.lastEvent);
- assertNull(l2.lastEvent);
- }
-
- public void testSetLocale_NullParam() throws PropertyVetoException {
- MockBeanContextSupport support = new MockBeanContextSupport();
- support.setLocale(Locale.ITALY);
- assertSame(Locale.ITALY, support.getLocale());
- support.records.assertRecord("initialize", null);
- support.records.assertEndOfRecords();
-
- support.setLocale(null);
- assertSame(Locale.ITALY, support.getLocale());
- support.records.assertEndOfRecords();
- }
-
- public void testSetLocale() throws PropertyVetoException {
- MockBeanContextSupport support = new MockBeanContextSupport();
- MockPropertyChangeListener l1 = new MockPropertyChangeListener();
- MockVetoableChangeListener l2 = new MockVetoableChangeListener();
- support.addPropertyChangeListener("locale", l1);
- support.addVetoableChangeListener("locale", l2);
- assertSame(Locale.getDefault(), support.getLocale());
- support.records.assertRecord("initialize", null);
- support.records.assertEndOfRecords();
-
- support.setLocale(Locale.ITALY);
- assertSame(Locale.ITALY, support.getLocale());
- support.records.assertEndOfRecords();
- assertSame(support, l1.lastEvent.getSource());
- assertEquals("locale", l1.lastEvent.getPropertyName());
- assertEquals(Locale.getDefault(), l1.lastEvent.getOldValue());
- assertEquals(Locale.ITALY, l1.lastEvent.getNewValue());
- assertSame(support, l2.lastEvent.getSource());
- assertEquals("locale", l2.lastEvent.getPropertyName());
- assertEquals(Locale.getDefault(), l2.lastEvent.getOldValue());
- assertEquals(Locale.ITALY, l2.lastEvent.getNewValue());
- }
-
- public void testSetLocale_Veto() {
- MockBeanContextSupport support = new MockBeanContextSupport();
- MockPropertyChangeListener l1 = new MockPropertyChangeListener();
- MockVetoChangeListener l2 = new MockVetoChangeListener();
- support.addPropertyChangeListener("locale", l1);
- support.addVetoableChangeListener("locale", l2);
- assertSame(Locale.getDefault(), support.getLocale());
- support.records.assertRecord("initialize", null);
- support.records.assertEndOfRecords();
-
- try {
- support.setLocale(Locale.ITALY);
- fail("PropertyVetoException expected");
- } catch (PropertyVetoException e) {
- // expected
- }
- assertSame(Locale.getDefault(), support.getLocale());
- support.records.assertEndOfRecords();
- assertNull(l1.lastEvent);
- assertSame(support, l2.lastEvent.getSource());
- assertEquals("locale", l2.lastEvent.getPropertyName());
- assertEquals(Locale.getDefault(), l2.lastEvent.getNewValue());
- assertEquals(Locale.ITALY, l2.lastEvent.getOldValue());
- }
-
- public void testSize() {
- @SuppressWarnings("serial")
- class TestBean extends Component implements BeanContextProxy {
- public BeanContextChildSupport childSupport = new BeanContextChildSupport();
-
- public BeanContextChild getBeanContextProxy() {
- return childSupport;
- }
- }
-
- // Regression test for HARMONY-1829
- BeanContextSupport obj = new BeanContextSupport();
- obj.add(new TestBean());
- assertEquals(2, obj.size());
- }
-
- /*
- * Class under test for java.lang.Object[] toArray()
- */
- public void testToArray() {
- MockBeanContextSupport support = new MockBeanContextSupport();
-
- Object[] array = support.toArray();
- assertEquals(0, array.length);
-
- support.add(new Integer(1000));
- support.add("a child");
- support.add(new MockBeanContextChild());
- array = support.toArray();
- assertEquals(3, array.length);
- int count = 0;
- for (Object element : array) {
- if (element instanceof Integer) {
- assertEquals(new Integer(1000), element);
- count += 1;
- }
- if (element instanceof String) {
- assertEquals("a child", element);
- count += 2;
- }
- if (element instanceof MockBeanContextChild) {
- count += 4;
- }
- }
- assertEquals(7, count);
- }
-
- /*
- * Class under test for java.lang.Object[] toArray(java.lang.Object[])
- */
- public void testToArrayObjectArray_NullParam() {
- MockBeanContextSupport support = new MockBeanContextSupport();
- try {
- support.toArray(null);
- fail("NPE expected");
- } catch (NullPointerException e) {
- // expected
- }
- }
-
- /*
- * Class under test for java.lang.Object[] toArray(java.lang.Object[])
- */
- public void testToArrayObjectArray_WrongType() {
- MockBeanContextSupport support = new MockBeanContextSupport();
- support.add("a");
- support.add("b");
- support.add("c");
- try {
- support.toArray(new Integer[0]);
- fail("ArrayStoreException expected");
- } catch (ArrayStoreException e) {
- // expected
- }
- }
-
- /*
- * Class under test for java.lang.Object[] toArray(java.lang.Object[])
- */
- public void testToArrayObjectArray_LesserLength() {
- MockBeanContextSupport support = new MockBeanContextSupport();
- support.add("a");
- support.add("b");
- support.add("c");
- String in[] = new String[] { "1" };
- String out[] = (String[]) support.toArray(in);
- assertNotSame(in, out);
- List<String> expected = Arrays.asList(new String[] { "a", "b", "c" });
- assertEquals(expected.size(), out.length);
- for (String element : out) {
- assertTrue(expected.contains(element));
- }
- }
-
- /*
- * Class under test for java.lang.Object[] toArray(java.lang.Object[])
- */
- public void testToArrayObjectArray_RightLength() {
- MockBeanContextSupport support = new MockBeanContextSupport();
- support.add("a");
- support.add("b");
- support.add("c");
- String in[] = new String[3];
- String out[] = (String[]) support.toArray(in);
- assertSame(in, out);
- List<String> expected = Arrays.asList(new String[] { "a", "b", "c" });
- assertEquals(expected.size(), out.length);
- for (String element : out) {
- assertTrue(expected.contains(element));
- }
- }
-
- /*
- * Class under test for java.lang.Object[] toArray(java.lang.Object[])
- */
- public void testToArrayObjectArray_GreaterLength() {
- MockBeanContextSupport support = new MockBeanContextSupport();
- support.add("a");
- support.add("b");
- support.add("c");
- String in[] = new String[5];
- String out[] = (String[]) support.toArray(in);
- assertSame(in, out);
- List<String> expected = Arrays.asList(new String[] { "a", "b", "c"});
- for (int i = 0; i < expected.size(); i++) {
- assertTrue(expected.contains(out[i]));
- }
- assertNull(out[3]);
- assertNull(out[4]);
- }
-
- public void testValidatePendingAdd() {
- // covered by testAdd
- }
-
- public void testValidatePendingRemove() {
- // covered by testRemove
- }
-
- public void testVetoableChange() throws PropertyVetoException {
- MockBeanContextSupport support = new MockBeanContextSupport();
- MockVetoableChangeListener l1 = new MockVetoableChangeListener();
- support.addVetoableChangeListener("locale", l1);
- support.records.assertRecord("initialize", null);
-
- support.setLocale(Locale.ITALY);
- support.records.assertEndOfRecords();
- assertSame(support, l1.lastEvent.getSource());
- assertSame(Locale.getDefault(), l1.lastEvent.getOldValue());
- assertSame(Locale.ITALY, l1.lastEvent.getNewValue());
-
- support.addVetoableChangeListener("locale", support);
- support.setLocale(Locale.CANADA);
- PropertyChangeEvent evt = (PropertyChangeEvent) support.records
- .getArg(0);
- assertSame(support, evt.getSource());
- assertEquals("locale", evt.getPropertyName());
- assertSame(Locale.ITALY, l1.lastEvent.getOldValue());
- assertSame(Locale.CANADA, l1.lastEvent.getNewValue());
- support.records.assertRecord("vetoableChange", evt, null);
- support.records.assertEndOfRecords();
- }
-
- public void testWriteChildren() {
- // covered by testReadChildren()
- }
-
- public void testSerialization_NoPeer() throws IOException,
- ClassNotFoundException {
- BeanContextSupport support = new BeanContextSupport(null, Locale.ITALY,
- true, true);
- support
- .addBeanContextMembershipListener(new MockBeanContextMembershipListener());
- support
- .addBeanContextMembershipListener(new MockBeanContextMembershipListenerS(
- "l2"));
- support
- .addBeanContextMembershipListener(new MockBeanContextMembershipListenerS(
- "l3"));
- support
- .addBeanContextMembershipListener(new MockBeanContextMembershipListener());
- support.add("abcd");
- support.add(new MockBeanContextChild());
- support.add(new MockBeanContextChildS("a child"));
- support.add(new MockBeanContextChild());
- support.add("1234");
- support.add(new MockBeanContextProxyS("proxy",
- new MockBeanContextChildS("b child")));
-
- assertEqualsSerially(support, (BeanContextSupport) SerializationTester
- .getDeserilizedObject(support));
- }
-
- public void testSerialization_Peer() throws IOException,
- ClassNotFoundException {
- MockBeanContextDelegateS mock = new MockBeanContextDelegateS("main id");
- BeanContextSupport support = mock.support;
- support
- .addBeanContextMembershipListener(new MockBeanContextMembershipListener());
- support
- .addBeanContextMembershipListener(new MockBeanContextMembershipListenerS(
- "l2"));
- support
- .addBeanContextMembershipListener(new MockBeanContextMembershipListenerS(
- "l3"));
- support
- .addBeanContextMembershipListener(new MockBeanContextMembershipListener());
- support.add("abcd");
- support.add(new MockBeanContextChild());
- support.add(new MockBeanContextChildS("a child"));
- support.add(new MockBeanContextChild());
- support.add("1234");
- support.add(new MockBeanContextProxyS("proxy",
- new MockBeanContextChildS("b child")));
-
- MockBeanContextDelegateS serMock = (MockBeanContextDelegateS) SerializationTester
- .getDeserilizedObject(mock);
- assertEquals(mock.id, serMock.id);
- assertSame(mock, mock.support.beanContextChildPeer);
- assertSame(serMock, serMock.support.beanContextChildPeer);
- assertEqualsSerially(mock.support, serMock.support);
- }
-
- public void testSerialization_Compatibility() throws Exception {
- MockBeanContextDelegateS mock = new MockBeanContextDelegateS("main id");
- BeanContextSupport support = mock.support;
- support.addBeanContextMembershipListener(new MockBeanContextMembershipListener());
- support.addBeanContextMembershipListener(new MockBeanContextMembershipListenerS("l2"));
- support.addBeanContextMembershipListener(new MockBeanContextMembershipListenerS("l3"));
- support.addBeanContextMembershipListener(new MockBeanContextMembershipListener());
- support.add("abcd");
- support.add(new MockBeanContextChild());
- support.add(new MockBeanContextChildS("a child"));
- support.add(new MockBeanContextChild());
- support.add("1234");
- SerializationTest.verifyGolden(this, mock, new SerializableAssert(){
- public void assertDeserialized(Serializable orig, Serializable ser) {
- MockBeanContextDelegateS serMock = (MockBeanContextDelegateS) ser;
- MockBeanContextDelegateS mock = (MockBeanContextDelegateS) orig;
- assertEquals(mock.id, serMock.id);
- assertSame(mock, mock.support.beanContextChildPeer);
- assertSame(serMock, serMock.support.beanContextChildPeer);
- assertEqualsSerially(mock.support, serMock.support);
- }
- });
- }
-
- private byte[] serialize(Serializable obj) {
- try {
- ByteArrayOutputStream bout = new ByteArrayOutputStream();
- ObjectOutputStream oout = new ObjectOutputStream(bout);
- oout.writeObject(obj);
- oout.close();
- return bout.toByteArray();
- } catch (IOException e) {
- e.printStackTrace();
- throw new RuntimeException();
- }
- }
-
- private Object deserialize(byte[] bytes) {
- try {
- ByteArrayInputStream bin = new ByteArrayInputStream(bytes);
- ObjectInputStream oin = new ObjectInputStream(bin);
- Object result = oin.readObject();
- oin.close();
- return result;
- } catch (Exception e) {
- e.printStackTrace();
- throw new RuntimeException(e);
- }
- }
-
- private void assertMembershipEvent(BeanContextMembershipEvent evt,
- BeanContext ctx, BeanContext pFrom, Object changes) {
- assertSame(ctx, evt.getSource());
- assertSame(ctx, evt.getBeanContext());
- assertSame(pFrom, evt.getPropagatedFrom());
- if (changes instanceof Collection) {
- Collection changeCollection = (Collection) changes;
- assertEquals(changeCollection.size(), evt.size());
- for (Iterator iter = changeCollection.iterator(); iter.hasNext();) {
- assertTrue(evt.contains(iter.next()));
- }
- } else {
- assertEquals(1, evt.size());
- assertTrue(evt.contains(changes));
- }
- }
-
- public static void assertEqualsSerially(BeanContextSupport orig,
- BeanContextSupport ser) {
-
- // check bcmListeners
- ArrayList origBcmListeners = (ArrayList) Utils.getField(orig,
- "bcmListeners");
- ArrayList serBcmListeners = (ArrayList) Utils.getField(ser,
- "bcmListeners");
- int i = 0, j = 0;
- while (i < origBcmListeners.size()) {
- Object l1 = origBcmListeners.get(i);
- if (l1 instanceof Serializable) {
- Object l2 = serBcmListeners.get(j);
- assertSame(l1.getClass(), l2.getClass());
- if (l1 instanceof MockBeanContextMembershipListenerS) {
- assertEquals(((MockBeanContextMembershipListenerS) l1).id,
- ((MockBeanContextMembershipListenerS) l2).id);
- }
- j++;
- }
- i++;
- }
- assertEquals(j, serBcmListeners.size());
-
- // check children
- HashMap origChildren = (HashMap) Utils.getField(orig, "children");
- HashMap serChildren = (HashMap) Utils.getField(ser, "children");
- int count = 0;
- for (Iterator iter = origChildren.keySet().iterator(); iter.hasNext();) {
- Object child = iter.next();
- if (child instanceof Serializable) {
- if (child instanceof String) {
- assertTrue(serChildren.containsKey(child));
- }
- if (child instanceof MockBeanContextChildS) {
- assertTrue(serChildren.containsKey(child));
- MockBeanContextChildS serChild = (MockBeanContextChildS) Utils
- .getField(serChildren.get(child), "child");
- assertSame(ser.getBeanContextPeer(), serChild
- .getBeanContext());
- }
- if (child instanceof MockBeanContextProxyS) {
- assertTrue(serChildren.containsKey(child));
- }
- count++;
- }
- }
- assertEquals(count, serChildren.size());
-
- // check other fields
- assertEquals(Utils.getField(orig, "locale"), Utils.getField(ser,
- "locale"));
- assertEquals(Utils.getField(orig, "okToUseGui"), Utils.getField(ser,
- "okToUseGui"));
- assertEquals(Utils.getField(orig, "designTime"), Utils.getField(ser,
- "designTime"));
- }
-
-
- public void testPropertyChangePropertyChangeEvent() {
- BeanContextServicesSupport s = new BeanContextServicesSupport();
- PropertyChangeSupport p= new PropertyChangeSupport(new Object());
-
- p.addPropertyChangeListener(s);
- p.firePropertyChange(null, new Object(), new Object());
- }
-
- //Regression Test for HARMONY-3757
- public void testSelfSerializatoin() throws Exception {
- BeanContextSupport beanContextSupport = new BeanContextSupport();
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- new ObjectOutputStream(baos).writeObject(beanContextSupport);
- ObjectInputStream oin = new ObjectInputStream(new ByteArrayInputStream(
- baos.toByteArray()));
- Object obj = oin.readObject();
- assertTrue(obj instanceof BeanContextSupport);
- }
-
- public void testAvoidGui() throws Exception
- {
- MockBeanContextSupport1 mockBeanContextSupport1 = new MockBeanContextSupport1();
- mockBeanContextSupport1.setOkToUseGui(false);
- assertFalse(mockBeanContextSupport1.avoidingGui());
-
- mockBeanContextSupport1 = new MockBeanContextSupport1();
- mockBeanContextSupport1.setOkToUseGui(true);
- assertFalse(mockBeanContextSupport1.avoidingGui());
-
- mockBeanContextSupport1 = new MockBeanContextSupport1();
- Component component = new Button();
- mockBeanContextSupport1.add(component);
- mockBeanContextSupport1.setOkToUseGui(false);
- assertTrue(mockBeanContextSupport1.needsGui());
- assertTrue(mockBeanContextSupport1.avoidingGui());
-
- mockBeanContextSupport1 = new MockBeanContextSupport1();
- component = new Button();
- mockBeanContextSupport1.add(component);
- mockBeanContextSupport1.setOkToUseGui(true);
- assertTrue(mockBeanContextSupport1.needsGui());
- assertFalse(mockBeanContextSupport1.avoidingGui());
- }
-
-
- public class MockBeanContextSupport1 extends BeanContextSupport
- {
- private static final long serialVersionUID = 1L;
-
- public void setOkToUseGui(boolean ok)
- {
- this.okToUseGui = ok;
- }
- }
-
-}
diff --git a/beans/src/test/resources/binary/java/beans/mock/MockJavaBean2.bin b/beans/src/test/resources/binary/java/beans/mock/MockJavaBean2.bin
deleted file mode 100644
index 8871c3b..0000000
--- a/beans/src/test/resources/binary/java/beans/mock/MockJavaBean2.bin
+++ /dev/null
Binary files differ
diff --git a/beans/src/test/resources/binary/java/beans/mock/TestClassEditor.bin b/beans/src/test/resources/binary/java/beans/mock/TestClassEditor.bin
deleted file mode 100644
index 3ba3730..0000000
--- a/beans/src/test/resources/binary/java/beans/mock/TestClassEditor.bin
+++ /dev/null
Binary files differ
diff --git a/beans/src/test/resources/gif/harmony-logo.gif b/beans/src/test/resources/gif/harmony-logo.gif
deleted file mode 100644
index 2384619..0000000
--- a/beans/src/test/resources/gif/harmony-logo.gif
+++ /dev/null
Binary files differ
diff --git a/beans/src/test/resources/gif/test.gif b/beans/src/test/resources/gif/test.gif
deleted file mode 100644
index ee1f64c..0000000
--- a/beans/src/test/resources/gif/test.gif
+++ /dev/null
Binary files differ
diff --git a/beans/src/test/resources/org/apache/harmony/beans/tests/java/beans/testB.jpg b/beans/src/test/resources/org/apache/harmony/beans/tests/java/beans/testB.jpg
deleted file mode 100644
index cbc5d9f..0000000
--- a/beans/src/test/resources/org/apache/harmony/beans/tests/java/beans/testB.jpg
+++ /dev/null
Binary files differ
diff --git a/beans/src/test/resources/serialization/java/beans/mock/MockAppletBean2.ser b/beans/src/test/resources/serialization/java/beans/mock/MockAppletBean2.ser
deleted file mode 100644
index c5fc88c..0000000
--- a/beans/src/test/resources/serialization/java/beans/mock/MockAppletBean2.ser
+++ /dev/null
Binary files differ
diff --git a/beans/src/test/resources/serialization/java/beans/mock/MockJavaBean2.ser b/beans/src/test/resources/serialization/java/beans/mock/MockJavaBean2.ser
deleted file mode 100644
index bba3d5a..0000000
--- a/beans/src/test/resources/serialization/java/beans/mock/MockJavaBean2.ser
+++ /dev/null
Binary files differ
diff --git a/beans/src/test/resources/serialization/org/apache/harmony/beans/tests/java/beans/IntrospectionExceptionTest.golden.ser b/beans/src/test/resources/serialization/org/apache/harmony/beans/tests/java/beans/IntrospectionExceptionTest.golden.ser
deleted file mode 100644
index 7a280dd..0000000
--- a/beans/src/test/resources/serialization/org/apache/harmony/beans/tests/java/beans/IntrospectionExceptionTest.golden.ser
+++ /dev/null
Binary files differ
diff --git a/beans/src/test/resources/serialization/org/apache/harmony/beans/tests/java/beans/PropertyVetoExceptionTest.golden.ser b/beans/src/test/resources/serialization/org/apache/harmony/beans/tests/java/beans/PropertyVetoExceptionTest.golden.ser
deleted file mode 100644
index 67aeadd..0000000
--- a/beans/src/test/resources/serialization/org/apache/harmony/beans/tests/java/beans/PropertyVetoExceptionTest.golden.ser
+++ /dev/null
Binary files differ
diff --git a/beans/src/test/resources/serialization/org/apache/harmony/beans/tests/java/beans/VetoableChangeSupportTest.golden.ser b/beans/src/test/resources/serialization/org/apache/harmony/beans/tests/java/beans/VetoableChangeSupportTest.golden.ser
deleted file mode 100644
index b461208..0000000
--- a/beans/src/test/resources/serialization/org/apache/harmony/beans/tests/java/beans/VetoableChangeSupportTest.golden.ser
+++ /dev/null
Binary files differ
diff --git a/beans/src/test/resources/serialization/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextChildSupportTest.golden.ser b/beans/src/test/resources/serialization/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextChildSupportTest.golden.ser
deleted file mode 100644
index e750f21..0000000
--- a/beans/src/test/resources/serialization/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextChildSupportTest.golden.ser
+++ /dev/null
Binary files differ
diff --git a/beans/src/test/resources/serialization/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextEventTest.golden.ser b/beans/src/test/resources/serialization/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextEventTest.golden.ser
deleted file mode 100644
index 3072c24..0000000
--- a/beans/src/test/resources/serialization/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextEventTest.golden.ser
+++ /dev/null
Binary files differ
diff --git a/beans/src/test/resources/serialization/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextMembershipEventTest.golden.ser b/beans/src/test/resources/serialization/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextMembershipEventTest.golden.ser
deleted file mode 100644
index 8bb260c..0000000
--- a/beans/src/test/resources/serialization/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextMembershipEventTest.golden.ser
+++ /dev/null
Binary files differ
diff --git a/beans/src/test/resources/serialization/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServiceAvailableEventTest.golden.ser b/beans/src/test/resources/serialization/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServiceAvailableEventTest.golden.ser
deleted file mode 100644
index 40a83e8..0000000
--- a/beans/src/test/resources/serialization/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServiceAvailableEventTest.golden.ser
+++ /dev/null
Binary files differ
diff --git a/beans/src/test/resources/serialization/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServiceRevokedEventTest.golden.ser b/beans/src/test/resources/serialization/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServiceRevokedEventTest.golden.ser
deleted file mode 100644
index 003bbc4..0000000
--- a/beans/src/test/resources/serialization/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServiceRevokedEventTest.golden.ser
+++ /dev/null
Binary files differ
diff --git a/beans/src/test/resources/serialization/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServicesSupportTest.golden.ser b/beans/src/test/resources/serialization/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServicesSupportTest.golden.ser
deleted file mode 100644
index 39dd4e2..0000000
--- a/beans/src/test/resources/serialization/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServicesSupportTest.golden.ser
+++ /dev/null
Binary files differ
diff --git a/beans/src/test/resources/serialization/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextSupportTest.golden.ser b/beans/src/test/resources/serialization/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextSupportTest.golden.ser
deleted file mode 100644
index 493f4cb..0000000
--- a/beans/src/test/resources/serialization/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextSupportTest.golden.ser
+++ /dev/null
Binary files differ
diff --git a/beans/src/test/resources/xml/Array.xml b/beans/src/test/resources/xml/Array.xml
deleted file mode 100644
index ebcea70..0000000
--- a/beans/src/test/resources/xml/Array.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<java version="1.6.0" class="java.beans.XMLDecoder">
- <array class="int" length="2">
- <void index="0">
- <int>1</int>
- </void>
- </array>
-</java>
diff --git a/beans/src/test/resources/xml/Array_Illegal.xml b/beans/src/test/resources/xml/Array_Illegal.xml
deleted file mode 100644
index 805ed1e..0000000
--- a/beans/src/test/resources/xml/Array_Illegal.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-<!--
- 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.
--->
-<java version='1.4.0' class='java.beans.XMLDecoder'>
- <array class="java.lang.String">
- <int>2</int>
- </array>
-</java> \ No newline at end of file
diff --git a/beans/src/test/resources/xml/Array_Null.xml b/beans/src/test/resources/xml/Array_Null.xml
deleted file mode 100644
index 547df7f..0000000
--- a/beans/src/test/resources/xml/Array_Null.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-<!--
- 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.
--->
-<java version='1.4.0' class='java.beans.XMLDecoder'>
- <array class="java.lang.String">
- <null/>
- <null/>
- <string></string>
- </array>
-</java> \ No newline at end of file
diff --git a/beans/src/test/resources/xml/Array_Object.xml b/beans/src/test/resources/xml/Array_Object.xml
deleted file mode 100644
index aec4df3..0000000
--- a/beans/src/test/resources/xml/Array_Object.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<!--
- 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.
--->
-<java version='1.4.0' class='java.beans.XMLDecoder'>
- <array class="java.lang.Object">
- <boolean>true</boolean>
- <short>1</short>
- <byte>2</byte>
- <char>c</char>
- <int>4</int>
- <long>5</long>
- <float>6</float>
- <double>7</double>
- <string>string</string>
- </array>
-</java> \ No newline at end of file
diff --git a/beans/src/test/resources/xml/Array_Primitive.xml b/beans/src/test/resources/xml/Array_Primitive.xml
deleted file mode 100644
index 4254504..0000000
--- a/beans/src/test/resources/xml/Array_Primitive.xml
+++ /dev/null
@@ -1,57 +0,0 @@
-<!--
- 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.
--->
- <java version='1.4.0' class='java.beans.XMLDecoder'>
- <array class="java.lang.Object">
- <array class='boolean'>
- <boolean>true</boolean>
- <boolean>false</boolean>
- </array>
- <array class='short'>
- <short>1</short>
- <short>1</short>
- </array>
- <array class='byte'>
- <byte>2</byte>
- <byte>2</byte>
- </array>
- <array class='char'>
- <char>c</char>
- <char>c</char>
- </array>
- <array class='int'>
- <int>4</int>
- <int>4</int>
- <int>4</int>
- <int>4</int>
- </array>
- <array class='long'>
- <long>5</long>
- <long>5</long>
- <long>5</long>
- <long>5</long>
- <long>5</long>
- </array>
- <array class='float'>
- <float>6</float>
- <float>6</float>
- </array>
- <array class='double'>
- <double>7</double>
- <double>7</double>
- </array>
- </array>
-</java> \ No newline at end of file
diff --git a/beans/src/test/resources/xml/Array_Wrapper.xml b/beans/src/test/resources/xml/Array_Wrapper.xml
deleted file mode 100644
index 0d9657d..0000000
--- a/beans/src/test/resources/xml/Array_Wrapper.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-<!--
- 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.
--->
-
- <java version='1.4.0' class='java.beans.XMLDecoder'>
- <array class='int'>
- <int>11</int>
- <int>22</int>
- </array>
-</java>
diff --git a/beans/src/test/resources/xml/ChangedObject.xml b/beans/src/test/resources/xml/ChangedObject.xml
deleted file mode 100644
index 365d30d..0000000
--- a/beans/src/test/resources/xml/ChangedObject.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<java version="${version}" class="java.beans.XMLDecoder">
- <object id="XMLEncoderTest$Sample0" class="org.apache.harmony.beans.tests.java.beans.XMLEncoderTest$Sample">
- <void property="name">
- <string>oldName</string>
- </void>
- </object>
- <object idref="XMLEncoderTest$Sample0"/>
-</java> \ No newline at end of file
diff --git a/beans/src/test/resources/xml/Choice.xml b/beans/src/test/resources/xml/Choice.xml
deleted file mode 100644
index 575fe5f..0000000
--- a/beans/src/test/resources/xml/Choice.xml
+++ /dev/null
@@ -1,45 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<java version="1.6.0" class="java.beans.XMLDecoder">
- <object class="java.awt.Choice">
- <void property="background">
- <object class="java.awt.Color">
- <int>0</int>
- <int>0</int>
- <int>255</int>
- <int>255</int>
- </object>
- </void>
- <void property="foreground">
- <object class="java.awt.Color">
- <int>0</int>
- <int>255</int>
- <int>0</int>
- <int>255</int>
- </object>
- </void>
- <void property="font">
- <object class="java.awt.Font">
- <string>Arial Bold</string>
- <int>2</int>
- <int>0</int>
- </object>
- </void>
- <void property="bounds">
- <object class="java.awt.Rectangle">
- <int>1</int>
- <int>2</int>
- <int>200</int>
- <int>100</int>
- </object>
- </void>
- <void property="name">
- <string>choice</string>
- </void>
- <void method="add">
- <string>addItem</string>
- </void>
- <void method="add">
- <string>add</string>
- </void>
- </object>
-</java> \ No newline at end of file
diff --git a/beans/src/test/resources/xml/ClassID.xml b/beans/src/test/resources/xml/ClassID.xml
deleted file mode 100644
index 1c46b8a..0000000
--- a/beans/src/test/resources/xml/ClassID.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<java version="${version}" class="java.beans.XMLDecoder">
- <object class="org.apache.harmony.beans.tests.java.beans.XMLEncoderTest$ChildClass">
- <void property="clazz">
- <class>org.apache.harmony.beans.tests.java.beans.XMLEncoderTest$ChildClass</class>
- </void>
- </object>
-</java>
-
diff --git a/beans/src/test/resources/xml/DependencyBean.xml b/beans/src/test/resources/xml/DependencyBean.xml
deleted file mode 100644
index f5f3cc1..0000000
--- a/beans/src/test/resources/xml/DependencyBean.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<java version="1.4.2_07" class="java.beans.XMLDecoder">
- <object class="org.apache.harmony.beans.tests.java.beans.XMLEncoderTest$DependencyBean">
- <void id="intArray0" property="ints">
- <void index="0">
- <int>888</int>
- </void>
- </void>
- <void property="ref">
- <object idref="intArray0"/>
- </void>
- </object>
-</java>
diff --git a/beans/src/test/resources/xml/IntArray.xml b/beans/src/test/resources/xml/IntArray.xml
deleted file mode 100644
index 2f86bbb..0000000
--- a/beans/src/test/resources/xml/IntArray.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<java version="1.4.2_07" class="java.beans.XMLDecoder">
- <array class="int" length="3">
- <void index="0">
- <int>1</int>
- </void>
- <void index="1">
- <int>2</int>
- </void>
- <void index="2">
- <int>3</int>
- </void>
- </array>
-</java>
diff --git a/beans/src/test/resources/xml/Integer.xml b/beans/src/test/resources/xml/Integer.xml
deleted file mode 100644
index 51472e4..0000000
--- a/beans/src/test/resources/xml/Integer.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<java version="1.6.0" class="java.beans.XMLDecoder">
- <int>1</int>
- <int>32</int>
- <int>2147483647</int>
- <int>-2147483648</int>
-</java>
diff --git a/beans/src/test/resources/xml/Mock2EnumObject.xml b/beans/src/test/resources/xml/Mock2EnumObject.xml
deleted file mode 100644
index 4d631d0..0000000
--- a/beans/src/test/resources/xml/Mock2EnumObject.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<java version="${version}" class="java.beans.XMLDecoder">
- <object class="${classname}">
- <void property="element">
- <object class="org.apache.harmony.beans.tests.java.beans.XMLEncoderTest$Element" method="valueOf">
- <string>ELEMENTB</string>
- </object>
- </void>
- </object>
-</java>
diff --git a/beans/src/test/resources/xml/MockBean4Codec_BornFriendChange.xml b/beans/src/test/resources/xml/MockBean4Codec_BornFriendChange.xml
deleted file mode 100644
index 79b5ce0..0000000
--- a/beans/src/test/resources/xml/MockBean4Codec_BornFriendChange.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<java version="${version}" class="java.beans.XMLDecoder">
- <object class="${classname}">
- <void id="MockBean4CodecPrimitives0" property="bornFriend">
- <void property="zarr">
- <void index="0">
- <int>888</int>
- </void>
- </void>
- </void>
- <void property="nill">
- <object idref="MockBean4CodecPrimitives0"/>
- </void>
- </object>
-</java>
diff --git a/beans/src/test/resources/xml/MockBean4Codec_ManyChanges.xml b/beans/src/test/resources/xml/MockBean4Codec_ManyChanges.xml
deleted file mode 100644
index d8e81bc..0000000
--- a/beans/src/test/resources/xml/MockBean4Codec_ManyChanges.xml
+++ /dev/null
@@ -1,112 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<java version="${version}" class="java.beans.XMLDecoder">
- <object id="MockBean4Codec0" class="${classname}">
- <void property="b">
- <byte>127</byte>
- </void>
- <void property="backRef">
- <object idref="MockBean4Codec0"/>
- </void>
- <void property="bobj">
- <byte>127</byte>
- </void>
- <void property="bool">
- <boolean>false</boolean>
- </void>
- <void property="boolobj">
- <boolean>true</boolean>
- </void>
- <void property="bornFriend">
- <void property="clazz">
- <class>java.lang.Exception</class>
- </void>
- <void property="zarr">
- <void index="0">
- <int>888</int>
- </void>
- </void>
- </void>
- <void property="c">
- <char>Z</char>
- </void>
- <void property="clazz">
- <class>java.lang.String</class>
- </void>
- <void property="cobj">
- <char>z</char>
- </void>
- <void property="d">
- <double>123.456</double>
- </void>
- <void property="dobj">
- <double>123.456</double>
- </void>
- <void property="f">
- <float>12.34</float>
- </void>
- <void property="fobj">
- <float>12.34</float>
- </void>
- <void property="friend">
- <object class="${classname}">
- <void property="clazz">
- <class>${classname}</class>
- </void>
- </object>
- </void>
- <void property="i">
- <int>999</int>
- </void>
- <void property="iobj">
- <int>999</int>
- </void>
- <void property="l">
- <long>8888888</long>
- </void>
- <void property="lobj">
- <long>8888888</long>
- </void>
- <void property="name">
- <string>Li Yang</string>
- </void>
- <void property="nill">
- <null/>
- </void>
- <void property="s">
- <short>55</short>
- </void>
- <void property="sobj">
- <short>55</short>
- </void>
- <void property="zarr">
- <array class="int" length="3">
- <void index="0">
- <int>3</int>
- </void>
- <void index="1">
- <int>2</int>
- </void>
- <void index="2">
- <int>1</int>
- </void>
- </array>
- </void>
- <void property="zarrarr">
- <array class="[Ljava.lang.String;" length="1">
- <void index="0">
- <array class="java.lang.String" length="3">
- <void index="0">
- <string>6</string>
- </void>
- <void index="1">
- <string>6</string>
- </void>
- <void index="2">
- <string>6</string>
- </void>
- </array>
- </void>
- </array>
- </void>
- </object>
-</java>
diff --git a/beans/src/test/resources/xml/MockBean4Codec_ManyChanges_2.xml b/beans/src/test/resources/xml/MockBean4Codec_ManyChanges_2.xml
deleted file mode 100644
index 96355d5..0000000
--- a/beans/src/test/resources/xml/MockBean4Codec_ManyChanges_2.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<java version="${version}" class="java.beans.XMLDecoder">
- <object class="${classname}">
- <void property="bornFriend">
- <void property="clazz">
- <class>java.lang.Exception</class>
- </void>
- </void>
- </object>
-</java>
diff --git a/beans/src/test/resources/xml/MockBean4Codec_NoChange.xml b/beans/src/test/resources/xml/MockBean4Codec_NoChange.xml
deleted file mode 100644
index bae6db9..0000000
--- a/beans/src/test/resources/xml/MockBean4Codec_NoChange.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<java version="${version}" class="java.beans.XMLDecoder">
- <object class="${classname}"/>
-</java>
diff --git a/beans/src/test/resources/xml/MockBean4Owner_SetOwner.xml b/beans/src/test/resources/xml/MockBean4Owner_SetOwner.xml
deleted file mode 100644
index e01d977..0000000
--- a/beans/src/test/resources/xml/MockBean4Owner_SetOwner.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<java version="${version}" class="java.beans.XMLDecoder">
- <void id="MockBean4Owner_Owner0" property="owner"/>
- <object class="${classname}">
- <void property="v">
- <object idref="MockBean4Owner_Owner0"/>
- </void>
- </object>
-</java>
diff --git a/beans/src/test/resources/xml/MockBean4Owner_SetOwnerWithWriteStatement.xml b/beans/src/test/resources/xml/MockBean4Owner_SetOwnerWithWriteStatement.xml
deleted file mode 100644
index 9edfa70..0000000
--- a/beans/src/test/resources/xml/MockBean4Owner_SetOwnerWithWriteStatement.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<java version="${version}" class="java.beans.XMLDecoder">
- <void id="MockBean4Owner_Owner0" property="owner">
- <void method="loading"/>
- </void>
- <object class="${classname}">
- <void property="v">
- <object idref="MockBean4Owner_Owner0"/>
- </void>
- </object>
-</java>
diff --git a/beans/src/test/resources/xml/MockBean4StaticField.xml b/beans/src/test/resources/xml/MockBean4StaticField.xml
deleted file mode 100644
index ad6d63e..0000000
--- a/beans/src/test/resources/xml/MockBean4StaticField.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<java version="${version}" class="java.beans.XMLDecoder">
- <object class="${classname}" field="inst"/>
-</java>
diff --git a/beans/src/test/resources/xml/MockBean4StaticField_Original.xml b/beans/src/test/resources/xml/MockBean4StaticField_Original.xml
deleted file mode 100644
index 073d5dd..0000000
--- a/beans/src/test/resources/xml/MockBean4StaticField_Original.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<java version="${version}" class="java.beans.XMLDecoder">
- <void class="${classname}">
- <string>inst</string>
- <void id="A0" method="get">
- <null/>
- </void>
- </void>
- <object idref="A0"/>
-</java>
diff --git a/beans/src/test/resources/xml/MockCheckedCollection.xml b/beans/src/test/resources/xml/MockCheckedCollection.xml
deleted file mode 100644
index 3abf592..0000000
--- a/beans/src/test/resources/xml/MockCheckedCollection.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<java version="${version}" class="java.beans.XMLDecoder">
- <object class="${classname}">
- <void property="property">
- <object class="java.util.Collections" method="checkedCollection">
- <object class="java.util.ArrayList">
- <void method="add">
- <string>A</string>
- </void>
- <void method="add">
- <string>B</string>
- </void>
- <void method="add">
- <string>C</string>
- </void>
- </object>
- <class>java.lang.String</class>
- </object>
- </void>
- </object>
-</java>
-
diff --git a/beans/src/test/resources/xml/MockCheckedList.xml b/beans/src/test/resources/xml/MockCheckedList.xml
deleted file mode 100644
index 98f3486..0000000
--- a/beans/src/test/resources/xml/MockCheckedList.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<java version="${version}" class="java.beans.XMLDecoder">
- <object class="${classname}">
- <void property="property">
- <object class="java.util.Collections" method="checkedList">
- <object class="java.util.LinkedList">
- <void method="add">
- <string>A</string>
- </void>
- <void method="add">
- <string>B</string>
- </void>
- <void method="add">
- <string>C</string>
- </void>
- </object>
- <class>java.lang.String</class>
- </object>
- </void>
- </object>
-</java>
-
diff --git a/beans/src/test/resources/xml/MockCheckedMap.xml b/beans/src/test/resources/xml/MockCheckedMap.xml
deleted file mode 100644
index 31e4623..0000000
--- a/beans/src/test/resources/xml/MockCheckedMap.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<java version="${version}" class="java.beans.XMLDecoder">
- <object class="${classname}">
- <void property="property">
- <object class="java.util.Collections" method="checkedMap">
- <object class="java.util.HashMap">
- <void method="put">
- <string>A</string>
- <string>a</string>
- </void>
- <void method="put">
- <string>B</string>
- <string>b</string>
- </void>
- <void method="put">
- <string>C</string>
- <string>c</string>
- </void>
- </object>
- <class>java.lang.String</class>
- <class>java.lang.String</class>
- </object>
- </void>
- </object>
-</java> \ No newline at end of file
diff --git a/beans/src/test/resources/xml/MockCheckedRandomAccessList.xml b/beans/src/test/resources/xml/MockCheckedRandomAccessList.xml
deleted file mode 100644
index 5daae2a..0000000
--- a/beans/src/test/resources/xml/MockCheckedRandomAccessList.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<java version="${version}" class="java.beans.XMLDecoder">
- <object class="${classname}">
- <void property="property">
- <object class="java.util.Collections" method="checkedList">
- <object class="java.util.ArrayList">
- <void method="add">
- <string>A</string>
- </void>
- <void method="add">
- <string>B</string>
- </void>
- <void method="add">
- <string>C</string>
- </void>
- </object>
- <class>java.lang.String</class>
- </object>
- </void>
- </object>
-</java>
-
diff --git a/beans/src/test/resources/xml/MockCheckedSet.xml b/beans/src/test/resources/xml/MockCheckedSet.xml
deleted file mode 100644
index af0743c..0000000
--- a/beans/src/test/resources/xml/MockCheckedSet.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<java version="${version}" class="java.beans.XMLDecoder">
- <object class="${classname}">
- <void property="property">
- <object class="java.util.Collections" method="checkedSet">
- <object class="java.util.HashSet">
- <void method="add">
- <string>A</string>
- </void>
- <void method="add">
- <string>B</string>
- </void>
- <void method="add">
- <string>C</string>
- </void>
- </object>
- <class>java.lang.String</class>
- </object>
- </void>
- </object>
-</java>
-
diff --git a/beans/src/test/resources/xml/MockCheckedSortedMap.xml b/beans/src/test/resources/xml/MockCheckedSortedMap.xml
deleted file mode 100644
index 5179966..0000000
--- a/beans/src/test/resources/xml/MockCheckedSortedMap.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<java version="${version}" class="java.beans.XMLDecoder">
- <object class="${classname}">
- <void property="property">
- <object class="java.util.Collections" method="checkedSortedMap">
- <object class="java.util.TreeMap">
- <void method="put">
- <string>A</string>
- <string>a</string>
- </void>
- <void method="put">
- <string>B</string>
- <string>b</string>
- </void>
- <void method="put">
- <string>C</string>
- <string>c</string>
- </void>
- </object>
- <class>java.lang.String</class>
- <class>java.lang.String</class>
- </object>
- </void>
- </object>
-</java> \ No newline at end of file
diff --git a/beans/src/test/resources/xml/MockCheckedSortedSet.xml b/beans/src/test/resources/xml/MockCheckedSortedSet.xml
deleted file mode 100644
index 43bf2f7..0000000
--- a/beans/src/test/resources/xml/MockCheckedSortedSet.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<java version="${version}" class="java.beans.XMLDecoder">
- <object class="${classname}">
- <void property="property">
- <object class="java.util.Collections" method="checkedSortedSet">
- <object class="java.util.TreeSet">
- <void method="add">
- <string>A</string>
- </void>
- <void method="add">
- <string>B</string>
- </void>
- <void method="add">
- <string>C</string>
- </void>
- </object>
- <class>java.lang.String</class>
- </object>
- </void>
- </object>
-</java>
-
diff --git a/beans/src/test/resources/xml/MockEnumObject.xml b/beans/src/test/resources/xml/MockEnumObject.xml
deleted file mode 100644
index 8f92d80..0000000
--- a/beans/src/test/resources/xml/MockEnumObject.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-
-<java version="${version}" class="java.beans.XMLDecoder">
- <object class="${classname}">
- <void property="element">
- <object class="org.apache.harmony.beans.tests.java.beans.XMLEncoderTest$Element" method="valueOf">
- <string>ELEMENTA</string>
- </object>
- </void>
- </object>
-</java>
diff --git a/beans/src/test/resources/xml/MockGetPropertyClass.xml b/beans/src/test/resources/xml/MockGetPropertyClass.xml
deleted file mode 100644
index 7b8e8cc..0000000
--- a/beans/src/test/resources/xml/MockGetPropertyClass.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<java version="${version}" class="java.beans.XMLDecoder">
- <object class="${classname}">
- <void id="HashSet0" property="property">
- <void method="add">
- <string>A</string>
- </void>
- <void method="add">
- <string>B</string>
- </void>
- <void method="add">
- <string>C</string>
- </void>
- </void>
- <void property="property">
- <object idref="HashSet0"/>
- </void>
- </object>
-</java> \ No newline at end of file
diff --git a/beans/src/test/resources/xml/MockListImplements.xml b/beans/src/test/resources/xml/MockListImplements.xml
deleted file mode 100644
index 76190bc..0000000
--- a/beans/src/test/resources/xml/MockListImplements.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<java version="${version}" class="java.beans.XMLDecoder">
- <object class="${classname}">
- <void property="property">
- <void method="add">
- <string>A</string>
- </void>
- </void>
- </object>
-</java>
-
diff --git a/beans/src/test/resources/xml/MockOwner.xml b/beans/src/test/resources/xml/MockOwner.xml
deleted file mode 100644
index 2ac421a..0000000
--- a/beans/src/test/resources/xml/MockOwner.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-
-<java version='1.6.0' class='java.beans.XMLDecoder'>
- <void property='owner'>
- <void method='get' id='v'>
- <string>key</string>
- </void>
- </void>
- <object idref='v'/>
-</java>
diff --git a/beans/src/test/resources/xml/MockOwner_Ambiguous.xml b/beans/src/test/resources/xml/MockOwner_Ambiguous.xml
deleted file mode 100644
index 18bb4e9..0000000
--- a/beans/src/test/resources/xml/MockOwner_Ambiguous.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-
-<java version='1.6.0' class='java.beans.XMLDecoder'>
- <void property='owner'>
- <void method='get' id='v'>
- <string>key</string>
- <string>key</string>
- </void>
- </void>
- <object idref='v'/>
-</java>
diff --git a/beans/src/test/resources/xml/MockOwner_Null.xml b/beans/src/test/resources/xml/MockOwner_Null.xml
deleted file mode 100644
index 2909f3f..0000000
--- a/beans/src/test/resources/xml/MockOwner_Null.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-
-<java version='1.6.0' class='java.beans.XMLDecoder'>
- <void property='owner'>
- <void method='get' id='v'>
- <null/>
- <string>key</string>
- </void>
- </void>
- <object idref='v'/>
-</java>
diff --git a/beans/src/test/resources/xml/MockOwner_Specific.xml b/beans/src/test/resources/xml/MockOwner_Specific.xml
deleted file mode 100644
index 2bbff0e..0000000
--- a/beans/src/test/resources/xml/MockOwner_Specific.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-
-<java version='1.6.0' class='java.beans.XMLDecoder'>
- <void property='owner'>
- <void method='get' id='v'>
- <int>2</int>
- <string>key</string>
- </void>
- </void>
- <object idref='v'/>
-</java>
diff --git a/beans/src/test/resources/xml/MockSetImplements.xml b/beans/src/test/resources/xml/MockSetImplements.xml
deleted file mode 100644
index 1b9c56a..0000000
--- a/beans/src/test/resources/xml/MockSetImplements.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<java version="${version}" class="java.beans.XMLDecoder">
- <object class="${classname}">
- <void property="property">
- <void method="add">
- <string>A</string>
- </void>
- </void>
- </object>
-</java>
-
diff --git a/beans/src/test/resources/xml/MockSynchronizedCollection.xml b/beans/src/test/resources/xml/MockSynchronizedCollection.xml
deleted file mode 100644
index 2cdc336..0000000
--- a/beans/src/test/resources/xml/MockSynchronizedCollection.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<java version="${version}" class="java.beans.XMLDecoder">
- <object class="${classname}">
- <void property="property">
- <object class="java.util.Collections" method="synchronizedCollection">
- <object class="java.util.ArrayList">
- <void method="add">
- <string>A</string>
- </void>
- <void method="add">
- <string>B</string>
- </void>
- <void method="add">
- <string>C</string>
- </void>
- </object>
- </object>
- </void>
- </object>
-</java>
-
diff --git a/beans/src/test/resources/xml/MockSynchronizedList.xml b/beans/src/test/resources/xml/MockSynchronizedList.xml
deleted file mode 100644
index 33bdcea..0000000
--- a/beans/src/test/resources/xml/MockSynchronizedList.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<java version="${version}" class="java.beans.XMLDecoder">
- <object class="${classname}">
- <void property="property">
- <object class="java.util.Collections" method="synchronizedList">
- <object class="java.util.LinkedList">
- <void method="add">
- <string>A</string>
- </void>
- <void method="add">
- <string>B</string>
- </void>
- <void method="add">
- <string>C</string>
- </void>
- </object>
- </object>
- </void>
- </object>
-</java>
-
diff --git a/beans/src/test/resources/xml/MockSynchronizedMap.xml b/beans/src/test/resources/xml/MockSynchronizedMap.xml
deleted file mode 100644
index 0efc0b4..0000000
--- a/beans/src/test/resources/xml/MockSynchronizedMap.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<java version="${version}" class="java.beans.XMLDecoder">
- <object class="${classname}">
- <void property="property">
- <object class="java.util.Collections" method="synchronizedMap">
- <object class="java.util.HashMap">
- <void method="put">
- <string>A</string>
- <string>a</string>
- </void>
- <void method="put">
- <string>B</string>
- <string>b</string>
- </void>
- <void method="put">
- <string>C</string>
- <string>c</string>
- </void>
- </object>
- </object>
- </void>
- </object>
-</java>
-
diff --git a/beans/src/test/resources/xml/MockSynchronizedRandomAccessList.xml b/beans/src/test/resources/xml/MockSynchronizedRandomAccessList.xml
deleted file mode 100644
index 9cb22a4..0000000
--- a/beans/src/test/resources/xml/MockSynchronizedRandomAccessList.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<java version="${version}" class="java.beans.XMLDecoder">
- <object class="${classname}">
- <void property="property">
- <object class="java.util.Collections" method="synchronizedList">
- <object class="java.util.ArrayList">
- <void method="add">
- <string>A</string>
- </void>
- <void method="add">
- <string>B</string>
- </void>
- <void method="add">
- <string>C</string>
- </void>
- </object>
- </object>
- </void>
- </object>
-</java>
-
diff --git a/beans/src/test/resources/xml/MockSynchronizedSet.xml b/beans/src/test/resources/xml/MockSynchronizedSet.xml
deleted file mode 100644
index 6426f6c..0000000
--- a/beans/src/test/resources/xml/MockSynchronizedSet.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<java version="${version}" class="java.beans.XMLDecoder">
- <object class="${classname}">
- <void property="property">
- <object class="java.util.Collections" method="synchronizedSet">
- <object class="java.util.HashSet">
- <void method="add">
- <string>A</string>
- </void>
- <void method="add">
- <string>B</string>
- </void>
- <void method="add">
- <string>C</string>
- </void>
- </object>
- </object>
- </void>
- </object>
-</java>
-
diff --git a/beans/src/test/resources/xml/MockSynchronizedSortedMap.xml b/beans/src/test/resources/xml/MockSynchronizedSortedMap.xml
deleted file mode 100644
index b34e9d2..0000000
--- a/beans/src/test/resources/xml/MockSynchronizedSortedMap.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<java version="${version}" class="java.beans.XMLDecoder">
- <object class="${classname}">
- <void property="property">
- <object class="java.util.Collections" method="synchronizedSortedMap">
- <object class="java.util.TreeMap">
- <void method="put">
- <string>A</string>
- <string>a</string>
- </void>
- <void method="put">
- <string>B</string>
- <string>b</string>
- </void>
- <void method="put">
- <string>C</string>
- <string>c</string>
- </void>
- </object>
- </object>
- </void>
- </object>
-</java>
-
diff --git a/beans/src/test/resources/xml/MockSynchronizedSortedSet.xml b/beans/src/test/resources/xml/MockSynchronizedSortedSet.xml
deleted file mode 100644
index 4b50148..0000000
--- a/beans/src/test/resources/xml/MockSynchronizedSortedSet.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<java version="${version}" class="java.beans.XMLDecoder">
- <object class="${classname}">
- <void property="property">
- <object class="java.util.Collections" method="synchronizedSortedSet">
- <object class="java.util.TreeSet">
- <void method="add">
- <string>A</string>
- </void>
- <void method="add">
- <string>B</string>
- </void>
- <void method="add">
- <string>C</string>
- </void>
- </object>
- </object>
- </void>
- </object>
-</java>
-
diff --git a/beans/src/test/resources/xml/MockTreeMap.xml b/beans/src/test/resources/xml/MockTreeMap.xml
deleted file mode 100644
index 29b03a8..0000000
--- a/beans/src/test/resources/xml/MockTreeMap.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-
-<java version="${version}" class="java.beans.XMLDecoder">
- <object class="${classname}">
- <void method="get">
- <string>outer_key</string>
- <void method="put">
- <string>inner_key</string>
- <string>value</string>
- </void>
- </void>
- </object>
-</java>
diff --git a/beans/src/test/resources/xml/MockUnmodifiableCollection.xml b/beans/src/test/resources/xml/MockUnmodifiableCollection.xml
deleted file mode 100644
index 43227a5..0000000
--- a/beans/src/test/resources/xml/MockUnmodifiableCollection.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<java version="${version}" class="java.beans.XMLDecoder">
- <object class="${classname}">
- <void property="property">
- <object class="java.util.Collections" method="unmodifiableCollection">
- <object class="java.util.ArrayList">
- <void method="add">
- <string>A</string>
- </void>
- <void method="add">
- <string>B</string>
- </void>
- <void method="add">
- <string>C</string>
- </void>
- </object>
- </object>
- </void>
- </object>
-</java>
-
diff --git a/beans/src/test/resources/xml/MockUnmodifiableList.xml b/beans/src/test/resources/xml/MockUnmodifiableList.xml
deleted file mode 100644
index 9f3d212..0000000
--- a/beans/src/test/resources/xml/MockUnmodifiableList.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<java version="${version}" class="java.beans.XMLDecoder">
- <object class="${classname}">
- <void property="property">
- <object class="java.util.Collections" method="unmodifiableList">
- <object class="java.util.LinkedList">
- <void method="add">
- <string>A</string>
- </void>
- <void method="add">
- <string>B</string>
- </void>
- <void method="add">
- <string>C</string>
- </void>
- </object>
- </object>
- </void>
- </object>
-</java>
-
diff --git a/beans/src/test/resources/xml/MockUnmodifiableMap.xml b/beans/src/test/resources/xml/MockUnmodifiableMap.xml
deleted file mode 100644
index d5bd832..0000000
--- a/beans/src/test/resources/xml/MockUnmodifiableMap.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<java version="${version}" class="java.beans.XMLDecoder">
- <object class="${classname}">
- <void property="property">
- <object class="java.util.Collections" method="unmodifiableMap">
- <object class="java.util.HashMap">
- <void method="put">
- <string>A</string>
- <string>a</string>
- </void>
- <void method="put">
- <string>B</string>
- <string>b</string>
- </void>
- <void method="put">
- <string>C</string>
- <string>c</string>
- </void>
- </object>
- </object>
- </void>
- </object>
-</java>
-
diff --git a/beans/src/test/resources/xml/MockUnmodifiableRandomAccessList.xml b/beans/src/test/resources/xml/MockUnmodifiableRandomAccessList.xml
deleted file mode 100644
index 41cb2f9..0000000
--- a/beans/src/test/resources/xml/MockUnmodifiableRandomAccessList.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<java version="${version}" class="java.beans.XMLDecoder">
- <object class="${classname}">
- <void property="property">
- <object class="java.util.Collections" method="unmodifiableList">
- <object class="java.util.ArrayList">
- <void method="add">
- <string>A</string>
- </void>
- <void method="add">
- <string>B</string>
- </void>
- <void method="add">
- <string>C</string>
- </void>
- </object>
- </object>
- </void>
- </object>
-</java>
-
diff --git a/beans/src/test/resources/xml/MockUnmodifiableSet.xml b/beans/src/test/resources/xml/MockUnmodifiableSet.xml
deleted file mode 100644
index 91ba582..0000000
--- a/beans/src/test/resources/xml/MockUnmodifiableSet.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<java version="${version}" class="java.beans.XMLDecoder">
- <object class="${classname}">
- <void property="property">
- <object class="java.util.Collections" method="unmodifiableSet">
- <object class="java.util.HashSet">
- <void method="add">
- <string>A</string>
- </void>
- <void method="add">
- <string>B</string>
- </void>
- <void method="add">
- <string>C</string>
- </void>
- </object>
- </object>
- </void>
- </object>
-</java>
-
diff --git a/beans/src/test/resources/xml/MockUnmodifiableSortedMap.xml b/beans/src/test/resources/xml/MockUnmodifiableSortedMap.xml
deleted file mode 100644
index 143fcb2..0000000
--- a/beans/src/test/resources/xml/MockUnmodifiableSortedMap.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<java version="${version}" class="java.beans.XMLDecoder">
- <object class="${classname}">
- <void property="property">
- <object class="java.util.Collections" method="unmodifiableSortedMap">
- <object class="java.util.TreeMap">
- <void method="put">
- <string>A</string>
- <string>a</string>
- </void>
- <void method="put">
- <string>B</string>
- <string>b</string>
- </void>
- <void method="put">
- <string>C</string>
- <string>c</string>
- </void>
- </object>
- </object>
- </void>
- </object>
-</java>
-
diff --git a/beans/src/test/resources/xml/MockUnmodifiableSortedSet.xml b/beans/src/test/resources/xml/MockUnmodifiableSortedSet.xml
deleted file mode 100644
index c63bce2..0000000
--- a/beans/src/test/resources/xml/MockUnmodifiableSortedSet.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<java version="${version}" class="java.beans.XMLDecoder">
- <object class="${classname}">
- <void property="property">
- <object class="java.util.Collections" method="unmodifiableSortedSet">
- <object class="java.util.TreeSet">
- <void method="add">
- <string>A</string>
- </void>
- <void method="add">
- <string>B</string>
- </void>
- <void method="add">
- <string>C</string>
- </void>
- </object>
- </object>
- </void>
- </object>
-</java>
-
diff --git a/beans/src/test/resources/xml/ObjectID.xml b/beans/src/test/resources/xml/ObjectID.xml
deleted file mode 100644
index 50b7f5c..0000000
--- a/beans/src/test/resources/xml/ObjectID.xml
+++ /dev/null
@@ -1,56 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<java version="${version}" class="java.beans.XMLDecoder">
- <object id="XMLEncoderTest$ExampleA0" class="org.apache.harmony.beans.tests.java.beans.XMLEncoderTest$ExampleA">
- <void property="name">
- <string>exampleAI</string>
- </void>
- </object>
- <object idref="XMLEncoderTest$ExampleA0"/>
- <object id="XMLEncoderTest$ExampleA1" class="org.apache.harmony.beans.tests.java.beans.XMLEncoderTest$ExampleA">
- <void property="name">
- <string>exampleAI</string>
- </void>
- </object>
- <object idref="XMLEncoderTest$ExampleA1"/>
- <object id="XMLEncoderTest$ExampleB0" class="org.apache.harmony.beans.tests.java.beans.XMLEncoderTest$ExampleB">
- <void property="name">
- <string>exampleBI</string>
- </void>
- </object>
- <object idref="XMLEncoderTest$ExampleB0"/>
- <object id="XMLEncoderTest$ExampleB1" class="org.apache.harmony.beans.tests.java.beans.XMLEncoderTest$ExampleB">
- <void property="name">
- <string>exampleBII</string>
- </void>
- </object>
- <object idref="XMLEncoderTest$ExampleB1"/>
- <object id="XMLEncoderTest$ExampleC0" class="org.apache.harmony.beans.tests.java.beans.XMLEncoderTest$ExampleC">
- <void property="name">
- <string>exampleCI</string>
- </void>
- </object>
- <object idref="XMLEncoderTest$ExampleC0"/>
- <object id="XMLEncoderTest$ExampleC1" class="org.apache.harmony.beans.tests.java.beans.XMLEncoderTest$ExampleC">
- <void property="name">
- <string>exampleCII</string>
- </void>
- </object>
- <object idref="XMLEncoderTest$ExampleC1"/>
-</java>
-
diff --git a/beans/src/test/resources/xml/Proxy.xml b/beans/src/test/resources/xml/Proxy.xml
deleted file mode 100644
index a83fa7c..0000000
--- a/beans/src/test/resources/xml/Proxy.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<java version="1.6.0" class="java.beans.XMLDecoder">
-</java>
diff --git a/beans/src/test/resources/xml/SampleBean_StringCodec.xml b/beans/src/test/resources/xml/SampleBean_StringCodec.xml
deleted file mode 100644
index 0b43ddb..0000000
--- a/beans/src/test/resources/xml/SampleBean_StringCodec.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<java version="1.4.2_07" class="java.beans.XMLDecoder">
- <object class="org.apache.harmony.beans.tests.java.beans.EncoderTest$SampleBean">
- <void property="myid">
- <string>&lt;Li Yang&gt; &amp; &quot;liyang&apos;</string>
- </void>
- <void property="ref">
- <object class="org.apache.harmony.beans.tests.java.beans.EncoderTest$SampleBean">
- <void property="myid">
- <string>a child</string>
- </void>
- </object>
- </void>
- </object>
-</java>
diff --git a/beans/src/test/resources/xml/StaticField.xml b/beans/src/test/resources/xml/StaticField.xml
deleted file mode 100644
index 2a291b4..0000000
--- a/beans/src/test/resources/xml/StaticField.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<java version="${version}" class="java.beans.XMLDecoder">
- <object class="org.apache.harmony.beans.tests.java.beans.XMLEncoderTest$MockObject" field="inst"/>
- <object class="org.apache.harmony.beans.tests.java.beans.XMLEncoderTest$MockObject" field="inst"/>
- <object class="java.awt.SystemColor" field="activeCaption"/>
- <object class="java.awt.SystemColor" field="activeCaption"/>
- <object class="java.awt.font.TextAttribute" field="FAMILY"/>
- <object class="java.awt.font.TextAttribute" field="FAMILY"/>
-</java> \ No newline at end of file
diff --git a/beans/src/test/resources/xml/Test1.xml b/beans/src/test/resources/xml/Test1.xml
deleted file mode 100644
index 01d1b17..0000000
--- a/beans/src/test/resources/xml/Test1.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-<!--
- 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.
--->
-
-<!--
-Author: Maxim V. Berkultsev
--->
-<java>
-
- <object class="java.util.LinkedList">
- <void method="add">
- <object class="java.lang.Object"/>
- </void>
- <void index="0">
- <object class="java.lang.Object"/>
- </void>
- <void index="0">
- <string>Hello</string>
- </void>
- <void index="0"/>
- </object>
-
-</java> \ No newline at end of file
diff --git a/beans/src/test/resources/xml/Test2.xml b/beans/src/test/resources/xml/Test2.xml
deleted file mode 100644
index ccdebdd..0000000
--- a/beans/src/test/resources/xml/Test2.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<!--
- 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.
--->
-
-<!--
-Author: Maxim V. Berkultsev
--->
-<java>
-
- <array class="float" length="3">
- <void index="1">
- <float>100.0</float>
- </void>
- <void index="2">
- <float>100.0</float>
- </void>
- </array>
-
-</java> \ No newline at end of file
diff --git a/beans/src/test/resources/xml/Test3.xml b/beans/src/test/resources/xml/Test3.xml
deleted file mode 100644
index 0a0ed4d..0000000
--- a/beans/src/test/resources/xml/Test3.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<!--
- 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.
--->
-
-<!--
-Author: Maxim V. Berkultsev
--->
-<java>
-
- <array class="float">
- <float>123</float>
- <float>123</float>
- <float>123</float>
- </array>
-
-</java> \ No newline at end of file
diff --git a/beans/src/test/resources/xml/Test4.xml b/beans/src/test/resources/xml/Test4.xml
deleted file mode 100644
index a2ee63d..0000000
--- a/beans/src/test/resources/xml/Test4.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<!--
- 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.
--->
-
-<!--
-Author: Maxim V. Berkultsev
--->
-<java>
-
- <array class="java.lang.Object" length="3">
- <void index="0">
- <object class="java.lang.Object"/>
- </void>
- </array>
-
-</java> \ No newline at end of file
diff --git a/beans/src/test/resources/xml/Test5.xml b/beans/src/test/resources/xml/Test5.xml
deleted file mode 100644
index 9aabee4..0000000
--- a/beans/src/test/resources/xml/Test5.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<!--
- 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.
--->
-
-<!--
-Author: Maxim V. Berkultsev
--->
-<java>
-
- <array class="java.lang.Object">
- <object class="java.lang.Object"/>
- <object class="java.lang.Object"/>
- <object class="java.lang.Object"/>
- </array>
-
-</java> \ No newline at end of file
diff --git a/beans/src/test/resources/xml/Test6.xml b/beans/src/test/resources/xml/Test6.xml
deleted file mode 100644
index ef4945d..0000000
--- a/beans/src/test/resources/xml/Test6.xml
+++ /dev/null
@@ -1,64 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-
-<!--
-Author: Maxim V. Berkultsev
--->
-<java version="${version}" class="java.beans.XMLDecoder">
- <object id="SampleBean0" class="${classname}">
- <void property="object">
- <object id="SampleBean1" class="${classname}">
- <void property="object">
- <object id="SampleBean2" class="${classname}">
- <void property="object">
- <object idref="SampleBean0"/>
- </void>
- <void property="otherText">
- <string>Constructor with args</string>
- </void>
- <void property="text">
- <string>Hello3</string>
- </void>
- </object>
- </void>
- <void property="otherText">
- <string>Constructor with args</string>
- </void>
- <void property="text">
- <string>Hello2</string>
- </void>
- </object>
- </void>
- <void property="objects">
- <array class="java.lang.Object" length="3">
- <void index="1">
- <object class="java.lang.Object"/>
- </void>
- </array>
- </void>
- <void property="smth">
- <array class="double" length="3">
- <void index="2">
- <double>1.0</double>
- </void>
- </array>
- </void>
- </object>
- <object idref="SampleBean1"/>
- <object idref="SampleBean2"/>
-</java>
diff --git a/beans/src/test/resources/xml/Test7.xml b/beans/src/test/resources/xml/Test7.xml
deleted file mode 100644
index 41039f1..0000000
--- a/beans/src/test/resources/xml/Test7.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-
-<!--
-Author: Maxim V. Berkultsev
--->
-<java version="${version}" class="java.beans.XMLDecoder">
-
- <array class="java.lang.String" length="2">
- <void index="0">
- <string>aa</string>
- </void>
- </array>
-
- <array class="java.lang.String">
- <string>aa</string>
- <string>bb</string>
- </array>
-
-</java> \ No newline at end of file
diff --git a/beans/src/test/resources/xml/bad_int.xml b/beans/src/test/resources/xml/bad_int.xml
deleted file mode 100644
index efb317e..0000000
--- a/beans/src/test/resources/xml/bad_int.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<java version="${version}" class="java.beans.XMLDecoder">
- <int>3</inta>
-</java>
diff --git a/beans/src/test/resources/xml/int.xml b/beans/src/test/resources/xml/int.xml
deleted file mode 100644
index b482bd9..0000000
--- a/beans/src/test/resources/xml/int.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<java version="${version}" class="java.beans.XMLDecoder">
- <int>3</int>
-</java>
diff --git a/beans/src/test/resources/xml/null.xml b/beans/src/test/resources/xml/null.xml
deleted file mode 100644
index 0b7b394..0000000
--- a/beans/src/test/resources/xml/null.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<java version="${version}" class="java.beans.XMLDecoder">
- <null/>
-</java>
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/infos/MockFooButtonBeanInfo.java b/beans/src/test/support/java/org/apache/harmony/beans/infos/MockFooButtonBeanInfo.java
deleted file mode 100644
index 810df0a..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/infos/MockFooButtonBeanInfo.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * 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.infos;
-
-import java.beans.BeanDescriptor;
-import java.beans.IntrospectionException;
-import java.beans.PropertyDescriptor;
-import java.beans.SimpleBeanInfo;
-
-import org.apache.harmony.beans.tests.support.mock.MockFooButton;
-
-/**
- * BeanInfo for the MockFooButton class
- */
-public class MockFooButtonBeanInfo extends SimpleBeanInfo {
- private final Class<MockFooButton> clazz = MockFooButton.class;
- private final String suffix = ".MockFooButtonBeanInfo";
-
- @Override
- public BeanDescriptor getBeanDescriptor() {
- BeanDescriptor beanDesc = new BeanDescriptor(clazz);
-
- beanDesc.setName(beanDesc.getName() + suffix);
- return beanDesc;
- }
-
- @Override
- public PropertyDescriptor[] getPropertyDescriptors() {
- PropertyDescriptor pd = null;
-
- try {
- pd = new PropertyDescriptor("text", clazz);
- pd.setName(pd.getName() + suffix);
- } catch (IntrospectionException e) {}
-
- return new PropertyDescriptor[] { pd };
- }
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/AType.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/AType.java
deleted file mode 100644
index 54bced6..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/AType.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * 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.
- */
-
-/**
- * @author Maxim V. Berkultsev
- */
-package org.apache.harmony.beans.tests.support;
-
-/**
- * @author Maxim V. Berkultsev
- */
-
-public class AType {
-
- public Object go() {
- return new Object();
- }
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/AnotherSampleProperty.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/AnotherSampleProperty.java
deleted file mode 100644
index db952c6..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/AnotherSampleProperty.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * 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.
- */
-
-/**
- * @author Maxim V. Berkultsev
- */
-package org.apache.harmony.beans.tests.support;
-
-/**
- * @author Maxim V. Berkultsev
- */
-
-public class AnotherSampleProperty {
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/AnotherSamplePropertyEditor.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/AnotherSamplePropertyEditor.java
deleted file mode 100644
index 71f1149..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/AnotherSamplePropertyEditor.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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.
- */
-
-/**
- * @author Maxim V. Berkultsev
- */
-package org.apache.harmony.beans.tests.support;
-
-import java.beans.PropertyEditorSupport;
-
-/**
- * @author Maxim V. Berkultsev
- */
-
-public class AnotherSamplePropertyEditor extends PropertyEditorSupport {
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/ChildBean.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/ChildBean.java
deleted file mode 100644
index 3b1b77b..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/ChildBean.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * 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.
- */
-
-/**
- * @author Maxim V. Berkultsev
- */
-package org.apache.harmony.beans.tests.support;
-
-/**
- * @author Maxim V. Berkultsev
- */
-
-public class ChildBean extends ParentBean {
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/ChildBeanBeanInfo.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/ChildBeanBeanInfo.java
deleted file mode 100644
index f26cfc5..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/ChildBeanBeanInfo.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * 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.
- */
-
-/**
- * @author Maxim V. Berkultsev
- */
-package org.apache.harmony.beans.tests.support;
-
-import java.beans.IntrospectionException;
-import java.beans.PropertyDescriptor;
-import java.beans.SimpleBeanInfo;
-
-/**
- * @author Maxim V. Berkultsev
- */
-
-public class ChildBeanBeanInfo extends SimpleBeanInfo {
-
- public ChildBeanBeanInfo() {
- super();
- }
-
- @Override
- public PropertyDescriptor[] getPropertyDescriptors() {
- try {
- return new PropertyDescriptor[] { new PropertyDescriptor(
- "childText", ChildBean.class, "getText", "setText") };
- } catch (IntrospectionException ie) {
- System.out.println("in ChildBeanBeanInfo.getPropertyDescriptors: "
- + ie.getMessage());
- return null;
- }
- }
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/GrannyBean.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/GrannyBean.java
deleted file mode 100644
index 56a552e..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/GrannyBean.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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.
- */
-
-/**
- * @author Maxim V. Berkultsev
- */
-package org.apache.harmony.beans.tests.support;
-
-/**
- * @author Maxim V. Berkultsev
- */
-
-public class GrannyBean {
-
- private String text = "GrannyBean";
-
- public String getText() {
- return text;
- }
-
- public void setText(String text) {
- this.text = text;
- }
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/GrannyBeanBeanInfo.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/GrannyBeanBeanInfo.java
deleted file mode 100644
index 109b450..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/GrannyBeanBeanInfo.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * 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.
- */
-
-/**
- * @author Maxim V. Berkultsev
- */
-package org.apache.harmony.beans.tests.support;
-
-import java.beans.IntrospectionException;
-import java.beans.PropertyDescriptor;
-import java.beans.SimpleBeanInfo;
-
-/**
- * @author Maxim V. Berkultsev
- */
-
-public class GrannyBeanBeanInfo extends SimpleBeanInfo {
-
- public GrannyBeanBeanInfo() {
- super();
- }
-
- @Override
- public PropertyDescriptor[] getPropertyDescriptors() {
- try {
- return new PropertyDescriptor[] { new PropertyDescriptor(
- "grannyText", GrannyBean.class, "getText", "setText") };
- } catch (IntrospectionException ie) {
- System.out.println("in GrannyBeanBeanInfo.getPropertyDescriptors: "
- + ie.getMessage());
- return null;
- }
- }
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/MisprintBean.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/MisprintBean.java
deleted file mode 100644
index f19f847..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/MisprintBean.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * 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.
- */
-
-/**
- * @author Maxim V. Berkultsev
- */
-package org.apache.harmony.beans.tests.support;
-
-/**
- * @author Maxim V. Berkultsev
- */
-
-public class MisprintBean {
-
- // public void addMisprintListener(MisprintListenerr ml) {}
- public void removeMisprintListener(MisprintListenerr ml) {
- }
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/MisprintEvent.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/MisprintEvent.java
deleted file mode 100644
index 640741d..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/MisprintEvent.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * 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;
-
-import java.util.EventObject;
-
-public class MisprintEvent extends EventObject {
-
- private static final long serialVersionUID = 6237503200476618235L;
-
- public MisprintEvent(Object object) {
- super(object);
- }
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/MisprintListenerr.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/MisprintListenerr.java
deleted file mode 100644
index ca109f7..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/MisprintListenerr.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * 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.
- */
-
-/**
- * @author Maxim V. Berkultsev
- */
-package org.apache.harmony.beans.tests.support;
-
-import java.util.EventListener;
-
-/**
- * @author Maxim V. Berkultsev
- */
-
-public interface MisprintListenerr extends EventListener {
-
- public void fireMisprintEvent(MisprintEvent me);
- // public void fireMisprint2Event(MisprintEvent me);
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/MockOwnerClass.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/MockOwnerClass.java
deleted file mode 100644
index 11252c0..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/MockOwnerClass.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * 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;
-
-public class MockOwnerClass {
- static public String get(int a , String b){
- return "I_Ljava.lang.String";
- }
-
- static public String get(Integer a, Object b){
- return "Ljava.lang.Integer_Ljava.lang.Object";
- }
-
- static public String get(Object a, String b){
- return "Ljava.lang.Object_Ljava.lang.String";
- }
-
- public String get(String b, Object a){
- return "Ljava.lang.Object_Ljava.lang.String";
- }
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/OtherBean.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/OtherBean.java
deleted file mode 100644
index 804eb5b..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/OtherBean.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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;
-
-import java.beans.PropertyChangeListener;
-
-public class OtherBean {
-
- public void addSampleListener(SampleListener listener) {
- }
-
- public void removeSampleListener(SampleListener listener) {
- }
-
- // no corresponding add method
- public void removePropertyChangeListener(PropertyChangeListener listener) {
- }
-
- public void setNumber(int a) {
- }
-
- public void set(int a) {
- }
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/OtherEditor.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/OtherEditor.java
deleted file mode 100644
index cef80d4..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/OtherEditor.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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.
- */
-
-/**
- * @author Maxim V. Berkultsev
- */
-package org.apache.harmony.beans.tests.support;
-
-import java.beans.PropertyEditorSupport;
-
-/**
- * @author Maxim V. Berkultsev
- */
-
-public class OtherEditor extends PropertyEditorSupport {
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/ParentBean.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/ParentBean.java
deleted file mode 100644
index 3156499..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/ParentBean.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * 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.
- */
-
-/**
- * @author Maxim V. Berkultsev
- */
-package org.apache.harmony.beans.tests.support;
-
-/**
- * @author Maxim V. Berkultsev
- */
-
-public class ParentBean extends GrannyBean {
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/ParentBeanBeanInfo.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/ParentBeanBeanInfo.java
deleted file mode 100644
index b1e2042..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/ParentBeanBeanInfo.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * 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.
- */
-
-/**
- * @author Maxim V. Berkultsev
- */
-package org.apache.harmony.beans.tests.support;
-
-import java.beans.IntrospectionException;
-import java.beans.PropertyDescriptor;
-import java.beans.SimpleBeanInfo;
-
-/**
- * @author Maxim V. Berkultsev
- */
-
-public class ParentBeanBeanInfo extends SimpleBeanInfo {
-
- public ParentBeanBeanInfo() {
- super();
- }
-
- @Override
- public PropertyDescriptor[] getPropertyDescriptors() {
- try {
- return new PropertyDescriptor[] { new PropertyDescriptor(
- "parentText", ParentBean.class, "getText", "setText") };
- } catch (IntrospectionException ie) {
- System.out.println("in ParentBeanBeanInfo.getPropertyDescriptors: "
- + ie.getMessage());
- return null;
- }
-
- }
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/SampleBean.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/SampleBean.java
deleted file mode 100644
index 9c7b726..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/SampleBean.java
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- * 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.
- */
-
-/**
- * @author Maxim V. Berkultsev
- */
-package org.apache.harmony.beans.tests.support;
-
-import java.util.Iterator;
-import java.util.TooManyListenersException;
-import java.util.Vector;
-
-/**
- * @author Maxim V. Berkultsev
- */
-
-public class SampleBean {
-
- private String text = null;
-
- private String otherText = null;
-
- private SampleBean bean = null;
-
- private int x = 0;
-
- private double[] smth;
-
- private Object[] smthObjs;
-
- private Vector<SampleListener> listeners;
-
- public SampleBean() {
- this.text = null;
- }
-
- public SampleBean(String text) {
- this.text = text;
- this.otherText = "Constructor with args";
- }
-
- protected SampleBean(String text, SampleBean bean) {
- this.text = text;
- this.bean = bean;
- }
-
- public String getText() {
- return text;
- }
-
- public void setText(String text) {
- this.text = text;
- }
-
- public SampleBean getObject() {
- return bean;
- }
-
- public void setObject(SampleBean bean) {
- this.bean = bean;
- }
-
- public String getOtherText() {
- return otherText;
- }
-
- public void setOtherText(String value) {
- this.otherText = value;
- }
-
- public int getX() {
- return x;
- }
-
- public void setX(int value) {
- this.x = value;
- }
-
- public double getSmthByIdx(int i) {
- return smth[i];
- }
-
- public void setSmthByIdx(int i, double value) {
- smth[i] = value;
- }
-
- public double[] getSmth() {
- return this.smth;
- }
-
- public void setSmth(double[] value) {
- this.smth = value;
- }
-
- public Object getObjectByIdx(int i) {
- return smthObjs[i];
- }
-
- public void setObjectByIdx(int i, Object value) {
- this.smthObjs[i] = value;
- }
-
- public Object[] getObjects() {
- return smthObjs;
- }
-
- public void setObjects(Object[] value) {
- this.smthObjs = value;
- }
-
- @Override
- public boolean equals(Object other) {
- if (other instanceof SampleBean) {
- SampleBean sb = (SampleBean) other;
- if ((sb.bean == null) && (bean == null)) {
- return true;
- } else if ((sb.bean != null) && (bean != null)) {
- return true;
- } else {
- return false;
- }
- }
- return false;
- }
-
- public static SampleBean create(String text, SampleBean bean) {
- return new SampleBean(text, bean);
- }
-
- public void addSampleListener(SampleListener listener)
- throws TooManyListenersException {
- if (listeners == null) {
- listeners = new Vector<SampleListener>();
- }
-
- if (listeners.size() >= 100) {
- throw new TooManyListenersException(
- "Number of listeners could not exceed 100");
- }
- listeners.add(listener);
- }
-
- public void removeSampleListener(SampleListener listener) {
- if (listeners != null) {
- listeners.remove(listener);
- }
- }
-
- public SampleListener[] getSampleListeners() {
- if (listeners != null) {
- SampleListener[] result = new SampleListener[listeners.size()];
-
- Iterator<SampleListener> i = listeners.iterator();
-
- int idx = 0;
- while (i.hasNext()) {
- result[idx++] = i.next();
- }
-
- return result;
- }
- return new SampleListener[] {};
- }
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/SampleBeanBeanInfo.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/SampleBeanBeanInfo.java
deleted file mode 100644
index d174fc9..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/SampleBeanBeanInfo.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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.
- */
-
-/**
- * @author Maxim V. Berkultsev
- */
-package org.apache.harmony.beans.tests.support;
-
-import java.beans.MethodDescriptor;
-import java.beans.SimpleBeanInfo;
-
-/**
- * @author Maxim V. Berkultsev
- */
-
-public class SampleBeanBeanInfo extends SimpleBeanInfo {
-
- @Override
- public MethodDescriptor[] getMethodDescriptors() {
- try {
- return new MethodDescriptor[] { new MethodDescriptor(
- SampleBean.class.getDeclaredMethod("getX", (Class[]) null)) };
- } catch (Exception e) {
- return null;
- }
- }
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/SampleEvent.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/SampleEvent.java
deleted file mode 100644
index 7d2ef87..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/SampleEvent.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * 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;
-
-import java.util.EventObject;
-
-public class SampleEvent extends EventObject {
-
- private static final long serialVersionUID = 5298423873363309034L;
-
- private final int i = 7;
-
- private static int j = 7;
-
- public SampleEvent(Object object) {
- super(object);
- }
-
- public int getI() {
- return i;
- }
-
- public void setI(int j) {
- j = i;
- }
-
- public static int getJ() {
- return j;
- }
-
- public static void setJ(int i) {
- j = i;
- }
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/SampleException.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/SampleException.java
deleted file mode 100644
index ad629c4..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/SampleException.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * 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;
-
-public class SampleException extends Exception {
-
- private static final long serialVersionUID = 8001501122369182728L;
-
- public SampleException(String msg) {
- }
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/SampleListener.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/SampleListener.java
deleted file mode 100644
index 414609a..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/SampleListener.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * 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.
- */
-
-/**
- * @author Maxim V. Berkultsev
- */
-package org.apache.harmony.beans.tests.support;
-
-/**
- * @author Maxim V. Berkultsev
- */
-import java.util.EventListener;
-
-public interface SampleListener extends EventListener {
-
- public void fireSampleEvent(SampleEvent event);
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/SampleProperty.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/SampleProperty.java
deleted file mode 100644
index f3c1b67..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/SampleProperty.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * 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.
- */
-
-/**
- * @author Maxim V. Berkultsev
- */
-package org.apache.harmony.beans.tests.support;
-
-/**
- * @author Maxim V. Berkultsev
- */
-
-public class SampleProperty {
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/SamplePropertyEditor.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/SamplePropertyEditor.java
deleted file mode 100644
index a9f82be..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/SamplePropertyEditor.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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.
- */
-
-/**
- * @author Maxim V. Berkultsev
- */
-package org.apache.harmony.beans.tests.support;
-
-import java.beans.PropertyEditorSupport;
-
-/**
- * @author Maxim V. Berkultsev
- */
-
-public class SamplePropertyEditor extends PropertyEditorSupport {
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/StandardBean2BeanInfo.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/StandardBean2BeanInfo.java
deleted file mode 100644
index 4cf6f9b..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/StandardBean2BeanInfo.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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.
- */
-
-/**
- * @author Maxim V. Berkultsev
- */
-package org.apache.harmony.beans.tests.support;
-
-import java.beans.BeanInfo;
-import java.beans.SimpleBeanInfo;
-
-/**
- * @author Maxim V. Berkultsev
- */
-
-public class StandardBean2BeanInfo extends SimpleBeanInfo {
-
- @Override
- public BeanInfo[] getAdditionalBeanInfo() {
- try {
- return new BeanInfo[] { GrannyBeanBeanInfo.class.newInstance(),
- GrannyBeanBeanInfo.class.newInstance() };
- } catch (Exception e) {
- return null;
- }
- }
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/StringEditor.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/StringEditor.java
deleted file mode 100644
index 31770ad..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/StringEditor.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * 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;
-
-import java.beans.PropertyEditorSupport;
-
-public class StringEditor extends PropertyEditorSupport {
-
- public StringEditor(final Object source) {
- super(source);
- }
-
- public StringEditor() {
- super();
- }
-
- @Override
- public void setAsText(String text) {
- setValue(text);
- }
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/TInspectorCluster.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/TInspectorCluster.java
deleted file mode 100644
index 3dcfae7..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/TInspectorCluster.java
+++ /dev/null
@@ -1,298 +0,0 @@
-/*
- * 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;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import junit.framework.Assert;
-
-public class TInspectorCluster {
-
- public static final String ANCESTOR_STRING = "ancestor";
-
- public static final String OFFSPRING_STRING = "offspring";
-
- public static final boolean ANCESTOR_BOOLEAN = Boolean.FALSE;
-
- public static final boolean OFFSPRING_BOOLEAN = Boolean.TRUE;
-
- public static final char ANCESTOR_CHARACTER = 'A';
-
- public static final char OFFSPRING_CHARACTER = 'O';
-
- public static final short ANCESTOR_SHORT = 2;
-
- public static final short OFFSPRING_SHORT = -2;
-
- public static final int ANCESTOR_INTEGER = Integer.MIN_VALUE;
-
- public static final int OFFSPRING_INTEGER = Integer.MAX_VALUE;
-
- public static final long ANCESTOR_LONG = 453298580984320l;
-
- public static final long OFFSPRING_LONG = -453298580984320l;
-
- public static final float ANCESTOR_FLOAT = 0.5f;
-
- public static final float OFFSPRING_FLOAT = -0.5f;
-
- public static final double ANCESTOR_DOUBLE = 0.12;
-
- public static final double OFFSPRING_DOUBLE = -0.12;
-
- public static final MockA ANCESTOR_OBJECT = new MockA();
-
- public static final MockB OFFSPRING_OBJECT = new MockB();
-
- public static final List<MockA> ANCESTOR_OBJECT_LIST = new ArrayList<MockA>();
-
- public static final List<MockB> OFFSPRING_OBJECT_LIST = new ArrayList<MockB>();
-
- private static String calledMethodName = null;
-
- private static Object calledMethodResult = null;
-
- private static Object[] calledmethodArguments = null;
-
- static {
- ANCESTOR_OBJECT_LIST.add(new MockA());
- OFFSPRING_OBJECT_LIST.add(new MockB());
- }
-
- public interface Ancestor {
- }
-
- public interface Offspring extends Ancestor {
- }
-
- public interface Visitor<T> {
-
- public T visit(Ancestor o);
-
- }
-
- /*
- * check whether the right method is called
- */
- public static void assertMethodCalled(String methodName,
- Object[] arguments, Object expectResult) {
- Assert.assertEquals(methodName, calledMethodName);
- Assert.assertTrue(Arrays.equals(arguments, calledmethodArguments));
- Assert.assertEquals(expectResult, calledMethodResult);
- reset();
- }
-
- private static void reset() {
- calledMethodName = null;
- calledMethodResult = null;
- calledmethodArguments = null;
- }
-
- public static class StringInspector implements Visitor<String> {
-
- public String visit(Ancestor o) {
- calledMethodName = "visit";
- calledmethodArguments = new Object[] { o };
- calledMethodResult = ANCESTOR_STRING;
- return null;
- }
-
- public String visit(Offspring o) {
- calledMethodName = "visit";
- calledmethodArguments = new Object[] { o };
- calledMethodResult = OFFSPRING_STRING;
- return null;
- }
-
- }
-
- public static class BooleanInspector implements Visitor<Boolean> {
-
- public Boolean visit(Ancestor o) {
- calledMethodName = "visit";
- calledmethodArguments = new Object[] { o };
- calledMethodResult = ANCESTOR_BOOLEAN;
- return null;
- }
-
- public Boolean visit(Offspring o) {
- calledMethodName = "visit";
- calledmethodArguments = new Object[] { o };
- calledMethodResult = OFFSPRING_BOOLEAN;
- return null;
- }
-
- }
-
- public static class CharacterInspector implements Visitor<Character> {
-
- public Character visit(Ancestor o) {
- calledMethodName = "visit";
- calledmethodArguments = new Object[] { o };
- calledMethodResult = ANCESTOR_CHARACTER;
- return null;
- }
-
- public Character visit(Offspring o) {
- calledMethodName = "visit";
- calledmethodArguments = new Object[] { o };
- calledMethodResult = OFFSPRING_CHARACTER;
- return null;
- }
-
- }
-
- public static class ShortInspector implements Visitor<Short> {
-
- public Short visit(Ancestor o) {
- calledMethodName = "visit";
- calledmethodArguments = new Object[] { o };
- calledMethodResult = ANCESTOR_SHORT;
- return null;
- }
-
- public Short visit(Offspring o) {
- calledMethodName = "visit";
- calledmethodArguments = new Object[] { o };
- calledMethodResult = OFFSPRING_SHORT;
- return null;
- }
-
- }
-
- public static class IntegerInspector implements Visitor<Integer> {
-
- public Integer visit(Ancestor o) {
- calledMethodName = "visit";
- calledmethodArguments = new Object[] { o };
- calledMethodResult = ANCESTOR_INTEGER;
- return null;
- }
-
- public Integer visit(Offspring o) {
- calledMethodName = "visit";
- calledmethodArguments = new Object[] { o };
- calledMethodResult = OFFSPRING_INTEGER;
- return null;
- }
-
- }
-
- public static class LongInspector implements Visitor<Long> {
-
- public Long visit(Ancestor o) {
- calledMethodName = "visit";
- calledmethodArguments = new Object[] { o };
- calledMethodResult = ANCESTOR_LONG;
- return null;
- }
-
- public Long visit(Offspring o) {
- calledMethodName = "visit";
- calledmethodArguments = new Object[] { o };
- calledMethodResult = OFFSPRING_LONG;
- return null;
- }
-
- }
-
- public static class FloatInspector implements Visitor<Float> {
-
- public Float visit(Ancestor o) {
- calledMethodName = "visit";
- calledmethodArguments = new Object[] { o };
- calledMethodResult = ANCESTOR_FLOAT;
- return null;
- }
-
- public Float visit(Offspring o) {
- calledMethodName = "visit";
- calledmethodArguments = new Object[] { o };
- calledMethodResult = OFFSPRING_FLOAT;
- return null;
- }
-
- }
-
- public static class DoubleInspector implements Visitor<Double> {
-
- public Double visit(Ancestor o) {
- calledMethodName = "visit";
- calledmethodArguments = new Object[] { o };
- calledMethodResult = ANCESTOR_DOUBLE;
- return null;
- }
-
- public Double visit(Offspring o) {
- calledMethodName = "visit";
- calledmethodArguments = new Object[] { o };
- calledMethodResult = OFFSPRING_DOUBLE;
- return null;
- }
-
- }
-
- public static class ObjectInspector implements Visitor<Object> {
-
- public Object visit(Ancestor o) {
- calledMethodName = "visit";
- calledmethodArguments = new Object[] { o };
- calledMethodResult = ANCESTOR_OBJECT;
- return null;
- }
-
- public Object visit(Offspring o) {
- calledMethodName = "visit";
- calledmethodArguments = new Object[] { o };
- calledMethodResult = OFFSPRING_OBJECT;
- return null;
- }
-
- }
-
- public static class ObjectListInspector implements Visitor<List> {
-
- public List visit(Ancestor o) {
- calledMethodName = "visit";
- calledmethodArguments = new Object[] { o };
- calledMethodResult = ANCESTOR_OBJECT_LIST;
- return null;
- }
-
- public List visit(Offspring o) {
- calledMethodName = "visit";
- calledmethodArguments = new Object[] { o };
- calledMethodResult = OFFSPRING_OBJECT_LIST;
- return null;
- }
- }
-
-}
-
-class MockA {
-
- public static final String NAME = "A";
-
-}
-
-class MockB {
-
- public static final String NAME = "B";
-
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/TestEventHandler.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/TestEventHandler.java
deleted file mode 100644
index 52bbc0d..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/TestEventHandler.java
+++ /dev/null
@@ -1,245 +0,0 @@
-/*
- * 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.
- */
-
-/*
- * Created on 27.06.2006
- * @author Alexei Y. Zakharov
- */
-package org.apache.harmony.beans.tests.support;
-
-import java.io.FileReader;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.Map;
-
-import org.xml.sax.Attributes;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.XMLReader;
-import org.xml.sax.helpers.DefaultHandler;
-import org.xml.sax.helpers.XMLReaderFactory;
-
-/**
- * This class is used by XMLEncoderTest for handling SAX parser events.
- *
- * @author Alexei Zakharov
- */
-public class TestEventHandler extends DefaultHandler {
-
- public Tag root = null;
-
- private Tag currentTag = null;
-
- @Override
- public void startDocument() {
- }
-
- @Override
- public void endDocument() {
- }
-
- @Override
- public void startElement(String uri, String name, String qName,
- Attributes atts) {
- Tag theTag = new Tag(name, currentTag);
-
- theTag.fillAttributes(atts);
- if (currentTag != null) {
- currentTag.innerTags.add(theTag);
- }
- if (root == null) {
- root = theTag;
- }
- currentTag = theTag;
- }
-
- @Override
- public void endElement(String uri, String name, String qName)
- throws SAXException {
- if (!name.equals(currentTag.name)) {
- throw new SAXException("unexpected closing tag: " + name);
- }
- currentTag = currentTag.parent;
- }
-
- @Override
- public void characters(char ch[], int start, int length) {
- currentTag.content.append(ch, start, length);
- }
-
- public static void main(String argv[]) throws Exception {
-
- XMLReader xmlReader;
- TestEventHandler handler = new TestEventHandler();
- FileReader reader;
- String saxParserClassName = System.getProperty("org.xml.sax.driver");
-
- if (saxParserClassName == null) {
- saxParserClassName = "org.apache.xerces.parsers.SAXParser";
- }
- xmlReader = XMLReaderFactory.createXMLReader(saxParserClassName);
- xmlReader.setContentHandler(handler);
- xmlReader.setErrorHandler(handler);
-
- if (argv.length < 1) {
- throw new Exception("input file should be specified");
- }
- reader = new FileReader(argv[0]);
- xmlReader.parse(new InputSource(reader));
- System.out.println(handler.root.toString());
- }
-
- static class Tag {
- String name;
-
- HashMap<String, String> attributes = new LinkedHashMap<String, String>();
-
- HashSet<Tag> innerTags = new LinkedHashSet<Tag>();
-
- Tag parent = null;
-
- StringBuffer content = new StringBuffer();
-
- boolean ignoreJavaVersion = true;
-
- public Tag(String name, Tag parent) {
- this.name = name;
- this.parent = parent;
- }
-
- public void fillAttributes(Attributes attrs) {
- for (int i = 0; i < attrs.getLength(); i++) {
- String name = attrs.getLocalName(i);
- String value = attrs.getValue(i);
-
- attributes.put(name, value);
- }
- }
-
- @Override
- public boolean equals(Object obj) {
- Iterator<Map.Entry<String, String>> it;
- Iterator<Tag> itTag;
- Tag tag;
-
- if (!(obj instanceof Tag)) {
- return false;
- }
- tag = (Tag) obj;
-
- // name
- if (!name.equals(tag.name)) {
- return false;
- }
-
- // attributes
- if (attributes.entrySet().size() != tag.attributes.entrySet()
- .size()) {
- return false;
- }
- it = attributes.entrySet().iterator();
-
- while (it.hasNext()) {
- Map.Entry<String, String> entry = it.next();
- Iterator<Map.Entry<String, String>> it2 = tag.attributes
- .entrySet().iterator();
- boolean found = false;
-
- while (it2.hasNext()) {
- Map.Entry<String, String> entry2 = it2.next();
-
- if (entry2.getKey().equals(entry.getKey())) {
- if (ignoreJavaVersion && tag.name.equals("java")
- && entry.getKey().equals("version")) {
- // ignore java version
- found = true;
- break;
- } else if (entry2.getValue().equals(entry.getValue())) {
- // values are the same
- found = true;
- break;
- }
- }
- }
- if (!found) {
- return false;
- }
- }
-
- // inner tags
- if (innerTags.size() != tag.innerTags.size()) {
- return false;
- }
- itTag = innerTags.iterator();
- while (itTag.hasNext()) {
- Tag innerTag = itTag.next();
- Iterator<Tag> itTag2 = tag.innerTags.iterator();
- boolean found = false;
-
- while (itTag2.hasNext()) {
- Tag innerTag2 = itTag2.next();
-
- if (innerTag.equals(innerTag2)) {
- found = true;
- break;
- }
- }
- if (!found) {
- return false;
- }
- }
- return true;
- }
-
- @Override
- public String toString() {
- StringBuffer sb = new StringBuffer();
- Iterator<Map.Entry<String, String>> it;
-
- sb.append('<' + name);
- it = attributes.entrySet().iterator();
- while (it.hasNext()) {
- Map.Entry<String, String> entry = it.next();
-
- sb.append(" " + entry.getKey() + "=\"" + entry.getValue()
- + "\"");
- }
- if (innerTags.isEmpty() && content.length() == 0) {
- sb.append("/>\n");
- } else if (innerTags.isEmpty() && content.length() > 0) {
- sb.append(">");
- sb.append(content);
- sb.append("</" + name + ">\n");
- } else {
- Iterator<Tag> it2 = innerTags.iterator();
-
- sb.append(">\n");
- while (it2.hasNext()) {
- Tag child = it2.next();
-
- sb.append(child.toString() + "\n");
- }
- sb.append("</" + name + ">\n");
- }
- return sb.toString();
- }
- }
-
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/MethodInvocationRecords.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/MethodInvocationRecords.java
deleted file mode 100644
index 15e19b2..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/MethodInvocationRecords.java
+++ /dev/null
@@ -1,225 +0,0 @@
-/*
- * 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.beancontext;
-
-import java.util.ArrayList;
-import java.util.List;
-import junit.framework.Assert;
-
-/**
- * Record method invocation input and output.
- */
-public class MethodInvocationRecords extends Assert {
-
- public static final Object IGNORE = "IGNORE";
-
- private final List<List<Object>> records = new ArrayList<List<Object>>();
-
- private int assertIndex = 0;
-
- public void clear() {
- records.clear();
- assertIndex = 0;
- }
-
- public void add(String methodName, Object returnValue) {
- List<Object> rec = new ArrayList<Object>();
- rec.add(methodName);
- rec.add(returnValue);
- records.add(rec);
- }
-
- public void add(String methodName, Object arg1, Object returnValue) {
- List<Object> rec = new ArrayList<Object>();
- rec.add(methodName);
- rec.add(arg1);
- rec.add(returnValue);
- records.add(rec);
- }
-
- public void add(String methodName, Object arg1, Object arg2,
- Object returnValue) {
- List<Object> rec = new ArrayList<Object>();
- rec.add(methodName);
- rec.add(arg1);
- rec.add(arg2);
- rec.add(returnValue);
- records.add(rec);
- }
-
- public void add(String methodName, Object arg1, Object arg2, Object arg3,
- Object returnValue) {
- List<Object> rec = new ArrayList<Object>();
- rec.add(methodName);
- rec.add(arg1);
- rec.add(arg2);
- rec.add(arg3);
- rec.add(returnValue);
- records.add(rec);
- }
-
- public void add(String methodName, Object arg1, Object arg2, Object arg3,
- Object arg4, Object returnValue) {
- List<Object> rec = new ArrayList<Object>();
- rec.add(methodName);
- rec.add(arg1);
- rec.add(arg2);
- rec.add(arg3);
- rec.add(arg4);
- rec.add(returnValue);
- records.add(rec);
- }
-
- public void assertRecord(String methodName, Object returnValue) {
- List<Object> rec = records.get(assertIndex++);
- int count = 0;
- assertEquals(methodName, rec.get(count++));
- if (returnValue != IGNORE) {
- assertEquals(returnValue, rec.get(count++));
- } else {
- count++;
- }
- assertEquals(count, rec.size());
- }
-
- public void assertRecord(String methodName, Object arg1, Object returnValue) {
- List<Object> rec = records.get(assertIndex++);
- int count = 0;
- assertEquals(methodName, rec.get(count++));
- if (arg1 != IGNORE) {
- assertEquals(arg1, rec.get(count++));
- } else {
- count++;
- }
- if (returnValue != IGNORE) {
- assertEquals(returnValue, rec.get(count++));
- } else {
- count++;
- }
- assertEquals(count, rec.size());
- }
-
- public void assertRecord(String methodName, Object arg1, Object arg2,
- Object returnValue) {
- List<Object> rec = records.get(assertIndex++);
- int count = 0;
- assertEquals(methodName, rec.get(count++));
- if (arg1 != IGNORE) {
- assertEquals(arg1, rec.get(count++));
- } else {
- count++;
- }
- if (arg2 != IGNORE) {
- assertEquals(arg2, rec.get(count++));
- } else {
- count++;
- }
- if (returnValue != IGNORE) {
- assertEquals(returnValue, rec.get(count++));
- } else {
- count++;
- }
- assertEquals(count, rec.size());
- }
-
- public void assertRecord(String methodName, Object arg1, Object arg2,
- Object arg3, Object returnValue) {
- List<Object> rec = records.get(assertIndex++);
- int count = 0;
- assertEquals(methodName, rec.get(count++));
- if (arg1 != IGNORE) {
- assertEquals(arg1, rec.get(count++));
- } else {
- count++;
- }
- if (arg2 != IGNORE) {
- assertEquals(arg2, rec.get(count++));
- } else {
- count++;
- }
- if (arg3 != IGNORE) {
- assertEquals(arg3, rec.get(count++));
- } else {
- count++;
- }
- if (returnValue != IGNORE) {
- assertEquals(returnValue, rec.get(count++));
- } else {
- count++;
- }
- assertEquals(count, rec.size());
- }
-
- public void assertRecord(String methodName, Object arg1, Object arg2,
- Object arg3, Object arg4, Object returnValue) {
- List<Object> rec = records.get(assertIndex++);
- int count = 0;
- assertEquals(methodName, rec.get(count++));
- if (arg1 != IGNORE) {
- assertEquals(arg1, rec.get(count++));
- } else {
- count++;
- }
- if (arg2 != IGNORE) {
- assertEquals(arg2, rec.get(count++));
- } else {
- count++;
- }
- if (arg3 != IGNORE) {
- assertEquals(arg3, rec.get(count++));
- } else {
- count++;
- }
- if (arg4 != IGNORE) {
- assertEquals(arg4, rec.get(count++));
- } else {
- count++;
- }
- if (returnValue != IGNORE) {
- assertEquals(returnValue, rec.get(count++));
- } else {
- count++;
- }
- assertEquals(count, rec.size());
- }
-
- public void assertEndOfRecords() {
- assertEquals(assertIndex, records.size());
- }
-
- public String getMethodName() {
- List<Object> rec = records.get(assertIndex);
- return (String) rec.get(0);
- }
-
- public Object getArg(int i) {
- List<Object> rec = records.get(assertIndex);
- return rec.get(i + 1);
- }
-
- public Object getReturnValue(int i) {
- List<Object> rec = records.get(assertIndex);
- return rec.get(rec.size() - 1);
- }
-
- @Override
- public String toString() {
- return records.toString();
- }
-
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/Utils.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/Utils.java
deleted file mode 100644
index e79668b..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/Utils.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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.beancontext;
-
-import java.lang.reflect.Field;
-
-/**
- * Util class
- */
-public class Utils {
-
- public static Object getField(Object obj, String fieldName) {
- try {
- Field fld = obj.getClass().getDeclaredField(fieldName);
- fld.setAccessible(true);
- return fld.get(obj);
- } catch (Exception e) {
- e.printStackTrace();
- throw new RuntimeException("failed to get field by force");
- }
- }
-
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockBeanContext.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockBeanContext.java
deleted file mode 100644
index 9c3a5c7..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockBeanContext.java
+++ /dev/null
@@ -1,353 +0,0 @@
-/*
- * 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.beancontext.mock;
-
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyVetoException;
-import java.beans.VetoableChangeListener;
-import java.beans.beancontext.BeanContext;
-import java.beans.beancontext.BeanContextChild;
-import java.beans.beancontext.BeanContextMembershipListener;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.Collection;
-import java.util.Iterator;
-
-/**
- * Mock of BeanContext
- */
-@SuppressWarnings("unchecked")
-public class MockBeanContext implements BeanContext {
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.beancontext.BeanContext#instantiateChild(java.lang.String)
- */
- public Object instantiateChild(String beanName) throws IOException,
- ClassNotFoundException {
- // Auto-generated method stub
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.beancontext.BeanContext#getResourceAsStream(java.lang.String,
- * java.beans.beancontext.BeanContextChild)
- */
- public InputStream getResourceAsStream(String name, BeanContextChild bcc)
- throws IllegalArgumentException {
- // Auto-generated method stub
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.beancontext.BeanContext#getResource(java.lang.String,
- * java.beans.beancontext.BeanContextChild)
- */
- public URL getResource(String name, BeanContextChild bcc)
- throws IllegalArgumentException {
- // Auto-generated method stub
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.beancontext.BeanContext#addBeanContextMembershipListener(java.beans.beancontext.BeanContextMembershipListener)
- */
- public void addBeanContextMembershipListener(
- BeanContextMembershipListener bcml) {
- // Auto-generated method stub
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.beancontext.BeanContext#removeBeanContextMembershipListener(java.beans.beancontext.BeanContextMembershipListener)
- */
- public void removeBeanContextMembershipListener(
- BeanContextMembershipListener bcml) {
- // Auto-generated method stub
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.beancontext.BeanContextChild#setBeanContext(java.beans.beancontext.BeanContext)
- */
- public void setBeanContext(BeanContext bc) throws PropertyVetoException {
- // Auto-generated method stub
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.beancontext.BeanContextChild#getBeanContext()
- */
- public BeanContext getBeanContext() {
- // Auto-generated method stub
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.beancontext.BeanContextChild#addPropertyChangeListener(java.lang.String,
- * java.beans.PropertyChangeListener)
- */
- public void addPropertyChangeListener(String name,
- PropertyChangeListener pcl) {
- // Auto-generated method stub
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.beancontext.BeanContextChild#removePropertyChangeListener(java.lang.String,
- * java.beans.PropertyChangeListener)
- */
- public void removePropertyChangeListener(String name,
- PropertyChangeListener pcl) {
- // Auto-generated method stub
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.beancontext.BeanContextChild#addVetoableChangeListener(java.lang.String,
- * java.beans.VetoableChangeListener)
- */
- public void addVetoableChangeListener(String name,
- VetoableChangeListener vcl) {
- // Auto-generated method stub
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.beancontext.BeanContextChild#removeVetoableChangeListener(java.lang.String,
- * java.beans.VetoableChangeListener)
- */
- public void removeVetoableChangeListener(String name,
- VetoableChangeListener vcl) {
- // Auto-generated method stub
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.util.Collection#size()
- */
- public int size() {
- // Auto-generated method stub
- return 0;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.util.Collection#isEmpty()
- */
- public boolean isEmpty() {
- // Auto-generated method stub
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.util.Collection#contains(java.lang.Object)
- */
- public boolean contains(Object o) {
- // Auto-generated method stub
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.util.Collection#iterator()
- */
- public Iterator iterator() {
- // Auto-generated method stub
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.util.Collection#toArray()
- */
- public Object[] toArray() {
- // Auto-generated method stub
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.util.Collection#toArray(java.lang.Object[])
- */
- public Object[] toArray(Object[] a) {
- // Auto-generated method stub
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.util.Collection#add(java.lang.Object)
- */
- public boolean add(Object o) {
- // Auto-generated method stub
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.util.Collection#remove(java.lang.Object)
- */
- public boolean remove(Object o) {
- // Auto-generated method stub
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.util.Collection#containsAll(java.util.Collection)
- */
- public boolean containsAll(Collection c) {
- // Auto-generated method stub
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.util.Collection#addAll(java.util.Collection)
- */
- public boolean addAll(Collection c) {
- // Auto-generated method stub
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.util.Collection#removeAll(java.util.Collection)
- */
- public boolean removeAll(Collection c) {
- // Auto-generated method stub
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.util.Collection#retainAll(java.util.Collection)
- */
- public boolean retainAll(Collection c) {
- // Auto-generated method stub
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.util.Collection#clear()
- */
- public void clear() {
- // Auto-generated method stub
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.DesignMode#setDesignTime(boolean)
- */
- public void setDesignTime(boolean designTime) {
- // Auto-generated method stub
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.DesignMode#isDesignTime()
- */
- public boolean isDesignTime() {
- // Auto-generated method stub
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.Visibility#needsGui()
- */
- public boolean needsGui() {
- // Auto-generated method stub
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.Visibility#dontUseGui()
- */
- public void dontUseGui() {
- // Auto-generated method stub
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.Visibility#okToUseGui()
- */
- public void okToUseGui() {
- // Auto-generated method stub
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.Visibility#avoidingGui()
- */
- public boolean avoidingGui() {
- // Auto-generated method stub
- return false;
- }
-
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockBeanContextChild.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockBeanContextChild.java
deleted file mode 100644
index bcdfb9c..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockBeanContextChild.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * 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.beancontext.mock;
-
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyVetoException;
-import java.beans.VetoableChangeListener;
-import java.beans.beancontext.BeanContext;
-
-/**
- * Mock of BeanContextChild
- */
-public class MockBeanContextChild implements
- java.beans.beancontext.BeanContextChild {
-
- private BeanContext ctx;
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.beancontext.BeanContextChild#setBeanContext(java.beans.beancontext.BeanContext)
- */
- public void setBeanContext(BeanContext bc) throws PropertyVetoException {
- ctx = bc;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.beancontext.BeanContextChild#getBeanContext()
- */
- public BeanContext getBeanContext() {
- return ctx;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.beancontext.BeanContextChild#addPropertyChangeListener(java.lang.String,
- * java.beans.PropertyChangeListener)
- */
- public void addPropertyChangeListener(String name,
- PropertyChangeListener pcl) {
- // Auto-generated method stub
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.beancontext.BeanContextChild#removePropertyChangeListener(java.lang.String,
- * java.beans.PropertyChangeListener)
- */
- public void removePropertyChangeListener(String name,
- PropertyChangeListener pcl) {
- // Auto-generated method stub
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.beancontext.BeanContextChild#addVetoableChangeListener(java.lang.String,
- * java.beans.VetoableChangeListener)
- */
- public void addVetoableChangeListener(String name,
- VetoableChangeListener vcl) {
- // Auto-generated method stub
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.beancontext.BeanContextChild#removeVetoableChangeListener(java.lang.String,
- * java.beans.VetoableChangeListener)
- */
- public void removeVetoableChangeListener(String name,
- VetoableChangeListener vcl) {
- // Auto-generated method stub
-
- }
-
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockBeanContextChildComponentProxy.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockBeanContextChildComponentProxy.java
deleted file mode 100644
index 192b813..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockBeanContextChildComponentProxy.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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.beancontext.mock;
-
-import java.awt.Component;
-
-/**
- * Mock of BeanContextChildComponentProxy
- */
-public class MockBeanContextChildComponentProxy implements
- java.beans.beancontext.BeanContextChildComponentProxy {
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.beancontext.BeanContextChildComponentProxy#getComponent()
- */
- public Component getComponent() {
- // Auto-generated method stub
- return null;
- }
-
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockBeanContextChildDelegateS.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockBeanContextChildDelegateS.java
deleted file mode 100644
index 851ded9..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockBeanContextChildDelegateS.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * 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.beancontext.mock;
-
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyVetoException;
-import java.beans.VetoableChangeListener;
-import java.beans.beancontext.BeanContext;
-import java.beans.beancontext.BeanContextChild;
-import java.beans.beancontext.BeanContextChildSupport;
-import java.io.Serializable;
-
-/**
- * Delegate to BeanContextChildSupport
- */
-public class MockBeanContextChildDelegateS implements BeanContextChild, Serializable {
-
- private static final long serialVersionUID = -8741207393863151473L;
-
- public String id;
-
- public BeanContextChildSupport support = new BeanContextChildSupport(this);
-
- public MockBeanContextChildDelegateS(String id) {
- this.id = id;
- }
-
- public void addPropertyChangeListener(String name, PropertyChangeListener pcl) {
- support.addPropertyChangeListener(name, pcl);
- }
-
- public void addVetoableChangeListener(String name, VetoableChangeListener vcl) {
- support.addVetoableChangeListener(name, vcl);
- }
-
- public BeanContext getBeanContext() {
- return support.getBeanContext();
- }
-
- public void removePropertyChangeListener(String name, PropertyChangeListener pcl) {
- support.removePropertyChangeListener(name, pcl);
- }
-
- public void removeVetoableChangeListener(String name, VetoableChangeListener vcl) {
- support.removeVetoableChangeListener(name, vcl);
- }
-
- public void setBeanContext(BeanContext bc) throws PropertyVetoException {
- support.setBeanContext(bc);
- }
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockBeanContextChildS.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockBeanContextChildS.java
deleted file mode 100644
index 37d1d57..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockBeanContextChildS.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * 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.beancontext.mock;
-
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyVetoException;
-import java.beans.VetoableChangeListener;
-import java.beans.beancontext.BeanContext;
-import java.beans.beancontext.BeanContextChild;
-import java.io.Serializable;
-
-/**
- * Mock of BeanContextChild
- */
-public class MockBeanContextChildS implements BeanContextChild, Serializable {
-
- private static final long serialVersionUID = 8671685325002756158L;
-
- public String id;
-
- private BeanContext ctx;
-
- public MockBeanContextChildS(String id) {
- this.id = id;
- }
-
- @Override
- public boolean equals(Object o) {
- if (o instanceof MockBeanContextChildS) {
- return id.equals(((MockBeanContextChildS) o).id);
- }
- return false;
- }
-
- @Override
- public int hashCode() {
- return id.hashCode();
- }
-
- public void setBeanContext(BeanContext bc) throws PropertyVetoException {
- ctx = bc;
- }
-
- public BeanContext getBeanContext() {
- return ctx;
- }
-
- public void addPropertyChangeListener(String name, PropertyChangeListener pcl) {
-
- }
-
- public void removePropertyChangeListener(String name, PropertyChangeListener pcl) {
-
- }
-
- public void addVetoableChangeListener(String name, VetoableChangeListener vcl) {
-
- }
-
- public void removeVetoableChangeListener(String name, VetoableChangeListener vcl) {
- }
-
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockBeanContextContainerProxy.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockBeanContextContainerProxy.java
deleted file mode 100644
index edb0f8d..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockBeanContextContainerProxy.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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.beancontext.mock;
-
-import java.awt.Container;
-import java.beans.beancontext.BeanContextContainerProxy;
-
-/**
- * Mock of BeanContextContainerProxy
- */
-public class MockBeanContextContainerProxy implements BeanContextContainerProxy {
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.beancontext.BeanContextContainerProxy#getContainer()
- */
- public Container getContainer() {
- // Auto-generated method stub
- return null;
- }
-
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockBeanContextDelegateS.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockBeanContextDelegateS.java
deleted file mode 100644
index bee36f1..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockBeanContextDelegateS.java
+++ /dev/null
@@ -1,252 +0,0 @@
-/*
- * 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.beancontext.mock;
-
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyVetoException;
-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.BeanContextServiceRevokedEvent;
-import java.beans.beancontext.BeanContextSupport;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.Serializable;
-import java.net.URL;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Locale;
-
-/**
- * Mock of BeanContext
- */
-@SuppressWarnings("unchecked")
-public class MockBeanContextDelegateS implements BeanContext, Serializable {
-
- private static final long serialVersionUID = 3636087892485726792L;
-
- public BeanContextSupport support = new BeanContextSupport(this, Locale.US);
-
- public String id;
-
- public MockBeanContextDelegateS(String id) {
- this.id = id;
- }
-
- public boolean add(Object arg0) {
- return support.add(arg0);
- }
-
- public boolean addAll(Collection arg0) {
- return support.addAll(arg0);
- }
-
- public void addBeanContextMembershipListener(BeanContextMembershipListener arg0) {
- support.addBeanContextMembershipListener(arg0);
- }
-
- public void addPropertyChangeListener(String arg0, PropertyChangeListener arg1) {
- support.addPropertyChangeListener(arg0, arg1);
- }
-
- public void addVetoableChangeListener(String arg0, VetoableChangeListener arg1) {
- support.addVetoableChangeListener(arg0, arg1);
- }
-
- public boolean avoidingGui() {
- return support.avoidingGui();
- }
-
- public void clear() {
- support.clear();
- }
-
- public boolean contains(Object arg0) {
- return support.contains(arg0);
- }
-
- public boolean containsAll(Collection arg0) {
- return support.containsAll(arg0);
- }
-
- public boolean containsKey(Object arg0) {
- return support.containsKey(arg0);
- }
-
- public void dontUseGui() {
- support.dontUseGui();
- }
-
- public void firePropertyChange(String arg0, Object arg1, Object arg2) {
- support.firePropertyChange(arg0, arg1, arg2);
- }
-
- public void fireVetoableChange(String arg0, Object arg1, Object arg2)
- throws PropertyVetoException {
- support.fireVetoableChange(arg0, arg1, arg2);
- }
-
- public BeanContext getBeanContext() {
- return support.getBeanContext();
- }
-
- public BeanContextChild getBeanContextChildPeer() {
- return support.getBeanContextChildPeer();
- }
-
- public BeanContext getBeanContextPeer() {
- return support.getBeanContextPeer();
- }
-
- public Locale getLocale() {
- return support.getLocale();
- }
-
- public URL getResource(String arg0, BeanContextChild arg1) throws IllegalArgumentException {
- return support.getResource(arg0, arg1);
- }
-
- public InputStream getResourceAsStream(String arg0, BeanContextChild arg1)
- throws IllegalArgumentException {
- return support.getResourceAsStream(arg0, arg1);
- }
-
- public Object instantiateChild(String arg0) throws IOException, ClassNotFoundException {
- return support.instantiateChild(arg0);
- }
-
- public boolean isDelegated() {
- return support.isDelegated();
- }
-
- public boolean isDesignTime() {
- return support.isDesignTime();
- }
-
- public boolean isEmpty() {
- return support.isEmpty();
- }
-
- public boolean isSerializing() {
- return support.isSerializing();
- }
-
- public Iterator iterator() {
- return support.iterator();
- }
-
- public boolean needsGui() {
- return support.needsGui();
- }
-
- public void okToUseGui() {
- support.okToUseGui();
- }
-
- public void propertyChange(PropertyChangeEvent arg0) {
- support.propertyChange(arg0);
- }
-
- public void readChildren(ObjectInputStream arg0) throws IOException, ClassNotFoundException {
- support.readChildren(arg0);
- }
-
- public boolean remove(Object arg0) {
- return support.remove(arg0);
- }
-
- public boolean removeAll(Collection arg0) {
- return support.removeAll(arg0);
- }
-
- public void removeBeanContextMembershipListener(BeanContextMembershipListener arg0) {
- support.removeBeanContextMembershipListener(arg0);
- }
-
- public void removePropertyChangeListener(String arg0, PropertyChangeListener arg1) {
- support.removePropertyChangeListener(arg0, arg1);
- }
-
- public void removeVetoableChangeListener(String arg0, VetoableChangeListener arg1) {
- support.removeVetoableChangeListener(arg0, arg1);
- }
-
- public boolean retainAll(Collection arg0) {
- return support.retainAll(arg0);
- }
-
- public void serviceAvailable(BeanContextServiceAvailableEvent arg0) {
- support.serviceAvailable(arg0);
- }
-
- public void serviceRevoked(BeanContextServiceRevokedEvent arg0) {
- support.serviceRevoked(arg0);
- }
-
- public void setBeanContext(BeanContext arg0) throws PropertyVetoException {
- support.setBeanContext(arg0);
- }
-
- public void setDesignTime(boolean arg0) {
- support.setDesignTime(arg0);
- }
-
- public void setLocale(Locale arg0) throws PropertyVetoException {
- support.setLocale(arg0);
- }
-
- public int size() {
- return support.size();
- }
-
- public Object[] toArray() {
- return support.toArray();
- }
-
- public Object[] toArray(Object[] arg0) {
- return support.toArray(arg0);
- }
-
- public boolean validatePendingSetBeanContext(BeanContext arg0) {
- return support.validatePendingSetBeanContext(arg0);
- }
-
- public void vetoableChange(PropertyChangeEvent arg0) throws PropertyVetoException {
- support.vetoableChange(arg0);
- }
-
- public void writeChildren(ObjectOutputStream arg0) throws IOException {
- support.writeChildren(arg0);
- }
-
- private void writeObject(ObjectOutputStream oos) throws IOException {
- oos.defaultWriteObject();
- support.writeChildren(oos);
- }
-
- private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
- ois.defaultReadObject();
- support.readChildren(ois);
- }
-
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockBeanContextMembershipListener.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockBeanContextMembershipListener.java
deleted file mode 100644
index db0e18f..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockBeanContextMembershipListener.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * 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.beancontext.mock;
-
-import java.beans.beancontext.BeanContextMembershipEvent;
-import java.beans.beancontext.BeanContextMembershipListener;
-
-/**
- * Mock of BeanContextMembershipListener
- */
-public class MockBeanContextMembershipListener implements
- BeanContextMembershipListener {
-
- public boolean lastEventAdd = false;
-
- public boolean lastEventRemove = false;
-
- public BeanContextMembershipEvent lastEvent;
-
- public void clearLastEvent() {
- lastEventAdd = false;
- lastEventRemove = false;
- lastEvent = null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.beancontext.BeanContextMembershipListener#childrenAdded(java.beans.beancontext.BeanContextMembershipEvent)
- */
- public void childrenAdded(BeanContextMembershipEvent bcme) {
- lastEventAdd = true;
- lastEvent = bcme;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.beancontext.BeanContextMembershipListener#childrenRemoved(java.beans.beancontext.BeanContextMembershipEvent)
- */
- public void childrenRemoved(BeanContextMembershipEvent bcme) {
- lastEventRemove = true;
- lastEvent = bcme;
- }
-
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockBeanContextMembershipListenerS.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockBeanContextMembershipListenerS.java
deleted file mode 100644
index a94dfa2..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockBeanContextMembershipListenerS.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * 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.beancontext.mock;
-
-import java.beans.beancontext.BeanContextMembershipEvent;
-import java.beans.beancontext.BeanContextMembershipListener;
-import java.io.Serializable;
-
-/**
- * Mock of BeanContextMembershipListener
- */
-public class MockBeanContextMembershipListenerS implements BeanContextMembershipListener,
- Serializable {
-
- private static final long serialVersionUID = -7929429772961643840L;
-
- public String id;
-
- public boolean lastEventAdd = false;
-
- public boolean lastEventRemove = false;
-
- public BeanContextMembershipEvent lastEvent;
-
- public MockBeanContextMembershipListenerS(String id) {
- this.id = id;
- }
-
- public void clearLastEvent() {
- lastEventAdd = false;
- lastEventRemove = false;
- lastEvent = null;
- }
-
- public void childrenAdded(BeanContextMembershipEvent bcme) {
- lastEventAdd = true;
- lastEvent = bcme;
- }
-
- public void childrenRemoved(BeanContextMembershipEvent bcme) {
- lastEventRemove = true;
- lastEvent = bcme;
- }
-
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockBeanContextProxy.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockBeanContextProxy.java
deleted file mode 100644
index a326ae8..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockBeanContextProxy.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * 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.beancontext.mock;
-
-import java.beans.beancontext.BeanContextChild;
-import java.beans.beancontext.BeanContextProxy;
-
-/**
- * Mock of BeanContextProxy
- */
-public class MockBeanContextProxy implements BeanContextProxy {
-
- private BeanContextChild bcc;
-
- public MockBeanContextProxy() {
- this(null);
- }
-
- public MockBeanContextProxy(BeanContextChild bcc) {
- this.bcc = bcc;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.beancontext.BeanContextProxy#getBeanContextProxy()
- */
- public BeanContextChild getBeanContextProxy() {
- return bcc;
- }
-
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockBeanContextProxyS.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockBeanContextProxyS.java
deleted file mode 100644
index 648be06..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockBeanContextProxyS.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * 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.beancontext.mock;
-
-import java.beans.beancontext.BeanContextChild;
-import java.beans.beancontext.BeanContextProxy;
-import java.io.Serializable;
-
-/**
- * Mock of BeanContextProxy
- */
-public class MockBeanContextProxyS implements BeanContextProxy, Serializable {
-
- private static final long serialVersionUID = 1003496111741970301L;
-
- private String id;
-
- private BeanContextChild bcc;
-
- public MockBeanContextProxyS(String id, BeanContextChild bcc) {
- this.id = id;
- this.bcc = bcc;
- }
-
- @Override
- public boolean equals(Object o) {
- if (o instanceof MockBeanContextProxyS) {
- MockBeanContextProxyS other = (MockBeanContextProxyS) o;
- return id.equals(other.id) && bcc.equals(other.bcc);
- }
- return false;
- }
-
- @Override
- public int hashCode() {
- return id.hashCode() + bcc.hashCode();
- }
-
- public BeanContextChild getBeanContextProxy() {
- return bcc;
- }
-
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockBeanContextServiceProvider.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockBeanContextServiceProvider.java
deleted file mode 100644
index 5304966..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockBeanContextServiceProvider.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * 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.beancontext.mock;
-
-import java.beans.beancontext.BeanContextServiceProvider;
-import java.beans.beancontext.BeanContextServices;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.harmony.beans.tests.support.beancontext.MethodInvocationRecords;
-
-/**
- * Mock of BeanContextServiceProvider
- */
-@SuppressWarnings("unchecked")
-public class MockBeanContextServiceProvider implements
- BeanContextServiceProvider {
-
- public MethodInvocationRecords records = new MethodInvocationRecords();
-
- public List<Object> selectors = Arrays.asList(new Object[] { Integer.class });
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.beancontext.BeanContextServiceProvider#getService(java.beans.beancontext.BeanContextServices,
- * java.lang.Object, java.lang.Class, java.lang.Object)
- */
- public Object getService(BeanContextServices bcs, Object requestor,
- Class serviceClass, Object serviceSelector) {
- Object result = Collections.EMPTY_SET;
- records.add("getService", bcs, requestor, serviceClass,
- serviceSelector, result);
- return result;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.beancontext.BeanContextServiceProvider#releaseService(java.beans.beancontext.BeanContextServices,
- * java.lang.Object, java.lang.Object)
- */
- public void releaseService(BeanContextServices bcs, Object requestor,
- Object service) {
- records.add("releaseService", bcs, requestor, service, null);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.beancontext.BeanContextServiceProvider#getCurrentServiceSelectors(java.beans.beancontext.BeanContextServices,
- * java.lang.Class)
- */
- public Iterator<Object> getCurrentServiceSelectors(BeanContextServices bcs,
- Class serviceClass) {
- Iterator<Object> result = selectors.iterator();
- records.add("getCurrentServiceSelectors", bcs, serviceClass, result);
- return result;
- }
-
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockBeanContextServiceProviderBeanInfo.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockBeanContextServiceProviderBeanInfo.java
deleted file mode 100644
index 465e47b..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockBeanContextServiceProviderBeanInfo.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * 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.beancontext.mock;
-
-import java.awt.Image;
-import java.beans.BeanDescriptor;
-import java.beans.BeanInfo;
-import java.beans.EventSetDescriptor;
-import java.beans.MethodDescriptor;
-import java.beans.PropertyDescriptor;
-import java.beans.beancontext.BeanContextServiceProviderBeanInfo;
-
-/**
- * Mock of BeanContextServiceProviderBeanInfo
- */
-public class MockBeanContextServiceProviderBeanInfo implements
- BeanContextServiceProviderBeanInfo {
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.beancontext.BeanContextServiceProviderBeanInfo#getServicesBeanInfo()
- */
- public BeanInfo[] getServicesBeanInfo() {
- // Auto-generated method stub
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.BeanInfo#getBeanDescriptor()
- */
- public BeanDescriptor getBeanDescriptor() {
- // Auto-generated method stub
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.BeanInfo#getEventSetDescriptors()
- */
- public EventSetDescriptor[] getEventSetDescriptors() {
- // Auto-generated method stub
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.BeanInfo#getDefaultEventIndex()
- */
- public int getDefaultEventIndex() {
- // Auto-generated method stub
- return 0;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.BeanInfo#getPropertyDescriptors()
- */
- public PropertyDescriptor[] getPropertyDescriptors() {
- // Auto-generated method stub
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.BeanInfo#getDefaultPropertyIndex()
- */
- public int getDefaultPropertyIndex() {
- // Auto-generated method stub
- return 0;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.BeanInfo#getMethodDescriptors()
- */
- public MethodDescriptor[] getMethodDescriptors() {
- // Auto-generated method stub
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.BeanInfo#getAdditionalBeanInfo()
- */
- public BeanInfo[] getAdditionalBeanInfo() {
- // Auto-generated method stub
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.BeanInfo#getIcon(int)
- */
- public Image getIcon(int iconKind) {
- // Auto-generated method stub
- return null;
- }
-
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockBeanContextServiceProviderS.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockBeanContextServiceProviderS.java
deleted file mode 100644
index 12e0e51..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockBeanContextServiceProviderS.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * 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.beancontext.mock;
-
-import java.beans.beancontext.BeanContextServiceProvider;
-import java.beans.beancontext.BeanContextServices;
-import java.io.Serializable;
-import java.util.Iterator;
-
-/**
- * Mock of BeanContextServiceProvider
- */
-@SuppressWarnings("unchecked")
-public class MockBeanContextServiceProviderS implements BeanContextServiceProvider,
- Serializable {
-
- private static final long serialVersionUID = -4704593364692129549L;
-
- public String id;
-
- public MockBeanContextServiceProviderS(String id) {
- this.id = id;
- }
-
- public Object getService(BeanContextServices bcs, Object requestor, Class serviceClass,
- Object serviceSelector) {
- return null;
- }
-
- public void releaseService(BeanContextServices bcs, Object requestor, Object service) {
- // nothing
- }
-
- public Iterator<Object> getCurrentServiceSelectors(BeanContextServices bcs,
- Class serviceClass) {
- return null;
- }
-
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockBeanContextServiceRevokedListener.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockBeanContextServiceRevokedListener.java
deleted file mode 100644
index 0470dee..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockBeanContextServiceRevokedListener.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * 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.beancontext.mock;
-
-import java.beans.beancontext.BeanContextServiceRevokedEvent;
-import java.beans.beancontext.BeanContextServiceRevokedListener;
-
-/**
- * Mock of BeanContextServiceRevokedListener
- */
-public class MockBeanContextServiceRevokedListener implements
- BeanContextServiceRevokedListener {
-
- public BeanContextServiceRevokedEvent lastEvent;
-
- public void clearLastEvent() {
- lastEvent = null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.beancontext.BeanContextServiceRevokedListener#serviceRevoked(java.beans.beancontext.BeanContextServiceRevokedEvent)
- */
- public void serviceRevoked(BeanContextServiceRevokedEvent bcsre) {
- lastEvent = bcsre;
- }
-
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockBeanContextServices.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockBeanContextServices.java
deleted file mode 100644
index ed9a25d..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockBeanContextServices.java
+++ /dev/null
@@ -1,488 +0,0 @@
-/*
- * 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.beancontext.mock;
-
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyVetoException;
-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.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.TooManyListenersException;
-
-/**
- * Mock of BeanContextServices
- */
-@SuppressWarnings("unchecked")
-public class MockBeanContextServices implements BeanContextServices {
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.beancontext.BeanContextServices#addService(java.lang.Class,
- * java.beans.beancontext.BeanContextServiceProvider)
- */
- public boolean addService(Class serviceClass,
- BeanContextServiceProvider serviceProvider) {
- // Auto-generated method stub
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.beancontext.BeanContextServices#revokeService(java.lang.Class,
- * java.beans.beancontext.BeanContextServiceProvider, boolean)
- */
- public void revokeService(Class serviceClass,
- BeanContextServiceProvider serviceProvider,
- boolean revokeCurrentServicesNow) {
- // Auto-generated method stub
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.beancontext.BeanContextServices#hasService(java.lang.Class)
- */
- public boolean hasService(Class serviceClass) {
- // Auto-generated method stub
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.beancontext.BeanContextServices#getService(java.beans.beancontext.BeanContextChild,
- * java.lang.Object, java.lang.Class, java.lang.Object,
- * java.beans.beancontext.BeanContextServiceRevokedListener)
- */
- public Object getService(BeanContextChild child, Object requestor,
- Class serviceClass, Object serviceSelector,
- BeanContextServiceRevokedListener bcsrl)
- throws TooManyListenersException {
- // Auto-generated method stub
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.beancontext.BeanContextServices#releaseService(java.beans.beancontext.BeanContextChild,
- * java.lang.Object, java.lang.Object)
- */
- public void releaseService(BeanContextChild child, Object requestor,
- Object service) {
- // Auto-generated method stub
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.beancontext.BeanContextServices#getCurrentServiceClasses()
- */
- public Iterator getCurrentServiceClasses() {
- // Auto-generated method stub
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.beancontext.BeanContextServices#getCurrentServiceSelectors(java.lang.Class)
- */
- public Iterator getCurrentServiceSelectors(Class serviceClass) {
- // Auto-generated method stub
- ArrayList list = new ArrayList();
- list.add("1");
- list.add("2");
- list.add("3");
- return list.iterator();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.beancontext.BeanContextServices#addBeanContextServicesListener(java.beans.beancontext.BeanContextServicesListener)
- */
- public void addBeanContextServicesListener(BeanContextServicesListener bcsl) {
- // Auto-generated method stub
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.beancontext.BeanContextServices#removeBeanContextServicesListener(java.beans.beancontext.BeanContextServicesListener)
- */
- public void removeBeanContextServicesListener(
- BeanContextServicesListener bcsl) {
- // Auto-generated method stub
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.beancontext.BeanContext#instantiateChild(java.lang.String)
- */
- public Object instantiateChild(String beanName) throws IOException,
- ClassNotFoundException {
- // Auto-generated method stub
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.beancontext.BeanContext#getResourceAsStream(java.lang.String,
- * java.beans.beancontext.BeanContextChild)
- */
- public InputStream getResourceAsStream(String name, BeanContextChild bcc)
- throws IllegalArgumentException {
- // Auto-generated method stub
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.beancontext.BeanContext#getResource(java.lang.String,
- * java.beans.beancontext.BeanContextChild)
- */
- public URL getResource(String name, BeanContextChild bcc)
- throws IllegalArgumentException {
- // Auto-generated method stub
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.beancontext.BeanContext#addBeanContextMembershipListener(java.beans.beancontext.BeanContextMembershipListener)
- */
- public void addBeanContextMembershipListener(
- BeanContextMembershipListener bcml) {
- // Auto-generated method stub
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.beancontext.BeanContext#removeBeanContextMembershipListener(java.beans.beancontext.BeanContextMembershipListener)
- */
- public void removeBeanContextMembershipListener(
- BeanContextMembershipListener bcml) {
- // Auto-generated method stub
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.beancontext.BeanContextServicesListener#serviceAvailable(java.beans.beancontext.BeanContextServiceAvailableEvent)
- */
- public void serviceAvailable(BeanContextServiceAvailableEvent bcsae) {
- // Auto-generated method stub
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.beancontext.BeanContextChild#setBeanContext(java.beans.beancontext.BeanContext)
- */
- public void setBeanContext(BeanContext bc) throws PropertyVetoException {
- // Auto-generated method stub
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.beancontext.BeanContextChild#getBeanContext()
- */
- public BeanContext getBeanContext() {
- // Auto-generated method stub
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.beancontext.BeanContextChild#addPropertyChangeListener(java.lang.String,
- * java.beans.PropertyChangeListener)
- */
- public void addPropertyChangeListener(String name,
- PropertyChangeListener pcl) {
- // Auto-generated method stub
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.beancontext.BeanContextChild#removePropertyChangeListener(java.lang.String,
- * java.beans.PropertyChangeListener)
- */
- public void removePropertyChangeListener(String name,
- PropertyChangeListener pcl) {
- // Auto-generated method stub
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.beancontext.BeanContextChild#addVetoableChangeListener(java.lang.String,
- * java.beans.VetoableChangeListener)
- */
- public void addVetoableChangeListener(String name,
- VetoableChangeListener vcl) {
- // Auto-generated method stub
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.beancontext.BeanContextChild#removeVetoableChangeListener(java.lang.String,
- * java.beans.VetoableChangeListener)
- */
- public void removeVetoableChangeListener(String name,
- VetoableChangeListener vcl) {
- // Auto-generated method stub
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.util.Collection#size()
- */
- public int size() {
- // Auto-generated method stub
- return 0;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.util.Collection#isEmpty()
- */
- public boolean isEmpty() {
- // Auto-generated method stub
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.util.Collection#contains(java.lang.Object)
- */
- public boolean contains(Object o) {
- // Auto-generated method stub
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.util.Collection#iterator()
- */
- public Iterator iterator() {
- // Auto-generated method stub
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.util.Collection#toArray()
- */
- public Object[] toArray() {
- // Auto-generated method stub
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.util.Collection#toArray(java.lang.Object[])
- */
- public Object[] toArray(Object[] a) {
- // Auto-generated method stub
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.util.Collection#add(java.lang.Object)
- */
- public boolean add(Object o) {
- // Auto-generated method stub
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.util.Collection#remove(java.lang.Object)
- */
- public boolean remove(Object o) {
- // Auto-generated method stub
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.util.Collection#containsAll(java.util.Collection)
- */
- public boolean containsAll(Collection c) {
- // Auto-generated method stub
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.util.Collection#addAll(java.util.Collection)
- */
- public boolean addAll(Collection c) {
- // Auto-generated method stub
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.util.Collection#removeAll(java.util.Collection)
- */
- public boolean removeAll(Collection c) {
- // Auto-generated method stub
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.util.Collection#retainAll(java.util.Collection)
- */
- public boolean retainAll(Collection c) {
- // Auto-generated method stub
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.util.Collection#clear()
- */
- public void clear() {
- // Auto-generated method stub
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.DesignMode#setDesignTime(boolean)
- */
- public void setDesignTime(boolean designTime) {
- // Auto-generated method stub
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.DesignMode#isDesignTime()
- */
- public boolean isDesignTime() {
- // Auto-generated method stub
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.Visibility#needsGui()
- */
- public boolean needsGui() {
- // Auto-generated method stub
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.Visibility#dontUseGui()
- */
- public void dontUseGui() {
- // Auto-generated method stub
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.Visibility#okToUseGui()
- */
- public void okToUseGui() {
- // Auto-generated method stub
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.Visibility#avoidingGui()
- */
- public boolean avoidingGui() {
- // Auto-generated method stub
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.beancontext.BeanContextServiceRevokedListener#serviceRevoked(java.beans.beancontext.BeanContextServiceRevokedEvent)
- */
- public void serviceRevoked(BeanContextServiceRevokedEvent bcsre) {
- // Auto-generated method stub
-
- }
-
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockBeanContextServicesListener.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockBeanContextServicesListener.java
deleted file mode 100644
index e9c29c9..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockBeanContextServicesListener.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * 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.beancontext.mock;
-
-import java.beans.beancontext.BeanContextServiceAvailableEvent;
-import java.beans.beancontext.BeanContextServiceRevokedEvent;
-import java.beans.beancontext.BeanContextServicesListener;
-
-/**
- * Mock of BeanContextServicesListener
- */
-public class MockBeanContextServicesListener implements
- BeanContextServicesListener {
-
- public BeanContextServiceAvailableEvent lastAvailableEvent;
-
- public BeanContextServiceRevokedEvent lastRevokedEvent;
-
- public void clearLastEvent() {
- lastAvailableEvent = null;
- lastRevokedEvent = null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.beancontext.BeanContextServicesListener#serviceAvailable(java.beans.beancontext.BeanContextServiceAvailableEvent)
- */
- public void serviceAvailable(BeanContextServiceAvailableEvent bcsae) {
- lastAvailableEvent = bcsae;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.beancontext.BeanContextServiceRevokedListener#serviceRevoked(java.beans.beancontext.BeanContextServiceRevokedEvent)
- */
- public void serviceRevoked(BeanContextServiceRevokedEvent bcsre) {
- lastRevokedEvent = bcsre;
- }
-
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockBeanContextServicesListenerS.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockBeanContextServicesListenerS.java
deleted file mode 100644
index 5347947..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockBeanContextServicesListenerS.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * 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.beancontext.mock;
-
-import java.beans.beancontext.BeanContextServiceAvailableEvent;
-import java.beans.beancontext.BeanContextServiceRevokedEvent;
-import java.beans.beancontext.BeanContextServicesListener;
-import java.io.Serializable;
-
-/**
- * Mock of BeanContextServicesListener
- */
-public class MockBeanContextServicesListenerS implements BeanContextServicesListener,
- Serializable {
-
- private static final long serialVersionUID = -2513090204796560433L;
-
- public String id;
-
- public MockBeanContextServicesListenerS(String id) {
- this.id = id;
- }
-
- public void serviceAvailable(BeanContextServiceAvailableEvent bcsae) {
-
- }
-
- public void serviceRevoked(BeanContextServiceRevokedEvent bcsre) {
-
- }
-
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockVetoChangeListener.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockVetoChangeListener.java
deleted file mode 100644
index 7bdf1c6..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockVetoChangeListener.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 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.beancontext.mock;
-
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyVetoException;
-import java.beans.VetoableChangeListener;
-
-/**
- * Mock of VetoableChangeListener
- */
-public class MockVetoChangeListener implements VetoableChangeListener {
-
- public PropertyChangeEvent lastEvent;
-
- public void clearLastEvent() {
- lastEvent = null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.VetoableChangeListener#vetoableChange(java.beans.PropertyChangeEvent)
- */
- public void vetoableChange(PropertyChangeEvent evt)
- throws PropertyVetoException {
- lastEvent = evt;
- throw new PropertyVetoException("NO CHANGE ALLOWED", evt);
- }
-
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockVetoableChangeListener.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockVetoableChangeListener.java
deleted file mode 100644
index efabdfd..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockVetoableChangeListener.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * 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.beancontext.mock;
-
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyVetoException;
-import java.beans.VetoableChangeListener;
-
-/**
- * Mock of VetoableChangeListener
- */
-public class MockVetoableChangeListener implements VetoableChangeListener {
-
- public PropertyChangeEvent lastEvent;
-
- public void clearLastEvent() {
- lastEvent = null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.VetoableChangeListener#vetoableChange(java.beans.PropertyChangeEvent)
- */
- public void vetoableChange(PropertyChangeEvent evt)
- throws PropertyVetoException {
- lastEvent = evt;
- }
-
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockVetoableChangeListenerS.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockVetoableChangeListenerS.java
deleted file mode 100644
index fdb5e8b..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockVetoableChangeListenerS.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * 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.beancontext.mock;
-
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyVetoException;
-import java.beans.VetoableChangeListener;
-import java.io.Serializable;
-
-/**
- * Mock of VetoableChangeListener
- */
-public class MockVetoableChangeListenerS implements VetoableChangeListener, Serializable {
-
- private static final long serialVersionUID = -455571860616755790L;
-
- public PropertyChangeEvent lastEvent;
-
- public String id;
-
- public MockVetoableChangeListenerS(String id) {
- this.id = id;
- }
-
- public void clearLastEvent() {
- lastEvent = null;
- }
-
- public void vetoableChange(PropertyChangeEvent evt) throws PropertyVetoException {
- lastEvent = evt;
- }
-
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockVisibility.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockVisibility.java
deleted file mode 100644
index d413f53..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/beancontext/mock/MockVisibility.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * 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.beancontext.mock;
-
-import java.beans.Visibility;
-
-/**
- * Test Visibility
- */
-public class MockVisibility implements Visibility {
-
- public boolean avoidingGui;
-
- public boolean needsGui;
-
- public boolean okToUseGui;
-
- public MockVisibility(boolean avoiding, boolean needs) {
- this.avoidingGui = avoiding;
- this.needsGui = needs;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.Visibility#avoidingGui()
- */
- public boolean avoidingGui() {
- return avoidingGui;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.Visibility#dontUseGui()
- */
- public void dontUseGui() {
- okToUseGui = false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.Visibility#needsGui()
- */
- public boolean needsGui() {
- return needsGui;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.Visibility#okToUseGui()
- */
- public void okToUseGui() {
- okToUseGui = true;
- }
-
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/CorruptedSerBean.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/CorruptedSerBean.java
deleted file mode 100644
index dbb7183..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/CorruptedSerBean.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * 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 CorruptedSerBean {
-
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/CorruptedSerBean.ser b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/CorruptedSerBean.ser
deleted file mode 100644
index 74b8f11..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/CorruptedSerBean.ser
+++ /dev/null
@@ -1 +0,0 @@
-bad data. \ No newline at end of file
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/EmptySerBean.ser b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/EmptySerBean.ser
deleted file mode 100644
index e69de29..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/EmptySerBean.ser
+++ /dev/null
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/FakeFox.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/FakeFox.java
deleted file mode 100644
index e06ae05..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/FakeFox.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * 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;
-
-/**
- * The series of FakeFox classes are used to test
- * Introspector.getBeanInfo(Class, int)
- */
-public class FakeFox {
-
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/FakeFox01.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/FakeFox01.java
deleted file mode 100644
index 66642a4..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/FakeFox01.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * 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;
-
-/**
- * The series of FakeFox classes are used to test
- * Introspector.getBeanInfo(Class, int)
- */
-public class FakeFox01 extends FakeFox {
- String fox01;
-
- public String getFox01() {
- return fox01;
- }
-
- public void setFox01(String fox01) {
- this.fox01 = fox01;
- }
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/FakeFox011.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/FakeFox011.java
deleted file mode 100644
index 748d1c6..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/FakeFox011.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * 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;
-
-/**
- * The series of FakeFox classes are used to test
- * Introspector.getBeanInfo(Class, int)
- */
-public class FakeFox011 extends FakeFox01 {
- String fox011;
-
- public String getFox011() {
- return fox011;
- }
-
- public void setFox011(String fox011) {
- this.fox011 = fox011;
- }
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/FakeFox01BeanInfo.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/FakeFox01BeanInfo.java
deleted file mode 100644
index d6ece95..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/FakeFox01BeanInfo.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * 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.BeanDescriptor;
-import java.beans.IntrospectionException;
-import java.beans.MethodDescriptor;
-import java.beans.PropertyDescriptor;
-import java.beans.SimpleBeanInfo;
-import java.lang.reflect.Method;
-
-/**
- * The series of FakeFox classes are used to test
- * Introspector.getBeanInfo(Class, int)
- */
-public class FakeFox01BeanInfo extends SimpleBeanInfo {
-
- Class<FakeFox01> clazz = FakeFox01.class;
-
- String suffix = "." + clazz.getName();
-
- @Override
- public BeanDescriptor getBeanDescriptor() {
- BeanDescriptor beanDesc = new BeanDescriptor(clazz);
- beanDesc.setDisplayName(beanDesc.getDisplayName() + suffix);
- return beanDesc;
- }
-
- @Override
- public MethodDescriptor[] getMethodDescriptors() {
- Method get = null;
- Method set = null;
- try {
- get = clazz.getMethod("getFox01", (Class[]) null);
- set = clazz.getMethod("setFox01", new Class[] { String.class });
- } catch (SecurityException e) {
- e.printStackTrace();
- } catch (NoSuchMethodException e) {
- e.printStackTrace();
- }
-
- MethodDescriptor getDesc = new MethodDescriptor(get);
- getDesc.setDisplayName(getDesc.getDisplayName() + suffix);
- MethodDescriptor setDesc = new MethodDescriptor(set);
- setDesc.setDisplayName(setDesc.getDisplayName() + suffix);
- return new MethodDescriptor[] { setDesc, getDesc };
- }
-
- @Override
- public PropertyDescriptor[] getPropertyDescriptors() {
- PropertyDescriptor propertyDesc = null;
- try {
- propertyDesc = new PropertyDescriptor("fox01", clazz);
- propertyDesc.setDisplayName(propertyDesc.getDisplayName() + suffix);
- } catch (IntrospectionException e) {
- e.printStackTrace();
- }
- return new PropertyDescriptor[] { propertyDesc };
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.BeanInfo#getDefaultEventIndex()
- */
- @Override
- public int getDefaultEventIndex() {
- return -1;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.BeanInfo#getDefaultPropertyIndex()
- */
- @Override
- public int getDefaultPropertyIndex() {
- // TODO Auto-generated method stub
- return 0;
- }
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/FakeFox02.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/FakeFox02.java
deleted file mode 100644
index 08c6160..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/FakeFox02.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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;
-
-/**
- * The series of FakeFox classes are used to test
- * Introspector.getBeanInfo(Class, int)
- */
-public class FakeFox02 {
- String fox02;
-
- /**
- * @return Returns the fox02.
- */
- public String getFox02() {
- return fox02;
- }
-
- /**
- * @param fox02
- * The fox02 to set.
- */
- public void setFox02(String fox02) {
- this.fox02 = fox02;
- }
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/FakeFox02BeanInfo.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/FakeFox02BeanInfo.java
deleted file mode 100644
index 0c32335..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/FakeFox02BeanInfo.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * 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;
-
-/**
- * The series of FakeFox classes are used to test
- * Introspector.getBeanInfo(Class, int)
- */
-public class FakeFox02BeanInfo extends SimpleBeanInfo {
-
- public FakeFox02BeanInfo() {
- super();
- }
-
- public FakeFox02BeanInfo(String param) {
- super();
- }
-
- @Override
- public PropertyDescriptor[] getPropertyDescriptors() {
- PropertyDescriptor pd = null;
- try {
- pd = new PropertyDescriptor("fox02", FakeFox02.class);
- pd.setDisplayName("fox02.beaninfo");
- } catch (IntrospectionException e) {
-
- }
- return new PropertyDescriptor[] { pd };
- }
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/FakeFox03.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/FakeFox03.java
deleted file mode 100644
index 9d59533..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/FakeFox03.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * 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 FakeFox03 {
- public int getOther() {
-
- return 0;
-
- }
-
- public void setOther(int other) {}
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/FakeFox031.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/FakeFox031.java
deleted file mode 100644
index c6a7d9e..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/FakeFox031.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * 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 FakeFox031 {
- public int[] getDefault() {
- return null;
- }
- public void setDefault( int[] i ) {}
-
-
- public int indexedGetDefault( int i) {
- return 0;
- }
- public void indexedSetDefault( int i, int b ) {}
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/FakeFox031BeanInfo.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/FakeFox031BeanInfo.java
deleted file mode 100644
index 3d3ecc4..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/FakeFox031BeanInfo.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * 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.BeanDescriptor;
-import java.beans.BeanInfo;
-import java.beans.EventSetDescriptor;
-import java.beans.PropertyDescriptor;
-import java.beans.SimpleBeanInfo;
-
-public class FakeFox031BeanInfo extends SimpleBeanInfo{
- public FakeFox031BeanInfo() {
- super();
- }
-
- public BeanDescriptor getBeanDescriptor() {
- BeanDescriptor descriptor = new BeanDescriptor(FakeFox031.class);
- descriptor.setName("DummyBean Descriptor");
- return descriptor;
- }
-
- public BeanInfo[] getAdditionalBeanInfo() {
-
- return new BeanInfo[] { new FakeFox03BeanInfo() };
-
- }
-
- public PropertyDescriptor[] getPropertyDescriptors() {
- return new PropertyDescriptor[] {};
- }
-
- public EventSetDescriptor[] getEventSetDescriptors() {
- return new EventSetDescriptor[] {};
- }
-
- PropertyDescriptor propdescr[];
-
- EventSetDescriptor eventdescr[];
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/FakeFox03BeanInfo.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/FakeFox03BeanInfo.java
deleted file mode 100644
index d5bc37e..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/FakeFox03BeanInfo.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * 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.awt.Image;
-import java.awt.image.BufferedImage;
-import java.beans.BeanDescriptor;
-import java.beans.EventSetDescriptor;
-import java.beans.PropertyDescriptor;
-import java.beans.SimpleBeanInfo;
-
-public class FakeFox03BeanInfo extends SimpleBeanInfo {
-
- PropertyDescriptor propdescr[];
-
- EventSetDescriptor eventdescr[];
-
- public FakeFox03BeanInfo() {
- super();
- try {
- propdescr = new PropertyDescriptor[] { new PropertyDescriptor(
- "Other", FakeFox03.class) };
- eventdescr = new EventSetDescriptor[] { new EventSetDescriptor(
- SomeOtherObject.class, "SomeOther",
- SomeOtherListener.class, "aMethod") };
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- public BeanDescriptor getBeanDescriptor() {
- BeanDescriptor descriptor = new BeanDescriptor(FakeFox03.class);
- descriptor.setName("SomeOtherBean Descriptor");
- return descriptor;
- }
-
- public static final Image someOtherImage = new BufferedImage(1, 1,
- BufferedImage.TYPE_3BYTE_BGR);
-
- public Image getIcon(int iconKind) {
- return someOtherImage;
-
- }
-
- public int getDefaultPropertyIndex() {
- System.out
- .println("SomeOtherBeanBeanInfo.getDefaultPropertyIndex() called...");
- return propdescr.length - 1;
- }
-
- public PropertyDescriptor[] getPropertyDescriptors() {
- return propdescr;
- }
-
- public int getDefaultEventIndex() {
- return eventdescr.length - 1;
- }
-
- public EventSetDescriptor[] getEventSetDescriptors() {
- return eventdescr;
- }
-
- private interface SomeOtherListener {
- public void aMethod(SomeOtherEvent s);
- }
-
- private class SomeOtherObject {
- public void addFakeFox03BeanInfo$SomeOtherListener(
- SomeOtherListener l) {
- }
-
- public void removeFakeFox03BeanInfo$SomeOtherListener(
- SomeOtherListener l) {
- }
- }
-
- private class SomeOtherEvent {
- }
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/FakeFox04.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/FakeFox04.java
deleted file mode 100644
index 703e262..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/FakeFox04.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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 FakeFox04 extends Object {
-
- public int[] getOneProp() {
- return null;
- }
-
- public void setOneProp(int[] i) {
- }
-
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/FakeFox041.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/FakeFox041.java
deleted file mode 100644
index f7149b0..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/FakeFox041.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * 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.PropertyChangeListener;
-import java.beans.PropertyVetoException;
-
-public class FakeFox041 extends FakeFox04 {
-
- public int[] getTwoProp() {
- return null;
- }
-
- // throwing PropertyVetoException makes this property constrained.
- public void setTwoProp(int[] i) throws PropertyVetoException {
- }
-
- // being able to add/remove listeners makes this classes properties bound.
- // but it does not bind properties in any superclasses.
- // both add and remove methods are required.
- public void addPropertyChangeListener(PropertyChangeListener l) {
- }
-
- public void removePropertyChangeListener(PropertyChangeListener l) {
- }
-
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/FakeFox0411.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/FakeFox0411.java
deleted file mode 100644
index 0f8f966..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/FakeFox0411.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * 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 FakeFox0411 extends FakeFox041 {
-
- public int[] getThreeProp() {
- return null;
- }
-
- // throwing PropertyVetoException makes this property constrained.
- public void setThreeProp(int[] i) {
- }
-
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/Foz.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/Foz.java
deleted file mode 100644
index d39b5f7..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/Foz.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * 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;
-
-/**
- * Test PropertyEditorManager
- */
-public class Foz {
- private String name;
-
- private String text;
-
- /**
- * @return Returns the name.
- */
- public String getName() {
- return name;
- }
-
- /**
- * @param name
- * The name to set.
- */
- public void setName(String name) {
- this.name = name;
- }
-
- /**
- * @return Returns the text.
- */
- public String getText() {
- return text;
- }
-
- /**
- * @param text
- * The text to set.
- */
- public void setText(String text) {
- this.text = text;
- }
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/FozDefault.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/FozDefault.java
deleted file mode 100644
index 290ec5e..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/FozDefault.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * 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;
-
-/**
- * Test PropertyEditorManager
- */
-public class FozDefault {
- private String name;
-
- private String text;
-
- /**
- * @return Returns the name.
- */
- public String getName() {
- return name;
- }
-
- /**
- * @param name
- * The name to set.
- */
- public void setName(String name) {
- this.name = name;
- }
-
- /**
- * @return Returns the text.
- */
- public String getText() {
- return text;
- }
-
- /**
- * @param text
- * The text to set.
- */
- public void setText(String text) {
- this.text = text;
- }
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/Fozz.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/Fozz.java
deleted file mode 100644
index 320c520..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/Fozz.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * 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;
-
-/**
- * Test PropertyEditorManager
- */
-public class Fozz {
- private String name;
-
- private String text;
-
- /**
- * @return Returns the name.
- */
- public String getName() {
- return name;
- }
-
- /**
- * @param name
- * The name to set.
- */
- public void setName(String name) {
- this.name = name;
- }
-
- /**
- * @return Returns the text.
- */
- public String getText() {
- return text;
- }
-
- /**
- * @param text
- * The text to set.
- */
- public void setText(String text) {
- this.text = text;
- }
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/FozzEditor.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/FozzEditor.java
deleted file mode 100644
index 3dc911c..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/FozzEditor.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * 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.awt.Component;
-import java.awt.Graphics;
-import java.awt.Rectangle;
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyEditor;
-
-/**
- * Test PropertyEditorManager
- */
-public class FozzEditor implements PropertyEditor {
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.PropertyEditor#addPropertyChangeListener(java.beans.PropertyChangeListener)
- */
- public void addPropertyChangeListener(PropertyChangeListener listener) {
- // TO DO Auto-generated method stub
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.PropertyEditor#getAsText()
- */
- public String getAsText() {
- // TO DO Auto-generated method stub
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.PropertyEditor#getCustomEditor()
- */
- public Component getCustomEditor() {
- // TO DO Auto-generated method stub
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.PropertyEditor#getJavaInitializationString()
- */
- public String getJavaInitializationString() {
- // TO DO Auto-generated method stub
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.PropertyEditor#getTags()
- */
- public String[] getTags() {
- // TO DO Auto-generated method stub
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.PropertyEditor#getValue()
- */
- public Object getValue() {
- // TO DO Auto-generated method stub
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.PropertyEditor#isPaintable()
- */
- public boolean isPaintable() {
- // TO DO Auto-generated method stub
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.PropertyEditor#paintValue(java.awt.Graphics,
- * java.awt.Rectangle)
- */
- public void paintValue(Graphics graphics, Rectangle box) {
- // TO DO Auto-generated method stub
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.PropertyEditor#removePropertyChangeListener(java.beans.PropertyChangeListener)
- */
- public void removePropertyChangeListener(PropertyChangeListener listener) {
- // TO DO Auto-generated method stub
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.PropertyEditor#setAsText(java.lang.String)
- */
- public void setAsText(String text) throws IllegalArgumentException {
- // TO DO Auto-generated method stub
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.PropertyEditor#setValue(java.lang.Object)
- */
- public void setValue(Object value) {
- // TO DO Auto-generated method stub
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.PropertyEditor#supportsCustomEditor()
- */
- public boolean supportsCustomEditor() {
- // TO DO Auto-generated method stub
- return false;
- }
-
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/Fozzz.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/Fozzz.java
deleted file mode 100644
index 3fb06ec..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/Fozzz.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * 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;
-
-/**
- * Test PropertyEditorManager
- */
-public class Fozzz {
- private String name;
-
- private String text;
-
- /**
- * @return Returns the name.
- */
- public String getName() {
- return name;
- }
-
- /**
- * @param name
- * The name to set.
- */
- public void setName(String name) {
- this.name = name;
- }
-
- /**
- * @return Returns the text.
- */
- public String getText() {
- return text;
- }
-
- /**
- * @param text
- * The text to set.
- */
- public void setText(String text) {
- this.text = text;
- }
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockAppletBean.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockAppletBean.java
deleted file mode 100644
index 9b76b98..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockAppletBean.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * 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.applet.Applet;
-
-/**
- * test java.beans.Beans
- */
-public class MockAppletBean extends Applet {
- private static final long serialVersionUID = -1501701773486783824L;
-
- private String propertyOne;
-
- private boolean initBeenCalled;
-
- @Override
- public void init() {
- super.init();
- this.initBeenCalled = true;
- }
-
- public boolean initHasBeenCalled() {
- return this.initBeenCalled;
- }
-
- public void setInitHasBeenCalled(boolean value) {
- this.initBeenCalled = value;
- }
-
- public String getPropertyOne() {
- return propertyOne;
- }
-
- public void setPropertyOne(String propertyOne) {
- this.propertyOne = propertyOne;
- }
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockAppletBean2.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockAppletBean2.java
deleted file mode 100644
index 782a372..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockAppletBean2.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * 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.applet.Applet;
-import java.io.Serializable;
-
-/**
- * test java.beans.Beans
- */
-public class MockAppletBean2 extends Applet implements Serializable {
- private static final long serialVersionUID = 1L;
-
- private String propertyOne;
-
- private boolean initBeenCalled;
-
- @Override
- public void init() {
- super.init();
- this.initBeenCalled = true;
- }
-
- public boolean initHasBeenCalled() {
- return this.initBeenCalled;
- }
-
- public void setInitHasBeenCalled(boolean value) {
- this.initBeenCalled = value;
- }
-
- /**
- * @return Returns the propertyOne.
- */
- public String getPropertyOne() {
- return propertyOne;
- }
-
- /**
- * @param propertyOne
- * The propertyOne to set.
- */
- public void setPropertyOne(String propertyOne) {
- this.propertyOne = propertyOne;
- }
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockAppletInitializer.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockAppletInitializer.java
deleted file mode 100644
index cdee330..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockAppletInitializer.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * 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.applet.Applet;
-import java.beans.AppletInitializer;
-import java.beans.beancontext.BeanContext;
-
-/**
- * test java.beans.Beans
- */
-public class MockAppletInitializer implements AppletInitializer {
-
- private boolean activateBeenCalled;
-
- private boolean initializeBeenCalled;
-
- public boolean activateHasBeenCalled() {
- return this.activateBeenCalled;
- }
-
- public boolean initializeHasBeenCalled() {
- return this.initializeBeenCalled;
- }
-
- public void activate(Applet newApplet) {
- this.activateBeenCalled = true;
- }
-
- public void initialize(Applet appletBean, BeanContext context) {
- this.initializeBeenCalled = true;
- }
-
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockBean4Codec.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockBean4Codec.java
deleted file mode 100644
index 12ae61d..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockBean4Codec.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * 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 MockBean4Codec extends MockBean4CodecPrimitives {
-
- public static MockBean4Codec getInstanceOfManyChanges() {
- MockBean4Codec bean = new MockBean4Codec();
- bean.setB((byte) 127);
- bean.setBackRef(bean);
- bean.setBobj(new Byte((byte) 127));
- bean.setBool(false);
- bean.setBoolobj(Boolean.TRUE);
- bean.getBornFriend().setClazz(Exception.class);
- bean.getBornFriend().getZarr()[0] = 888;
- bean.setC('Z');
- bean.setClazz(String.class);
- bean.setCobj(new Character('z'));
- bean.setD(123.456);
- bean.setDobj(new Double(123.456));
- bean.setF(12.34F);
- bean.setFobj(new Float(12.34F));
- bean.setFriend(new MockBean4Codec());
- bean.getFriend().setClazz(MockBean4Codec.class);
- bean.setI(999);
- bean.setIobj(new Integer(999));
- bean.setL(8888888);
- bean.setLobj(new Long(8888888));
- bean.setName("Li Yang");
- bean.setNill(null);
- bean.setS((short) 55);
- bean.setSobj(new Short((short) 55));
- bean.setZarr(new int[] { 3, 2, 1 });
- bean.setZarrarr(new String[][] { { "6", "6", "6" } });
- return bean;
- }
-
- public static MockBean4Codec getInstanceOfManyChanges2() {
- MockBean4Codec bean = new MockBean4Codec();
- bean.getBornFriend().setClazz(Exception.class);
- return bean;
- }
-
- String name;
-
- MockBean4Codec friend;
-
- MockBean4CodecPrimitives bornFriend = new MockBean4CodecPrimitives();
-
- MockBean4Codec backRef;
-
- public MockBean4Codec() {
- super();
- }
-
- /**
- * @return Returns the friend.
- */
- public MockBean4Codec getFriend() {
- return friend;
- }
-
- /**
- * @param friend
- * The friend to set.
- */
- public void setFriend(MockBean4Codec friend) {
- this.friend = friend;
- }
-
- /**
- * @return Returns the name.
- */
- public String getName() {
- return name;
- }
-
- /**
- * @param name
- * The name to set.
- */
- public void setName(String name) {
- this.name = name;
- }
-
- /**
- * @return Returns the backRef.
- */
- public MockBean4Codec getBackRef() {
- return backRef;
- }
-
- /**
- * @param backRef
- * The backRef to set.
- */
- public void setBackRef(MockBean4Codec backRef) {
- this.backRef = backRef;
- }
-
- /**
- * @return Returns the bornFriend.
- */
- public MockBean4CodecPrimitives getBornFriend() {
- return bornFriend;
- }
-
- /**
- * @param bornFriend
- * The bornFriend to set.
- */
- public void setBornFriend(MockBean4CodecPrimitives bornFriend) {
- this.bornFriend = bornFriend;
- }
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockBean4CodecAdv.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockBean4CodecAdv.java
deleted file mode 100644
index 809ce49..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockBean4CodecAdv.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * 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.util.ArrayList;
-import java.util.Calendar;
-import java.util.Currency;
-import java.util.Date;
-import java.util.Locale;
-import java.util.Properties;
-import java.util.TimeZone;
-
-public class MockBean4CodecAdv extends MockBean4Codec {
-
- String id;
-
- ArrayList<Object> arraylist = new ArrayList<Object>();
-
- Calendar calendar = Calendar.getInstance();
-
- Currency currency = Currency.getInstance(Locale.US);
-
- Date date = new Date();
-
- Locale locale = Locale.US;
-
- Properties properties = new Properties();
-
- TimeZone timezone = TimeZone.getTimeZone("GMT+8");
-
- /**
- *
- */
- public MockBean4CodecAdv(String id) {
- super();
- this.id = id;
- }
-
- public String getId() {
- return id;
- }
-
- /**
- * @return Returns the arraylist.
- */
- public ArrayList<Object> getArraylist() {
- return arraylist;
- }
-
- /**
- * @param arraylist
- * The arraylist to set.
- */
- public void setArraylist(ArrayList<Object> arraylist) {
- this.arraylist = arraylist;
- }
-
- /**
- * @return Returns the calendar.
- */
- public Calendar getCalendar() {
- return calendar;
- }
-
- /**
- * @param calendar
- * The calendar to set.
- */
- public void setCalendar(Calendar calendar) {
- this.calendar = calendar;
- }
-
- /**
- * @return Returns the currency.
- */
- public Currency getCurrency() {
- return currency;
- }
-
- /**
- * @param currency
- * The currency to set.
- */
- public void setCurrency(Currency currency) {
- this.currency = currency;
- }
-
- /**
- * @return Returns the date.
- */
- public Date getDate() {
- return date;
- }
-
- /**
- * @param date
- * The date to set.
- */
- public void setDate(Date date) {
- this.date = date;
- }
-
- /**
- * @return Returns the locale.
- */
- public Locale getLocale() {
- return locale;
- }
-
- /**
- * @param locale
- * The locale to set.
- */
- public void setLocale(Locale locale) {
- this.locale = locale;
- }
-
- /**
- * @return Returns the properties.
- */
- public Properties getProperties() {
- return properties;
- }
-
- /**
- * @param properties
- * The properties to set.
- */
- public void setProperties(Properties properties) {
- this.properties = properties;
- }
-
- /**
- * @return Returns the timezone.
- */
- public TimeZone getTimezone() {
- return timezone;
- }
-
- /**
- * @param timezone
- * The timezone to set.
- */
- public void setTimezone(TimeZone timezone) {
- this.timezone = timezone;
- }
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockBean4CodecBadGetter.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockBean4CodecBadGetter.java
deleted file mode 100644
index 1130a7e..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockBean4CodecBadGetter.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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 MockBean4CodecBadGetter extends MockBean4Codec {
-
- public MockBean4CodecBadGetter() {
- super();
- }
-
- @Override
- public String getName() {
- throw new UnsupportedOperationException();
- }
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockBean4CodecBadSetter.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockBean4CodecBadSetter.java
deleted file mode 100644
index ac2a232..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockBean4CodecBadSetter.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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 MockBean4CodecBadSetter extends MockBean4Codec {
-
- public MockBean4CodecBadSetter() {
- super();
- }
-
- @Override
- public void setName(String name) {
- throw new UnsupportedOperationException();
- }
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockBean4CodecPrimitives.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockBean4CodecPrimitives.java
deleted file mode 100644
index b7b6324..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockBean4CodecPrimitives.java
+++ /dev/null
@@ -1,408 +0,0 @@
-/*
- * 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.lang.reflect.Field;
-import java.util.Collection;
-
-public class MockBean4CodecPrimitives {
-
- boolean bool = true;
-
- byte b = 1;
-
- char c = 'a';
-
- double d = 3.14;
-
- float f = 3.14F;
-
- int i = 4;
-
- long l = 8;
-
- short s = 2;
-
- Boolean boolobj = Boolean.FALSE;
-
- Byte bobj = new Byte((byte) 11);
-
- Character cobj = new Character('A');
-
- Double dobj = new Double(6.28);
-
- Float fobj = new Float(6.28F);
-
- Integer iobj = new Integer(44);
-
- Long lobj = new Long(88);
-
- Short sobj = new Short((short) 22);
-
- Object nill = "start with not null";
-
- Class<?> clazz = Collection.class;
-
- int zarr[] = { 1, 2, 3, 4 };
-
- String zarrarr[][] = { { "1", "2" }, { "3", "4", "5" } };
-
- public MockBean4CodecPrimitives() {
- super();
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == null || !getClass().equals(obj.getClass())) {
- return false;
- }
- try {
- Field fields[] = getClass().getDeclaredFields();
- for (Field element : fields) {
- Object mine = element.get(this);
- Object other = element.get(obj);
- if (mine == null ? other != null : !mine.equals(other)) {
- return false;
- }
- }
- return true;
- } catch (Exception e) {
- throw new RuntimeException("impossible!!");
- }
- }
-
- @Override
- public int hashCode() {
- try {
- int code = 0;
- Field fields[] = getClass().getDeclaredFields();
- for (Field element : fields) {
- Object mine = element.get(this);
- if (mine instanceof MockBean4CodecPrimitives) {
- continue;
- }
- if (mine != null) {
- code += mine.hashCode();
- }
- }
- return code;
- } catch (Exception e) {
- throw new RuntimeException("impossible!!");
- }
- }
-
- /**
- * @return Returns the b.
- */
- public byte getB() {
- return b;
- }
-
- /**
- * @param b
- * The b to set.
- */
- public void setB(byte b) {
- this.b = b;
- }
-
- /**
- * @return Returns the bobj.
- */
- public Byte getBobj() {
- return bobj;
- }
-
- /**
- * @param bobj
- * The bobj to set.
- */
- public void setBobj(Byte bobj) {
- this.bobj = bobj;
- }
-
- /**
- * @return Returns the bool.
- */
- public boolean isBool() {
- return bool;
- }
-
- /**
- * @param bool
- * The bool to set.
- */
- public void setBool(boolean bool) {
- this.bool = bool;
- }
-
- /**
- * @return Returns the boolobj.
- */
- public Boolean getBoolobj() {
- return boolobj;
- }
-
- /**
- * @param boolobj
- * The boolobj to set.
- */
- public void setBoolobj(Boolean boolobj) {
- this.boolobj = boolobj;
- }
-
- /**
- * @return Returns the c.
- */
- public char getC() {
- return c;
- }
-
- /**
- * @param c
- * The c to set.
- */
- public void setC(char c) {
- this.c = c;
- }
-
- /**
- * @return Returns the cobj.
- */
- public Character getCobj() {
- return cobj;
- }
-
- /**
- * @param cobj
- * The cobj to set.
- */
- public void setCobj(Character cobj) {
- this.cobj = cobj;
- }
-
- /**
- * @return Returns the d.
- */
- public double getD() {
- return d;
- }
-
- /**
- * @param d
- * The d to set.
- */
- public void setD(double d) {
- this.d = d;
- }
-
- /**
- * @return Returns the dobj.
- */
- public Double getDobj() {
- return dobj;
- }
-
- /**
- * @param dobj
- * The dobj to set.
- */
- public void setDobj(Double dobj) {
- this.dobj = dobj;
- }
-
- /**
- * @return Returns the f.
- */
- public float getF() {
- return f;
- }
-
- /**
- * @param f
- * The f to set.
- */
- public void setF(float f) {
- this.f = f;
- }
-
- /**
- * @return Returns the fobj.
- */
- public Float getFobj() {
- return fobj;
- }
-
- /**
- * @param fobj
- * The fobj to set.
- */
- public void setFobj(Float fobj) {
- this.fobj = fobj;
- }
-
- /**
- * @return Returns the i.
- */
- public int getI() {
- return i;
- }
-
- /**
- * @param i
- * The i to set.
- */
- public void setI(int i) {
- this.i = i;
- }
-
- /**
- * @return Returns the iobj.
- */
- public Integer getIobj() {
- return iobj;
- }
-
- /**
- * @param iobj
- * The iobj to set.
- */
- public void setIobj(Integer iobj) {
- this.iobj = iobj;
- }
-
- /**
- * @return Returns the l.
- */
- public long getL() {
- return l;
- }
-
- /**
- * @param l
- * The l to set.
- */
- public void setL(long l) {
- this.l = l;
- }
-
- /**
- * @return Returns the lobj.
- */
- public Long getLobj() {
- return lobj;
- }
-
- /**
- * @param lobj
- * The lobj to set.
- */
- public void setLobj(Long lobj) {
- this.lobj = lobj;
- }
-
- /**
- * @return Returns the nill.
- */
- public Object getNill() {
- return nill;
- }
-
- /**
- * @param nill
- * The nill to set.
- */
- public void setNill(Object nill) {
- this.nill = nill;
- }
-
- /**
- * @return Returns the s.
- */
- public short getS() {
- return s;
- }
-
- /**
- * @param s
- * The s to set.
- */
- public void setS(short s) {
- this.s = s;
- }
-
- /**
- * @return Returns the sobj.
- */
- public Short getSobj() {
- return sobj;
- }
-
- /**
- * @param sobj
- * The sobj to set.
- */
- public void setSobj(Short sobj) {
- this.sobj = sobj;
- }
-
- /**
- * @return Returns the clazz.
- */
- public Class<?> getClazz() {
- return clazz;
- }
-
- /**
- * @param clazz
- * The clazz to set.
- */
- public void setClazz(Class<?> clazz) {
- this.clazz = clazz;
- }
-
- /**
- * @return Returns the zarr.
- */
- public int[] getZarr() {
- return zarr;
- }
-
- /**
- * @param arr
- * The zarr to set.
- */
- public void setZarr(int[] arr) {
- this.zarr = arr;
- }
-
- /**
- * @return Returns the zarrarr.
- */
- public String[][] getZarrarr() {
- return zarrarr;
- }
-
- /**
- * @param arrarr
- * The zarrarr to set.
- */
- public void setZarrarr(String[][] arrarr) {
- this.zarrarr = arrarr;
- }
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockBean4Owner_Owner.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockBean4Owner_Owner.java
deleted file mode 100644
index 787df12..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockBean4Owner_Owner.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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 MockBean4Owner_Owner {
- private int v = 1;
-
- public void loading() {
- v = 999;
- }
-
- public int getV() {
- return v;
- }
-
- public void setV(int v) {
- this.v = v;
- }
-
- @Override
- public boolean equals(Object o) {
- return (o != null && this.getClass() == o.getClass() && this.v == ((MockBean4Owner_Owner) o).v);
- }
-
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockBean4Owner_Target.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockBean4Owner_Target.java
deleted file mode 100644
index 42312d1..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockBean4Owner_Target.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * 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 MockBean4Owner_Target {
- MockBean4Owner_Owner v;
-
- public MockBean4Owner_Owner getV() {
- return v;
- }
-
- public void setV(MockBean4Owner_Owner v) {
- this.v = v;
- }
-
- @Override
- public boolean equals(Object o) {
- return (this.getClass() == o.getClass() && this.v == ((MockBean4Owner_Target) o).v);
- }
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockBean4StaticField.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockBean4StaticField.java
deleted file mode 100644
index fc8e8da..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockBean4StaticField.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 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 MockBean4StaticField {
- public static MockBean4StaticField inst = new MockBean4StaticField(999);
-
- private int v;
-
- @Override
- public boolean equals(Object o) {
- if(!(o instanceof MockBean4StaticField))return false;
- return (o.getClass().equals(this.getClass()) && this.v == ((MockBean4StaticField) o).v);
- }
-
- public MockBean4StaticField() {
- v = 1;
- }
-
- public MockBean4StaticField(int i) {
- v = i;
- }
-
- public int getV() {
- return v;
- }
-
- public void setV(int v) {
- this.v = v;
- }
-
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockBean4StaticField_PD.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockBean4StaticField_PD.java
deleted file mode 100644
index 05ca0d4..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockBean4StaticField_PD.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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.Encoder;
-import java.beans.Expression;
-import java.beans.PersistenceDelegate;
-
-public class MockBean4StaticField_PD extends PersistenceDelegate {
-
- @Override
- public Expression instantiate(Object oldInstance, Encoder out) {
- Expression exp = null;
-
- try {
- exp = new Expression(MockBean4StaticField.class.getField("inst"),
- "get", new Object[] { null });
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- return exp;
- }
-
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockBeanListener2.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockBeanListener2.java
deleted file mode 100644
index 3292656..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockBeanListener2.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * 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;
-
-/**
- * test java.beans
- */
-public class MockBeanListener2 implements MockPropertyChangeListener2 {
-
- public void mockPropertyChange(
- org.apache.harmony.beans.tests.support.mock.MockPropertyChangeEvent e) {
- }
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockButton.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockButton.java
deleted file mode 100644
index e790130..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockButton.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * 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.PropertyChangeListener;
-import java.beans.PropertyChangeSupport;
-import java.io.Serializable;
-
-/**
- * This is a mock bean for EventHandler test.
- */
-public class MockButton implements Serializable {
- private static final long serialVersionUID = 9216444906795513297L;
-
- String name;
-
- String label;
-
- PropertyChangeSupport support;
-
- static public String defaultName = "MockButton 1";
-
- public MockButton() {
- this.name = defaultName;
- this.label = this.name;
- this.support = new PropertyChangeSupport(this);
- }
-
- public void addPropertyChangeListener(PropertyChangeListener listener) {
- this.support.addPropertyChangeListener(listener);
- }
-
- public String getLabel() {
- return label;
- }
-
- public void setLabel(String label) {
- this.support.firePropertyChange("label", this.label, label);
- this.label = label;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockExceptionListener.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockExceptionListener.java
deleted file mode 100644
index 6de67cb..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockExceptionListener.java
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- * 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.ExceptionListener;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-
-/**
- * Mock of ExceptionListener
- */
-@SuppressWarnings("unchecked")
-public class MockExceptionListener implements ExceptionListener {
-
- public ArrayList<Object> exHistory = new ArrayList<Object>();
-
- public void exceptionThrown(Exception ex) {
- exHistory.add(ex);
- }
-
- /**
- * @param arg0
- * @param arg1
- */
- public void add(int arg0, Object arg1) {
- exHistory.add(arg0, arg1);
- }
-
- /**
- * @param arg0
- * @return
- */
- public boolean add(Object arg0) {
- return exHistory.add(arg0);
- }
-
- /**
- * @param arg0
- * @param arg1
- * @return
- */
- public boolean addAll(int arg0, Collection arg1) {
- return exHistory.addAll(arg0, arg1);
- }
-
- /**
- * @param arg0
- * @return
- */
- public boolean addAll(Collection arg0) {
- return exHistory.addAll(arg0);
- }
-
- /**
- *
- */
- public void clear() {
- exHistory.clear();
- }
-
- /**
- * @param arg0
- * @return
- */
- public boolean contains(Object arg0) {
- return exHistory.contains(arg0);
- }
-
- /**
- * @param arg0
- * @return
- */
- public boolean containsAll(Collection arg0) {
- return exHistory.containsAll(arg0);
- }
-
- /**
- * @param arg0
- */
- public void ensureCapacity(int arg0) {
- exHistory.ensureCapacity(arg0);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object arg0) {
- return exHistory.equals(arg0);
- }
-
- /**
- * @param arg0
- * @return
- */
- public Object get(int arg0) {
- return exHistory.get(arg0);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- return exHistory.hashCode();
- }
-
- /**
- * @param arg0
- * @return
- */
- public int indexOf(Object arg0) {
- return exHistory.indexOf(arg0);
- }
-
- /**
- * @return
- */
- public boolean isEmpty() {
- return exHistory.isEmpty();
- }
-
- /**
- * @return
- */
- public Iterator<Object> iterator() {
- return exHistory.iterator();
- }
-
- /**
- * @param arg0
- * @return
- */
- public int lastIndexOf(Object arg0) {
- return exHistory.lastIndexOf(arg0);
- }
-
- /**
- * @return
- */
- public ListIterator<Object> listIterator() {
- return exHistory.listIterator();
- }
-
- /**
- * @param arg0
- * @return
- */
- public ListIterator<Object> listIterator(int arg0) {
- return exHistory.listIterator(arg0);
- }
-
- /**
- * @param arg0
- * @return
- */
- public Object remove(int arg0) {
- return exHistory.remove(arg0);
- }
-
- /**
- * @param arg0
- * @return
- */
- public boolean remove(Object arg0) {
- return exHistory.remove(arg0);
- }
-
- /**
- * @param arg0
- * @return
- */
- public boolean removeAll(Collection arg0) {
- return exHistory.removeAll(arg0);
- }
-
- /**
- * @param arg0
- * @return
- */
- public boolean retainAll(Collection arg0) {
- return exHistory.retainAll(arg0);
- }
-
- /**
- * @param arg0
- * @param arg1
- * @return
- */
- public Object set(int arg0, Object arg1) {
- return exHistory.set(arg0, arg1);
- }
-
- /**
- * @return
- */
- public int size() {
- return exHistory.size();
- }
-
- /**
- * @param arg0
- * @param arg1
- * @return
- */
- public List<Object> subList(int arg0, int arg1) {
- return exHistory.subList(arg0, arg1);
- }
-
- /**
- * @return
- */
- public Object[] toArray() {
- return exHistory.toArray();
- }
-
- /**
- * @param arg0
- * @return
- */
- public Object[] toArray(Object[] arg0) {
- return exHistory.toArray(arg0);
- }
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockFakeListener.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockFakeListener.java
deleted file mode 100644
index 9d7eda8..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockFakeListener.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * 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;
-
-/**
- * test java.beans
- */
-public interface MockFakeListener {
- public void mockPropertyChange(MockPropertyChangeEvent e);
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockFoo.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockFoo.java
deleted file mode 100644
index 286bb8e..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockFoo.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * 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.io.Serializable;
-
-/**
- * This class is used for Introspector test.
- */
-public class MockFoo extends MockFooStop implements Serializable {
-
- /**
- * Comment for <code>serialVersionUID</code>
- */
- private static final long serialVersionUID = 1L;
-
- private String name;
- private MockFooLabel complexLabel;
-
- /**
- * @return Returns the name.
- */
- public String getName() {
- return name;
- }
-
- /**
- * @param name The name to set.
- */
- public void setName(String name) {
- this.name = name;
- }
-
- public MockFooLabel getComplexLabel() {
- return complexLabel;
- }
-
- public void setComplexLabel(MockFooLabel label) {
- this.complexLabel = label;
- }
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockFoo2.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockFoo2.java
deleted file mode 100644
index deab145..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockFoo2.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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;
-
-/**
- * A bean that has get/set method different from getXXX and setXXX.
- */
-public class MockFoo2 extends MockFoo2Parent {
- private int prop1;
-
- public MockFoo2() {
- }
-
- public MockFoo2(int prop) {
- this.prop1 = prop;
- }
-
- public int myget() {
- return this.prop1;
- }
-
- public void myset(int prop) {
- this.prop1 = prop;
- }
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockFoo2BeanInfo.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockFoo2BeanInfo.java
deleted file mode 100644
index 6566ae8..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockFoo2BeanInfo.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * 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;
-
-/**
- * Testcases for persistence delegate classes.
- */
-public class MockFoo2BeanInfo extends SimpleBeanInfo {
-
- @Override
- public PropertyDescriptor[] getPropertyDescriptors() {
- PropertyDescriptor pd = null;
-
- try {
- pd = new PropertyDescriptor("prop",
- MockFoo2.class, "myget", "myset");
- } catch (IntrospectionException e) {
- throw new Error(e);
- }
- return new PropertyDescriptor[] { pd };
- }
-
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockFoo2Parent.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockFoo2Parent.java
deleted file mode 100644
index fd79374..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockFoo2Parent.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * 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;
-
-/**
- * test for DefaultPersistenceDelegate
- */
-public class MockFoo2Parent {
- private int i = 0;
-
- public void set(int i) {
- this.i = i;
- }
-
- public int get() {
- return this.i;
- }
-
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockFoo2ParentBeanInfo.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockFoo2ParentBeanInfo.java
deleted file mode 100644
index 84d615d..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockFoo2ParentBeanInfo.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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;
-
-/**
- * test for DefaultPersistenceDelegate
- */
-public class MockFoo2ParentBeanInfo {
- public PropertyDescriptor[] getPropertyDescriptors() {
- PropertyDescriptor[] pds = new PropertyDescriptor[1];
- try {
- PropertyDescriptor pd = new PropertyDescriptor("prop",
- MockFoo2.class, "get", "set");
- pd.setName(pd.getName() + ".BeanInfo");
- pds[0] = pd;
- } catch (IntrospectionException e) {
- throw new Error(e);
- }
- return pds;
- }
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockFooBeanInfo.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockFooBeanInfo.java
deleted file mode 100644
index d3e0309..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockFooBeanInfo.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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.BeanDescriptor;
-import java.beans.SimpleBeanInfo;
-
-/**
- * test for DefaultPersistenceDelegate
- */
-public class MockFooBeanInfo extends SimpleBeanInfo {
- private final Class<MockFoo> clazz = MockFoo.class;
-
- private final String suffix = ".BeanInfo";
-
- @Override
- public BeanDescriptor getBeanDescriptor() {
- BeanDescriptor beanDesc = new BeanDescriptor(clazz);
- beanDesc.setName(beanDesc.getName() + suffix);
- // beanDesc.setValue("persistenceDelegate", new
- // EncoderTest.VerbosePD());
- return beanDesc;
- }
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockFooButton.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockFooButton.java
deleted file mode 100644
index b1b5930..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockFooButton.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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.io.Serializable;
-
-/**
- * Test the default bean info search path.
- */
-public class MockFooButton implements Serializable {
- private static final long serialVersionUID = -2605949066932919527L;
-
- private String text;
-
- public String getText() {
- return text;
- }
-
- public void setText(String text) {
- this.text = text;
- }
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockFooChild.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockFooChild.java
deleted file mode 100644
index bf6d0b3..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockFooChild.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * 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;
-
-/**
- * test Introspector
- */
-public class MockFooChild extends MockFoo {
- private static final long serialVersionUID = -5817959822261385626L;
-
- private String childName;
-
- public String getChildName() {
- return childName;
- }
-
- public void setChildName(String childName) {
- this.childName = childName;
- }
-
- public void addMockPropertyChangeListener(MockPropertyChangeListener listener) {
-
- }
-
- public void removeMockPropertyChangeListener(MockPropertyChangeListener listener) {
-
- }
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockFooChildBeanInfo.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockFooChildBeanInfo.java
deleted file mode 100644
index 7e0b3aa..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockFooChildBeanInfo.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * 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.MethodDescriptor;
-import java.beans.PropertyDescriptor;
-import java.beans.SimpleBeanInfo;
-import java.lang.reflect.Method;
-
-/**
- * test Introspector
- */
-public class MockFooChildBeanInfo extends SimpleBeanInfo {
-
- Class<MockFooChild> clazz = MockFooChild.class;
-
- String suffix = ".MockFooChildBeanInfo";
-
- @Override
- public PropertyDescriptor[] getPropertyDescriptors() {
- PropertyDescriptor[] pds = new PropertyDescriptor[1];
- try {
- PropertyDescriptor pd = new PropertyDescriptor("childName", clazz);
- pd.setName(pd.getName() + suffix);
- pds[0] = pd;
- } catch (IntrospectionException e) {
- e.printStackTrace();
- }
- return pds;
- }
-
- @Override
- public MethodDescriptor[] getMethodDescriptors() {
- MethodDescriptor[] mds = new MethodDescriptor[2];
- try {
- Method getMethod = clazz.getMethod("getChildName", (Class[]) null);
- Method setMethod = clazz.getMethod("setChildName",
- new Class[] { String.class });
- mds[0] = new MethodDescriptor(getMethod);
- mds[0].setName(mds[0].getName() + suffix);
-
- mds[1] = new MethodDescriptor(setMethod);
- mds[1].setName(mds[1].getName() + suffix);
-
- } catch (SecurityException e) {
- e.printStackTrace();
- } catch (NoSuchMethodException e) {
- e.printStackTrace();
- }
- return mds;
- }
-
- @Override
- public EventSetDescriptor[] getEventSetDescriptors() {
- EventSetDescriptor[] esds = new EventSetDescriptor[1];
- try {
- EventSetDescriptor esd = new EventSetDescriptor(clazz,
- "mockPropertyChange", MockPropertyChangeListener.class,
- "mockPropertyChange");
- esd.setName(esd.getName() + suffix);
- esds[0] = esd;
- } catch (IntrospectionException e) {
- e.printStackTrace();
- }
- return esds;
- }
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockFooLabel.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockFooLabel.java
deleted file mode 100644
index 46a31f6..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockFooLabel.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * 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.io.Serializable;
-
-/**
- * Test the default bean info search path.
- */
-public class MockFooLabel implements Serializable {
- private static final long serialVersionUID = -1305056517480261922L;
-
- private String text;
-
- public MockFooLabel() {
- }
-
- public MockFooLabel(String text) {
- this.text = text;
- }
-
- public String getText() {
- return text;
- }
-
- public void setText(String text) {
- this.text = text;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof MockFooLabel) {
- return false;
- }
- return false;
- }
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockFooLabelBeanInfo.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockFooLabelBeanInfo.java
deleted file mode 100644
index 66a2dad..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockFooLabelBeanInfo.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * 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.BeanDescriptor;
-import java.beans.IntrospectionException;
-import java.beans.PropertyDescriptor;
-import java.beans.SimpleBeanInfo;
-
-public class MockFooLabelBeanInfo extends SimpleBeanInfo {
- Class<MockFooLabel> clazz = MockFooLabel.class;
-
- String suffix = ".MockFooLabelBeanInfo";
-
- @Override
- public BeanDescriptor getBeanDescriptor() {
- BeanDescriptor beanDesc = new BeanDescriptor(clazz);
- beanDesc.setName(beanDesc.getName() + suffix);
- return beanDesc;
- }
-
- @Override
- public PropertyDescriptor[] getPropertyDescriptors() {
- PropertyDescriptor[] pds = new PropertyDescriptor[1];
- try {
- PropertyDescriptor pd = new PropertyDescriptor("text", clazz);
- pd.setName(pd.getName() + suffix);
- pds[0] = pd;
- } catch (IntrospectionException e) {
- e.printStackTrace();
- }
- return pds;
- }
-
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockFooLiYang.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockFooLiYang.java
deleted file mode 100644
index 8590225..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockFooLiYang.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * 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.io.Serializable;
-
-/**
- * This class is used for Introspector test.
- */
-public class MockFooLiYang extends MockFooStop implements Serializable {
-
- /**
- * Comment for <code>serialVersionUID</code>
- */
- private static final long serialVersionUID = 1L;
-
- private String name;
-
- /**
- * @return Returns the name.
- */
- public String getName() {
- return name;
- }
-
- /**
- * @param name
- * The name to set.
- */
- public void setName(String name) {
- this.name = name;
- }
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockFooStop.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockFooStop.java
deleted file mode 100644
index 3829433..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockFooStop.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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.io.Serializable;
-
-/**
- * test Introspector
- */
-public class MockFooStop implements Serializable {
- private static final long serialVersionUID = -3007105946173048551L;
-
- private String label;
-
- public String getLabel() {
- return label;
- }
-
- public void setLabel(String label) {
- this.label = label;
- }
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockFooSub.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockFooSub.java
deleted file mode 100644
index a0a6b29..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockFooSub.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 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;
-
-/**
- * test Introspector
- */
-public class MockFooSub extends MockFooChild {
-
- private static final long serialVersionUID = -6190124759553440748L;
-
- private String text;
-
- public String getText() {
- return text;
- }
-
- public void setText(String text) {
- this.text = text;
- }
-
- @Override
- public void addMockPropertyChangeListener(MockPropertyChangeListener listener) {
-
- }
-
- @Override
- public void removeMockPropertyChangeListener(MockPropertyChangeListener listener) {
-
- }
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockFooSubBeanInfo.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockFooSubBeanInfo.java
deleted file mode 100644
index 4d0f418..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockFooSubBeanInfo.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * 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.MethodDescriptor;
-import java.beans.PropertyDescriptor;
-import java.beans.SimpleBeanInfo;
-import java.lang.reflect.Method;
-
-/**
- * test Introspector
- */
-public class MockFooSubBeanInfo extends SimpleBeanInfo {
-
- Class<MockFooSub> clazz = MockFooSub.class;
-
- String suffix = ".MockFooSubBeanInfo";
-
- @Override
- public PropertyDescriptor[] getPropertyDescriptors() {
- PropertyDescriptor[] pds = new PropertyDescriptor[1];
- try {
- PropertyDescriptor pd = new PropertyDescriptor("text", clazz);
- pd.setName(pd.getName() + suffix);
- pds[0] = pd;
- } catch (IntrospectionException e) {
- e.printStackTrace();
- }
- return pds;
- }
-
- @Override
- public MethodDescriptor[] getMethodDescriptors() {
- MethodDescriptor[] mds = new MethodDescriptor[2];
- try {
- Method getMethod = clazz.getMethod("getText", (Class[]) null);
- Method setMethod = clazz.getMethod("setText",
- new Class[] { String.class });
- mds[0] = new MethodDescriptor(getMethod);
- mds[0].setName(mds[0].getName() + suffix);
-
- mds[1] = new MethodDescriptor(setMethod);
- mds[1].setName(mds[1].getName() + suffix);
-
- } catch (SecurityException e) {
- e.printStackTrace();
- } catch (NoSuchMethodException e) {
- e.printStackTrace();
- }
- return mds;
- }
-
- @Override
- public EventSetDescriptor[] getEventSetDescriptors() {
- EventSetDescriptor[] esds = new EventSetDescriptor[1];
- try {
- EventSetDescriptor esd = new EventSetDescriptor(clazz,
- "mockPropertyChange", MockPropertyChangeListener.class,
- "mockPropertyChange");
- esd.setName(esd.getName() + suffix);
- esds[0] = esd;
- } catch (IntrospectionException e) {
- e.printStackTrace();
- }
- return esds;
- }
-
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockFooSubSub.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockFooSubSub.java
deleted file mode 100644
index 1f47406..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockFooSubSub.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * 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;
-
-/**
- * test Introspector
- */
-public class MockFooSubSub extends MockFooSub {
-
- private static final long serialVersionUID = 2473405304400125998L;
-
- private int flags;
-
- public int getFlags() {
- return flags;
- }
-
- public void setFlags(int flags) {
- this.flags = flags;
- }
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockInterface.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockInterface.java
deleted file mode 100644
index b9382a5..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockInterface.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * 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);
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockInterfaceBeanInfo.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockInterfaceBeanInfo.java
deleted file mode 100644
index 7e7e5a1..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockInterfaceBeanInfo.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * 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.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};
- }
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockJavaBean.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockJavaBean.java
deleted file mode 100644
index 3a762cf..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockJavaBean.java
+++ /dev/null
@@ -1,377 +0,0 @@
-/*
- * 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.io.Serializable;
-
-public class MockJavaBean implements Serializable {
- /**
- * Comment for <code>serialVersionUID</code>
- */
- private static final long serialVersionUID = 1L;
-
- private String beanName;
-
- private String propertyOne;
-
- private Integer propertyTwo;
-
- private String propertyThree;
-
- private String[] propertyFour;
-
- private String[] propertyFive;
-
- private Integer[] propertySix;
-
- private String[] propertySeven;
-
- private String protectedProp;
-
- private String propertyWithoutSet;
-
- private boolean booleanProperty;
-
- @SuppressWarnings("unused")
- private int propertyWithoutGet;
-
- private String propertyWithDifferentGetSet;
-
- private int propertyWithInvalidGet;
-
- private int propertyWithoutPublicGet;
-
- private int propertyWithGet1Param;
-
- private int propertyWithIs1Param;
-
- private int propertyWithSet2Param;
-
- private int propertyWithIsGet;
-
- @SuppressWarnings("unused")
- private int propertyWithVoidGet;
-
- public Void getPropertyWithVoidGet() {
- return null;
- }
-
- public void setPropertyWithVoidGet(int propertyWithVoidGet) {
- this.propertyWithVoidGet = propertyWithVoidGet;
- }
-
- public MockJavaBean() {
- this.beanName = getClass().getName();
- }
-
- public MockJavaBean(String beanName) {
- this.beanName = beanName;
- }
-
- public String getXXX(){
- return propertyThree;
- }
-
- public String getPropertyWithDifferentGetSet(){
- return propertyWithDifferentGetSet;
- }
-
- public void setPropertyWithDifferentGetSet(int value){
- this.propertyWithDifferentGetSet = String.valueOf(value);
- }
-
- public String getPropertyWithoutSet(){
- return propertyWithoutSet;
- }
-
- public void setPropertyWithoutGet(int value){
- this.propertyWithoutGet = value;
- }
-
- public String getPropertyWithInvalidGet(){
- return String.valueOf(propertyWithInvalidGet);
- }
-
- public void setPropertyWithInvalidGet(String value){
- propertyWithInvalidGet = Integer.valueOf(value);
- }
-
- /**
- * @return Returns the beanName.
- */
- public String getBeanName() {
- return beanName;
- }
-
- /**
- * @param beanName
- * The beanName to set.
- */
- public void setBeanName(String beanName) {
- this.beanName = beanName;
- }
-
- /**
- * @return Returns the propertyOne.
- */
- public String getPropertyOne() {
- return propertyOne;
- }
-
- /**
- * @param propertyOne
- * The propertyOne to set.
- */
- public void setPropertyOne(String propertyOne) {
- this.propertyOne = propertyOne;
- }
-
- /**
- * @return Returns the propertyTwo.
- */
- public Integer getPropertyTwo() {
- return propertyTwo;
- }
-
- /**
- * @param propertyTwo
- * The propertyTwo to set.
- */
- public void setPropertyTwo(Integer propertyTwo) {
- this.propertyTwo = propertyTwo;
- }
-
- public String invalidGetMethod(String arg) {
- // for PropertyDescriptorTest: with args
- return arg;
- }
-
- public void invalidGetMethod() {
- // for PropertyDescriptorTest
- // return void
- }
-
- /**
- * @return Returns the propertyThree.
- */
- public String getPropertyThree() {
- return propertyThree;
- }
-
- /**
- * @param propertyThree
- * The propertyThree to set.
- */
- public void setPropertyThree(String propertyThree) {
- this.propertyThree = propertyThree;
- }
-
- /**
- * @return Returns the propertyFour.
- */
- public String[] getPropertyFour() {
- return propertyFour;
- }
-
- /**
- * @param propertyFour
- * The propertyFour to set.
- */
- public void setPropertyFour(String[] propertyFour) {
- this.propertyFour = propertyFour;
- }
-
- public String getPropertyFour(int i) {
- return getPropertyFour()[i];
- }
-
- public String getPropertyFive(int i, int j) {
- return getPropertyFour()[i];
- }
-
- public void getPropertyFourInvalid(int i) {
-
- }
-
- public void setPropertyFour(int i, String value) {
- propertyFour[i] = value;
- }
-
- public void setPropertyFour(int i, int value) {
- propertyFour[i] = "";
- }
-
- public int setPropertyFourInvalid(int i, String value) {
- return i;
- }
-
- public void setPropertyFourInvalid2(String i, String value) {
- // return i;
- }
-
- /**
- * @return Returns the propertyFive.
- */
- public String[] getPropertyFive() {
- return propertyFive;
- }
-
- /**
- * @param propertyFive
- * The propertyFive to set.
- */
- public void setPropertyFive(String[] propertyFive) {
- this.propertyFive = propertyFive;
- }
-
- public String getPropertyFive(int i) {
- return getPropertyFive()[i];
- }
-
- public void setPropertyFive(int i, String value) {
- propertyFive[i] = value;
- }
-
- /**
- * @return Returns the protectedProp.
- */
- protected String getProtectedProp() {
- return protectedProp;
- }
-
- /**
- * @param protectedProp
- * The protectedProp to set.
- */
- protected void setProtectedProp(String protectedProp) {
- this.protectedProp = protectedProp;
- }
-
- /**
- * @return Returns the propertySix.
- */
- public Integer[] getPropertySix() {
- return propertySix;
- }
-
- public Integer getPropertySix(int i) {
- return null;
- }
-
- /**
- * @param propertySix
- * The propertySix to set.
- */
- public void setPropertySix(Integer[] propertySix) {
- this.propertySix = propertySix;
- }
-
- public void setPropertySix(int i, Integer value) {
-
- }
-
- public void addMockPropertyChangeListener(
- MockPropertyChangeListener listener) {
-
- }
-
- public void removeMockPropertyChangeListener(
- MockPropertyChangeListener listener) {
-
- }
-
- int isPropertyWithoutPublicGet() {
- return propertyWithoutPublicGet;
- }
-
- int getPropertyWithoutPublicGet() {
- return propertyWithoutPublicGet;
- }
-
- public void setPropertyWithoutPublicGet(int propertyWithoutPublicGet) {
- this.propertyWithoutPublicGet = propertyWithoutPublicGet;
- }
-
- public int isPropertyWithIs1Param(int i) {
- return propertyWithIs1Param;
- }
-
- public int getPropertyWithIs1Param() {
- return propertyWithIs1Param;
- }
-
- public void setPropertyWithIs1Param(int value) {
- this.propertyWithIs1Param = value;
- }
-
- public int getPropertyWithGet1Param(int i) {
- return propertyWithGet1Param;
- }
-
- public void setPropertyWithGet1Param(int propertyWithGet1Param) {
- this.propertyWithGet1Param = propertyWithGet1Param;
- }
-
- public int getPropertyWithSet2Param() {
- return propertyWithSet2Param;
- }
-
- public void setPropertyWithSet2Param(int propertyWithSet2Param, int j) {
- this.propertyWithSet2Param = propertyWithSet2Param;
- }
-
- public int isPropertyWithIsGet() {
- return propertyWithIsGet;
- }
-
- public int getPropertyWithIsGet() {
- return propertyWithIsGet;
- }
-
- public void setPropertyWithIsGet(int propertyWithIsGet) {
- this.propertyWithIsGet = propertyWithIsGet;
- }
-
- public boolean isBooleanProperty() {
- return booleanProperty;
- }
-
- public boolean getBooleanProperty() {
- return booleanProperty;
- }
-
- public void setbooleanProperty(boolean booleanProperty) {
- this.booleanProperty = booleanProperty;
- }
-
- public Integer getPropertySeven(int i){
- return Integer.valueOf(propertySeven[i]);
- }
-
- public void setPropertySeven(int i, Integer I){
- propertySeven[i] = String.valueOf(I);
- }
-
- public String[] getPropertySeven() {
- return propertySeven;
- }
-
- public void setPropertySeven(String[] propertySeven) {
- this.propertySeven = propertySeven;
- }
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockNullSubClass.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockNullSubClass.java
deleted file mode 100644
index b3f2f58..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockNullSubClass.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * 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 MockNullSubClass extends MockNullSuperClass{
-
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockNullSubClassBeanInfo.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockNullSubClassBeanInfo.java
deleted file mode 100644
index 1083da0..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockNullSubClassBeanInfo.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * 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.MethodDescriptor;
-import java.beans.PropertyDescriptor;
-import java.beans.SimpleBeanInfo;
-
-public class MockNullSubClassBeanInfo extends SimpleBeanInfo{
- public PropertyDescriptor[] getPropertyDescriptors(){
- return null;
- }
-
- public MethodDescriptor[] getMethodDescriptors(){
- return null;
- }
-
- public EventSetDescriptor[] getEventSetDescriptors(){
- return null;
- }
-
- public int getDefaultEventIndex(){
- return Integer.MIN_VALUE;
- }
-
- public int getDefaultPropertyIndex(){
- return Integer.MIN_VALUE;
- }
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockNullSuperClass.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockNullSuperClass.java
deleted file mode 100644
index 893fe94..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockNullSuperClass.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * 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 MockNullSuperClass {
-
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockNullSuperClassBeanInfo.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockNullSuperClassBeanInfo.java
deleted file mode 100644
index 3d140a0..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockNullSuperClassBeanInfo.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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.MethodDescriptor;
-import java.beans.PropertyDescriptor;
-import java.beans.SimpleBeanInfo;
-
-public class MockNullSuperClassBeanInfo extends SimpleBeanInfo{
- public PropertyDescriptor[] getPropertyDescriptors(){
- return null;
- }
-
- public MethodDescriptor[] getMethodDescriptors(){
- return null;
- }
-
- public EventSetDescriptor[] getEventSetDescriptors(){
- return null;
- }
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockSimpleBeanInfo.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockSimpleBeanInfo.java
deleted file mode 100644
index 71eefaf..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockSimpleBeanInfo.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * 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.SimpleBeanInfo;
-
-/**
- * test SimpleBeanInfo
- */
-public class MockSimpleBeanInfo extends SimpleBeanInfo {
-
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockSubClass.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockSubClass.java
deleted file mode 100644
index f5474d3..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockSubClass.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * 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{
-
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockSubClassBeanInfo.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockSubClassBeanInfo.java
deleted file mode 100644
index 50a8016..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockSubClassBeanInfo.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * 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.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};
- }
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockSuperClass.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockSuperClass.java
deleted file mode 100644
index c52a066..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockSuperClass.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * 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) {
- }
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockSuperClassBeanInfo.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockSuperClassBeanInfo.java
deleted file mode 100644
index a6b5edd..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockSuperClassBeanInfo.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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 };
- }
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockTreeMapClass.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockTreeMapClass.java
deleted file mode 100644
index e4828ea..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockTreeMapClass.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * 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.util.TreeMap;
-
-public class MockTreeMapClass extends TreeMap {
-
- @Override
- public Object get(Object key) {
- Object result = super.get(key);
- if (result == null) {
- result = new TreeMap();
- put(key, result);
- }
- return result;
- }
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/NonSerializedVCListener.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/NonSerializedVCListener.java
deleted file mode 100644
index 950ed90..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/NonSerializedVCListener.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * 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.PropertyChangeEvent;
-import java.beans.PropertyVetoException;
-import java.beans.VetoableChangeListener;
-
-/**
- * test VetoableChangeSupport
- */
-public class NonSerializedVCListener implements VetoableChangeListener {
-
- String propertyName;
-
- public NonSerializedVCListener(String propertyName) {
- this.propertyName = propertyName;
- }
-
- @Override
- public boolean equals(Object o) {
- if (!(o instanceof NonSerializedVCListener)) {
- return false;
- }
-
- NonSerializedVCListener other = (NonSerializedVCListener) o;
- return (this.propertyName == null ? other.propertyName == null
- : this.propertyName.equals(other.propertyName));
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.VetoableChangeListener#vetoableChange(java.beans.PropertyChangeEvent)
- */
- public void vetoableChange(PropertyChangeEvent event)
- throws PropertyVetoException {
- // TODO Auto-generated method stub
-
- }
-
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/NotExistBean.ser b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/NotExistBean.ser
deleted file mode 100644
index 5c7aa2b..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/NotExistBean.ser
+++ /dev/null
Binary files differ
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/SerializedVCListener.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/SerializedVCListener.java
deleted file mode 100644
index 3f61f6b..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/SerializedVCListener.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * 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.PropertyChangeEvent;
-import java.beans.PropertyVetoException;
-import java.beans.VetoableChangeListener;
-import java.io.Serializable;
-
-/**
- * test VetoableChangeSupport
- */
-public class SerializedVCListener implements Serializable, VetoableChangeListener {
-
- private static final long serialVersionUID = -3110366593959548316L;
-
- String propertyName;
-
- String name;
-
- public SerializedVCListener(String propertyName) {
- this.propertyName = propertyName;
- }
-
- @Override
- public boolean equals(Object o) {
- if (!(o instanceof SerializedVCListener)) {
- return false;
- }
-
- SerializedVCListener other = (SerializedVCListener) o;
- return ((this.name == null ? other.name == null : this.name.equals(other.name)) && (this.propertyName == null ? other.propertyName == null
- : this.propertyName.equals(other.propertyName)));
- }
-
- public void vetoableChange(PropertyChangeEvent event) throws PropertyVetoException {
-
- }
-
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/WrongSerBean.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/WrongSerBean.java
deleted file mode 100644
index de361da..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/WrongSerBean.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * 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.io.Serializable;
-
-/**
- * A bean class which .ser file is wrong.
- * Used for BeansTest.test_instantiate_withWrongSer()
- */
-public class WrongSerBean implements Serializable{
- private int intField;
- private char charField;
- private String str;
-
- public WrongSerBean(){
- super();
- }
-
- public WrongSerBean(int intField, char charField){
- this.intField = intField;
- this.charField = charField;
- this.str = "test";
- }
-
- public char getCharField() {
- return charField;
- }
-
- public void setCharField(char charField) {
- this.charField = charField;
- }
-
- public int getIntField() {
- return intField;
- }
-
- public void setIntField(int intField) {
- this.intField = intField;
- }
-
-
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/WrongSerBean.ser b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/WrongSerBean.ser
deleted file mode 100644
index 4c0f7ad..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/WrongSerBean.ser
+++ /dev/null
Binary files differ
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/WrongSerBean2.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/WrongSerBean2.java
deleted file mode 100644
index 2b8e49b..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/WrongSerBean2.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * 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 WrongSerBean2 {
-
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/homonymy/mocksubject1/MockHomonymySubject.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/homonymy/mocksubject1/MockHomonymySubject.java
deleted file mode 100644
index 27856d5..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/homonymy/mocksubject1/MockHomonymySubject.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * 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.homonymy.mocksubject1;
-
-public class MockHomonymySubject implements java.io.Serializable {
-
- private static final long serialVersionUID = -5670959173127764297L;
-
- public MockHomonymySubject() {
- }
-
- public int getFoo() {
- return -1;
- }
-
- public void setFoo(int foo) {
- }
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/homonymy/mocksubject1/info/MockHomonymySubjectBeanInfo.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/homonymy/mocksubject1/info/MockHomonymySubjectBeanInfo.java
deleted file mode 100644
index 6a92f4f..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/homonymy/mocksubject1/info/MockHomonymySubjectBeanInfo.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * 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.homonymy.mocksubject1.info;
-
-import java.beans.BeanDescriptor;
-import java.beans.SimpleBeanInfo;
-
-public class MockHomonymySubjectBeanInfo extends SimpleBeanInfo {
-
- private BeanDescriptor beanDesc = new BeanDescriptor(
- org.apache.harmony.beans.tests.support.mock.homonymy.mocksubject1.MockHomonymySubject.class);;
-
- public MockHomonymySubjectBeanInfo() {
- beanDesc.setName("mocksubject1");
- }
-
- public BeanDescriptor getBeanDescriptor() {
- return beanDesc;
- }
-
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/homonymy/mocksubject2/MockHomonymySubject.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/homonymy/mocksubject2/MockHomonymySubject.java
deleted file mode 100644
index af7ace0..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/homonymy/mocksubject2/MockHomonymySubject.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * 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.homonymy.mocksubject2;
-
-public class MockHomonymySubject implements java.io.Serializable {
-
- private static final long serialVersionUID = -8789259604314388286L;
-
- public MockHomonymySubject() {
- }
-
- public int getFoo() {
- return -1;
- }
-
- public void setFoo(int foo) {
- }
-}
diff --git a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/homonymy/mocksubject2/info/MockHomonymySubjectBeanInfo.java b/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/homonymy/mocksubject2/info/MockHomonymySubjectBeanInfo.java
deleted file mode 100644
index 48ccd1f..0000000
--- a/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/homonymy/mocksubject2/info/MockHomonymySubjectBeanInfo.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * 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.homonymy.mocksubject2.info;
-
-import java.beans.BeanDescriptor;
-import java.beans.SimpleBeanInfo;
-
-public class MockHomonymySubjectBeanInfo extends SimpleBeanInfo {
-
- private BeanDescriptor beanDesc = new BeanDescriptor(
- org.apache.harmony.beans.tests.support.mock.homonymy.mocksubject2.MockHomonymySubject.class);;
-
- public MockHomonymySubjectBeanInfo() {
- beanDesc.setName("mocksubject2");
- }
-
- public BeanDescriptor getBeanDescriptor() {
- return beanDesc;
- }
-
-}