01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: package org.apache.harmony.beans.tests.support.mock;
19:
20: import java.beans.EventSetDescriptor;
21: import java.beans.IntrospectionException;
22: import java.beans.MethodDescriptor;
23: import java.beans.PropertyDescriptor;
24: import java.beans.SimpleBeanInfo;
25: import java.lang.reflect.Method;
26:
27: /**
28: * test Introspector
29: */
30: public class MockFooSubBeanInfo extends SimpleBeanInfo {
31:
32: Class<MockFooSub> clazz = MockFooSub.class;
33:
34: String suffix = ".MockFooSubBeanInfo";
35:
36: @Override
37: public PropertyDescriptor[] getPropertyDescriptors() {
38: PropertyDescriptor[] pds = new PropertyDescriptor[1];
39: try {
40: PropertyDescriptor pd = new PropertyDescriptor("text",
41: clazz);
42: pd.setName(pd.getName() + suffix);
43: pds[0] = pd;
44: } catch (IntrospectionException e) {
45: e.printStackTrace();
46: }
47: return pds;
48: }
49:
50: @Override
51: public MethodDescriptor[] getMethodDescriptors() {
52: MethodDescriptor[] mds = new MethodDescriptor[2];
53: try {
54: Method getMethod = clazz.getMethod("getText",
55: (Class[]) null);
56: Method setMethod = clazz.getMethod("setText",
57: new Class[] { String.class });
58: mds[0] = new MethodDescriptor(getMethod);
59: mds[0].setName(mds[0].getName() + suffix);
60:
61: mds[1] = new MethodDescriptor(setMethod);
62: mds[1].setName(mds[1].getName() + suffix);
63:
64: } catch (SecurityException e) {
65: e.printStackTrace();
66: } catch (NoSuchMethodException e) {
67: e.printStackTrace();
68: }
69: return mds;
70: }
71:
72: @Override
73: public EventSetDescriptor[] getEventSetDescriptors() {
74: EventSetDescriptor[] esds = new EventSetDescriptor[1];
75: try {
76: EventSetDescriptor esd = new EventSetDescriptor(clazz,
77: "mockPropertyChange",
78: MockPropertyChangeListener.class,
79: "mockPropertyChange");
80: esd.setName(esd.getName() + suffix);
81: esds[0] = esd;
82: } catch (IntrospectionException e) {
83: e.printStackTrace();
84: }
85: return esds;
86: }
87:
88: }
|