public class BeanShellAssertionGui extends AbstractAssertionGui { private JCheckBox resetInterpreter;// reset the bsh.Interpreter before each execution private JTextField filename;// script file name (if present) private JTextField parameters;// parameters to pass to script file (or script) private JTextArea scriptField;// script area public BeanShellAssertionGui() { init(); } public void configure(TestElement element) { scriptField.setText(element.getPropertyAsString(BeanShellAssertion.SCRIPT)); filename.setText(element.getPropertyAsString(BeanShellAssertion.FILENAME)); parameters.setText(element.getPropertyAsString(BeanShellAssertion.PARAMETERS)); resetInterpreter.setSelected(element.getPropertyAsBoolean(BeanShellAssertion.RESET_INTERPRETER)); super.configure(element); } public TestElement createTestElement() { BeanShellAssertion sampler = new BeanShellAssertion(); modifyTestElement(sampler); return sampler; } /** * Modifies a given TestElement to mirror the data in the gui components. * * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement) */ public void modifyTestElement(TestElement te) { te.clear(); this.configureTestElement(te); te.setProperty(BeanShellAssertion.SCRIPT, scriptField.getText()); te.setProperty(BeanShellAssertion.FILENAME, filename.getText()); te.setProperty(BeanShellAssertion.PARAMETERS, parameters.getText()); te.setProperty(new BooleanProperty(BeanShellAssertion.RESET_INTERPRETER, resetInterpreter.isSelected())); } public String getLabelResource() { return "bsh_assertion_title"; // $NON-NLS-1$ } private JPanel createFilenamePanel()// TODO ought to be a FileChooser ... { JLabel label = new JLabel(JMeterUtils.getResString("bsh_script_file")); //$NON-NLS-1$ filename = new JTextField(10); filename.setName(BeanShellAssertion.FILENAME); label.setLabelFor(filename); JPanel filenamePanel = new JPanel(new BorderLayout(5, 0)); filenamePanel.add(label, BorderLayout.WEST); filenamePanel.add(filename, BorderLayout.CENTER); return filenamePanel; } private JPanel createResetPanel() { resetInterpreter = new JCheckBox(JMeterUtils.getResString("bsh_script_reset_interpreter")); // $NON-NLS-1$ resetInterpreter.setName(BeanShellAssertion.PARAMETERS); JPanel resetInterpreterPanel = new JPanel(new BorderLayout()); resetInterpreterPanel.add(resetInterpreter, BorderLayout.WEST); return resetInterpreterPanel; } private JPanel createParameterPanel() { JLabel label = new JLabel(JMeterUtils.getResString("bsh_script_parameters")); //$NON-NLS-1$ parameters = new JTextField(10); parameters.setName(BeanShellAssertion.PARAMETERS); label.setLabelFor(parameters); JPanel parameterPanel = new JPanel(new BorderLayout(5, 0)); parameterPanel.add(label, BorderLayout.WEST); parameterPanel.add(parameters, BorderLayout.CENTER); return parameterPanel; } private void init() { setLayout(new BorderLayout(0, 5)); setBorder(makeBorder()); Box box = Box.createVerticalBox(); box.add(makeTitlePanel()); box.add(createResetPanel()); box.add(createParameterPanel()); box.add(createFilenamePanel()); add(box, BorderLayout.NORTH); JPanel panel = createScriptPanel(); add(panel, BorderLayout.CENTER); // Don't let the input field shrink too much add(Box.createVerticalStrut(panel.getPreferredSize().height), BorderLayout.WEST); } private JPanel createScriptPanel() { scriptField = new JTextArea(); scriptField.setRows(4); scriptField.setLineWrap(true); scriptField.setWrapStyleWord(true); JLabel label = new JLabel(JMeterUtils.getResString("bsh_assertion_script")); //$NON-NLS-1$ label.setLabelFor(scriptField); JPanel panel = new JPanel(new BorderLayout()); panel.add(label, BorderLayout.NORTH); panel.add(new JScrollPane(scriptField), BorderLayout.CENTER); JTextArea explain = new JTextArea(JMeterUtils.getResString("bsh_assertion_script_variables")); //$NON-NLS-1$ explain.setLineWrap(true); explain.setEditable(false); explain.setBackground(this.getBackground()); panel.add(explain, BorderLayout.SOUTH); return panel; } public void clearGui() { super.clearGui(); filename.setText(""); // $NON-NLS-1$ parameters.setText(""); // $NON-NLS-1$ scriptField.setText(""); // $NON-NLS-1$ resetInterpreter.setSelected(false);
public class BeanShellSamplerGui extends AbstractSamplerGui { private JCheckBox resetInterpreter;// reset the bsh.Interpreter before each execution private JTextField filename;// script file name (if present) private JTextField parameters;// parameters to pass to script file (or script) private JTextArea scriptField;// script area public BeanShellSamplerGui() { init(); } public void configure(TestElement element) { scriptField.setText(element.getPropertyAsString(BeanShellSampler.SCRIPT)); filename.setText(element.getPropertyAsString(BeanShellSampler.FILENAME)); parameters.setText(element.getPropertyAsString(BeanShellSampler.PARAMETERS)); resetInterpreter.setSelected(element.getPropertyAsBoolean(BeanShellSampler.RESET_INTERPRETER)); super.configure(element); } public TestElement createTestElement() { BeanShellSampler sampler = new BeanShellSampler(); modifyTestElement(sampler); return sampler; } /** * Modifies a given TestElement to mirror the data in the gui components. * * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement) */ public void modifyTestElement(TestElement te) { te.clear(); this.configureTestElement(te); te.setProperty(BeanShellSampler.SCRIPT, scriptField.getText()); te.setProperty(BeanShellSampler.FILENAME, filename.getText()); te.setProperty(BeanShellSampler.PARAMETERS, parameters.getText()); te.setProperty(new BooleanProperty(BeanShellSampler.RESET_INTERPRETER, resetInterpreter.isSelected())); } /** * Implements JMeterGUIComponent.clearGui */ public void clearGui() { super.clearGui(); filename.setText(""); //$NON-NLS-1$ parameters.setText(""); //$NON-NLS-1$ scriptField.setText(""); //$NON-NLS-1$ resetInterpreter.setSelected(false); } public String getLabelResource() { return "bsh_sampler_title"; // $NON-NLS-1$ } private JPanel createFilenamePanel()// TODO ought to be a FileChooser ... { JLabel label = new JLabel(JMeterUtils.getResString("bsh_script_file")); // $NON-NLS-1$ filename = new JTextField(10); filename.setName(BeanShellSampler.FILENAME); label.setLabelFor(filename); JPanel filenamePanel = new JPanel(new BorderLayout(5, 0)); filenamePanel.add(label, BorderLayout.WEST); filenamePanel.add(filename, BorderLayout.CENTER); return filenamePanel; } private JPanel createParameterPanel() { JLabel label = new JLabel(JMeterUtils.getResString("bsh_script_parameters")); // $NON-NLS-1$ parameters = new JTextField(10); parameters.setName(BeanShellSampler.PARAMETERS); label.setLabelFor(parameters); JPanel parameterPanel = new JPanel(new BorderLayout(5, 0)); parameterPanel.add(label, BorderLayout.WEST); parameterPanel.add(parameters, BorderLayout.CENTER); return parameterPanel; } private JPanel createResetPanel() { resetInterpreter = new JCheckBox(JMeterUtils.getResString("bsh_script_reset_interpreter")); // $NON-NLS-1$ resetInterpreter.setName(BeanShellSampler.PARAMETERS); JPanel resetInterpreterPanel = new JPanel(new BorderLayout()); resetInterpreterPanel.add(resetInterpreter, BorderLayout.WEST); return resetInterpreterPanel; } private void init() { setLayout(new BorderLayout(0, 5)); setBorder(makeBorder()); Box box = Box.createVerticalBox(); box.add(makeTitlePanel()); box.add(createResetPanel()); box.add(createParameterPanel()); box.add(createFilenamePanel()); add(box, BorderLayout.NORTH); JPanel panel = createScriptPanel(); add(panel, BorderLayout.CENTER); // Don't let the input field shrink too much add(Box.createVerticalStrut(panel.getPreferredSize().height), BorderLayout.WEST); } private JPanel createScriptPanel() { scriptField = new JTextArea(); scriptField.setRows(4); scriptField.setLineWrap(true); scriptField.setWrapStyleWord(true); JLabel label = new JLabel(JMeterUtils.getResString("bsh_script")); // $NON-NLS-1$ label.setLabelFor(scriptField); JPanel panel = new JPanel(new BorderLayout()); panel.add(label, BorderLayout.NORTH); panel.add(new JScrollPane(scriptField), BorderLayout.CENTER); JTextArea explain = new JTextArea(JMeterUtils.getResString("bsh_script_variables")); //$NON-NLS-1$ explain.setLineWrap(true); explain.setEditable(false); explain.setBackground(this.getBackground()); panel.add(explain, BorderLayout.SOUTH); return panel;
Clone fragments detected by clone detection tool
File path: /jakarta-jmeter-2.3.2/src/org/apache/jmeter/assertions/gui/BeanShellAssertionGui.java File path: /jakarta-jmeter-2.3.2/src/org/apache/jmeter/protocol/java/control/gui/BeanShellSamplerGui.java
Method name: Method name:
Number of AST nodes: 0 Number of AST nodes: 0
1
public class BeanShellAssertionGui extends AbstractAssertionGui {
1
public class BeanShellSamplerGui extends AbstractSamplerGui {
2
    
2
    private JCheckBox resetInterpreter;// reset the bsh.Interpreter before each execution
3
    private JCheckBox resetInterpreter;// reset the bsh.Interpreter before each execution
3
	private JTextField filename;// script file name (if present)
4
	private JTextField filename;// script file name (if present)
4
	private JTextField parameters;// parameters to pass to script file (or script)
5
	private JTextField parameters;// parameters to pass to script file (or script)
5
	private JTextArea scriptField;// script area
6
	private JTextArea scriptField;// script area
6
	public BeanShellAssertionGui() {
7
	public BeanShellSamplerGui() {
7
		init();
8
		init();
8
	}
9
	}
9
	public void configure(TestElement element) {
10
	public void configure(TestElement element) {
10
		scriptField.setText(element.getPropertyAsString(BeanShellAssertion.SCRIPT));
11
		scriptField.setText(element.getPropertyAsString(BeanShellSampler.SCRIPT));
11
		filename.setText(element.getPropertyAsString(BeanShellAssertion.FILENAME));
12
		filename.setText(element.getPropertyAsString(BeanShellSampler.FILENAME));
12
		parameters.setText(element.getPropertyAsString(BeanShellAssertion.PARAMETERS));
13
		parameters.setText(element.getPropertyAsString(BeanShellSampler.PARAMETERS));
13
        resetInterpreter.setSelected(element.getPropertyAsBoolean(BeanShellAssertion.RESET_INTERPRETER));
14
		resetInterpreter.setSelected(element.getPropertyAsBoolean(BeanShellSampler.RESET_INTERPRETER));
14
		super.configure(element);
15
		super.configure(element);
15
	}
16
	}
16
	public TestElement createTestElement() {
17
	public TestElement createTestElement() {
17
		BeanShellAssertion sampler = new BeanShellAssertion();
18
		BeanShellSampler sampler = new BeanShellSampler();
18
		modifyTestElement(sampler);
19
		modifyTestElement(sampler);
19
		return sampler;
20
		return sampler;
20
	}
21
	}
21
	/**
22
	/**
22
	 * Modifies a given TestElement to mirror the data in the gui components.
23
	 * Modifies a given TestElement to mirror the data in the gui components.
23
	 * 
24
	 * 
24
	 * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement)
25
	 * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement)
25
	 */
26
	 */
26
	public void modifyTestElement(TestElement te) {
27
	public void modifyTestElement(TestElement te) {
27
		te.clear();
28
		te.clear();
28
		this.configureTestElement(te);
29
		this.configureTestElement(te);
29
		te.setProperty(BeanShellAssertion.SCRIPT, scriptField.getText());
30
		te.setProperty(BeanShellSampler.SCRIPT, scriptField.getText());
30
		te.setProperty(BeanShellAssertion.FILENAME, filename.getText());
31
		te.setProperty(BeanShellSampler.FILENAME, filename.getText());
31
		te.setProperty(BeanShellAssertion.PARAMETERS, parameters.getText());
32
		te.setProperty(BeanShellSampler.PARAMETERS, parameters.getText());
32
        te.setProperty(new BooleanProperty(BeanShellAssertion.RESET_INTERPRETER, resetInterpreter.isSelected()));
33
		te.setProperty(new BooleanProperty(BeanShellSampler.RESET_INTERPRETER, resetInterpreter.isSelected()));
33
	}
34
	}
35
    
36
    /**
37
     * Implements JMeterGUIComponent.clearGui
38
     */
39
    public void clearGui() {
40
        super.clearGui();
41
        
42
        filename.setText(""); //$NON-NLS-1$
43
        parameters.setText(""); //$NON-NLS-1$
44
        scriptField.setText(""); //$NON-NLS-1$
45
        resetInterpreter.setSelected(false);
46
    }    
34
	public String getLabelResource() {
47
	public String getLabelResource() {
35
		return "bsh_assertion_title"; // $NON-NLS-1$
48
		return "bsh_sampler_title"; // $NON-NLS-1$
36
	}
49
	}
37
	private JPanel createFilenamePanel()// TODO ought to be a FileChooser ...
50
	private JPanel createFilenamePanel()// TODO ought to be a FileChooser ...
38
	{
51
	{
39
		JLabel label = new JLabel(JMeterUtils.getResString("bsh_script_file")); //$NON-NLS-1$
52
		JLabel label = new JLabel(JMeterUtils.getResString("bsh_script_file")); // $NON-NLS-1$
40
		filename = new JTextField(10);
53
		filename = new JTextField(10);
41
		filename.setName(BeanShellAssertion.FILENAME);
54
		filename.setName(BeanShellSampler.FILENAME);
42
		label.setLabelFor(filename);
55
		label.setLabelFor(filename);
43
		JPanel filenamePanel = new JPanel(new BorderLayout(5, 0));
56
		JPanel filenamePanel = new JPanel(new BorderLayout(5, 0));
44
		filenamePanel.add(label, BorderLayout.WEST);
57
		filenamePanel.add(label, BorderLayout.WEST);
45
		filenamePanel.add(filename, BorderLayout.CENTER);
58
		filenamePanel.add(filename, BorderLayout.CENTER);
46
		return filenamePanel;
59
		return filenamePanel;
47
	}
60
	}
48
    private JPanel createResetPanel() {
61
	private JPanel createParameterPanel() {
49
        resetInterpreter = new JCheckBox(JMeterUtils.getResString("bsh_script_reset_interpreter")); // $NON-NLS-1$
62
		JLabel label = new JLabel(JMeterUtils.getResString("bsh_script_parameters")); // $NON-NLS-1$
50
        resetInterpr
63
		parameters = new JTextField(10);
51
eter.setName(BeanShellAssertion.PARAMETERS);
64
		parameters.setName(BeanShellSampler.PARAMETERS);
52
        JPanel resetInterpr
65
		label.setLabelFor(parameters);
53
eterPanel = new JPanel(new BorderLayout());
66
		JPanel parameterPanel = new JPanel(new BorderLayout(5, 0));
54
        resetInterpr
67
		parameterPanel.add(label, BorderLayout.WEST);
55
eterPanel.add(resetInterpreter, BorderLayout.WEST);
68
		parameterPanel.add(parameters, BorderLayout.
56
        return resetInterpr
69
CENTER);
57
eterPanel;
70
		return parameterPanel;
58
	}
71
	}
59
	private JPanel createParameterPanel() {
72
    private JPanel createResetPanel() {
60
		JLabel label = new JLabel(JMeterUtils.getResString("bsh_script_parameters")); //$NON-NLS-1$
73
        resetInterpreter = new JCheckBox(JMeterUtils.getResString("bsh_script_reset_interpreter")); // $NON-NLS-1$
61
		parameters = new JTextField(10);
62
		parameters.setName(BeanShellAssertion.PARAMETERS);
74
        resetInterpreter.setName(BeanShellSampler.PARAMETERS);
63
		label.setLabelFor(parameters);
64
		JPanel param
65
eterPanel = new JPanel(new BorderLayout(5, 0));
75
        JPanel resetInterpreterPanel = new JPanel(new BorderLayout());
66
		parameterPanel.add(label, BorderLayout.WEST);
67
		parameterPanel.add(parameters, BorderLayout.CENTER);
76
        resetInterpreterPanel.add(resetInterpreter, BorderLayout.
68
		return param
77
WEST);
69
eterPanel;
78
        return resetInterpreterPanel;
70
	}
79
    }
71
	private void init() {
80
	private void init() {
72
		setLayout(new BorderLayout(0, 5));
81
		setLayout(new BorderLayout(0, 5));
73
		setBorder(makeBorder());
82
		setBorder(makeBorder());
74
		Box box = Box.createVerticalBox();
83
		Box box = Box.createVerticalBox();
75
		box.add(makeTitlePanel());
84
		box.add(makeTitlePanel());
76
		box.add(createResetPanel());
85
		box.add(createResetPanel());
77
		box.add(createParameterPanel());
86
		box.add(createParameterPanel());
78
		box.add(createFilenamePanel());
87
		box.add(createFilenamePanel());
79
		add(box, BorderLayout.NORTH);
88
		add(box, BorderLayout.NORTH);
80
		JPanel panel = createScriptPanel();
89
		JPanel panel = createScriptPanel();
81
		add(panel, BorderLayout.CENTER);
90
		add(panel, BorderLayout.CENTER);
82
		// Don't let the input field shrink too much
91
		// Don't let the input field shrink too much
83
		add(Box.createVerticalStrut(panel.getPreferredSize().height), BorderLayout.WEST);
92
		add(Box.createVerticalStrut(panel.getPreferredSize().height), BorderLayout.WEST);
84
	}
93
	}
85
	private JPanel createScriptPanel() {
94
	private JPanel createScriptPanel() {
86
		scriptField = new JTextArea();
95
		scriptField = new JTextArea();
87
		scriptField.setRows(4);
96
		scriptField.setRows(4);
88
		scriptField.setLineWrap(true);
97
		scriptField.setLineWrap(true);
89
		scriptField.setWrapStyleWord(true);
98
		scriptField.setWrapStyleWord(true);
90
		JLabel label = new JLabel(JMeterUtils.getResString("bsh_assertion_script")); //$NON-NLS-1$
99
		JLabel label = new JLabel(JMeterUtils.getResString("bsh_script")); // $NON-NLS-1$
91
		label.setLabelFor(scriptField);
100
		label.setLabelFor(scriptField);
92
		JPanel panel = new JPanel(new BorderLayout());
101
		JPanel panel = new JPanel(new BorderLayout());
93
		panel.add(label, BorderLayout.NORTH);
102
		panel.add(label, BorderLayout.NORTH);
94
		panel.add(new JScrollPane(scriptField), BorderLayout.CENTER);
103
		panel.add(new JScrollPane(scriptField), BorderLayout.CENTER);
104
		
95
		JTextArea explain = new JTextArea(JMeterUtils.getResString("bsh_assertion_script_variables")); //$NON-NLS-1$
105
		JTextArea explain = new JTextArea(JMeterUtils.getResString("bsh_script_variables")); //$NON-NLS-1$
96
		explain.setLineWrap(true);
106
		explain.setLineWrap(true);
97
		explain.setEditable(false);
107
		explain.setEditable(false);
98
		explain.setBackground(this.getBackground());
108
		explain.setBackground(this.getBackground());
99
		panel.add(explain, BorderLayout.SOUTH);
109
		panel.add(explain, BorderLayout.SOUTH);
100
		return panel;
110
		return panel;
101
	}
111
	
102
	public void clearGui() {
103
		super.clearGui();
104
		filename.setText(""); // $NON-NLS-1$
105
		parameters.setText(""); // $NON-NLS-1$
106
		scriptField.setText(""); // $NON-NLS-1$
107
        resetInterpreter.setSelected(false);
108
	
Summary
Number of common nesting structure subtrees0
Number of refactorable cases0
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.0
Clones location
Number of node comparisons0