1
2
3
4
5
6
7
8
9
10
11
12
13 package com.eviware.soapui.model.support;
14
15 import org.apache.commons.beanutils.PropertyUtils;
16
17 import com.eviware.soapui.SoapUI;
18 import com.eviware.soapui.impl.wsdl.teststeps.WsdlTestStep;
19
20 /***
21 * TestStepProperty implementation that maps to a standard javabean property
22 *
23 * @author Ole.Matzura
24 */
25
26 public class TestStepBeanProperty extends DefaultTestStepProperty
27 {
28 public TestStepBeanProperty(String name, boolean isReadOnly, Object targetObject, String targetName, WsdlTestStep testStep )
29 {
30 super(name, isReadOnly, new BeanPropertyHandler( targetObject, targetName ), testStep );
31 }
32
33 /***
34 * PropertyHandler for setting/getting bean properties
35 *
36 * @author Ole.Matzura
37 */
38
39 public static class BeanPropertyHandler implements PropertyHandler
40 {
41 private final Object target;
42 private final String targetName;
43
44 public BeanPropertyHandler(Object targetObject, String targetName)
45 {
46 this.target = targetObject;
47 this.targetName = targetName;
48 }
49
50 public String getValue()
51 {
52 try
53 {
54 Object property = PropertyUtils.getProperty(target, targetName );
55 return property == null ? null : property.toString();
56 }
57 catch (Exception e)
58 {
59 SoapUI.logError( e );
60 return null;
61 }
62 }
63
64 public void setValue(String value)
65 {
66 try
67 {
68 PropertyUtils.setProperty( target, targetName, value );
69 }
70 catch (Exception e)
71 {
72 SoapUI.logError( e );
73 }
74 }
75 }
76
77 }