KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > jmeter > assertions > gui > MD5HexAssertionGUI


1 // $Header: /home/cvs/jakarta-jmeter/src/components/org/apache/jmeter/assertions/gui/MD5HexAssertionGUI.java,v 1.3 2004/03/05 01:32:13 sebb Exp $
2
/*
3  * Copyright 2004 The Apache Software Foundation.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * 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
19
20 /**
21  * GUI class supporting the MD5Hex assertion functionality.
22  *
23  * @version $Revision: 1.3 $ updated on $Date: 2004/03/05 01:32:13 $
24  *
25  */

26 package org.apache.jmeter.assertions.gui;
27
28 import java.awt.BorderLayout JavaDoc;
29
30 import javax.swing.BorderFactory JavaDoc;
31 import javax.swing.JLabel JavaDoc;
32 import javax.swing.JPanel JavaDoc;
33 import javax.swing.JTextField JavaDoc;
34
35 import org.apache.jmeter.assertions.MD5HexAssertion;
36 import org.apache.jmeter.gui.util.HorizontalPanel;
37 import org.apache.jmeter.testelement.TestElement;
38 import org.apache.jmeter.util.JMeterUtils;
39
40 public class MD5HexAssertionGUI extends AbstractAssertionGui {
41
42     private JTextField JavaDoc md5HexInput;
43
44     public MD5HexAssertionGUI() {
45         init();
46     }
47
48     private void init() {
49
50         setLayout(new BorderLayout JavaDoc(0, 10));
51         setBorder(makeBorder());
52
53         add(makeTitlePanel(), BorderLayout.NORTH);
54
55         JPanel JavaDoc mainPanel = new JPanel JavaDoc(new BorderLayout JavaDoc());
56
57         // USER_INPUT
58
HorizontalPanel md5HexPanel = new HorizontalPanel();
59         md5HexPanel.setBorder(
60             BorderFactory.createTitledBorder(
61                 BorderFactory.createEtchedBorder(),
62                 JMeterUtils.getResString("md5hex_assertion_md5hex_test")));
63
64         md5HexPanel.add(
65             new JLabel JavaDoc(JMeterUtils.getResString("md5hex_assertion_label")));
66
67         md5HexInput = new JTextField JavaDoc(25);
68         // md5HexInput.addFocusListener(this);
69
md5HexPanel.add(md5HexInput);
70
71         mainPanel.add(md5HexPanel, BorderLayout.NORTH);
72         add(mainPanel, BorderLayout.CENTER);
73
74     }
75
76     public void configure(TestElement el) {
77         super.configure(el);
78         MD5HexAssertion assertion = (MD5HexAssertion)el;
79         this.md5HexInput.setText(String.valueOf(assertion.getAllowedMD5Hex()));
80     }
81
82     public String JavaDoc getLabelResource() {
83         return "md5hex_assertion_title";
84     }
85
86     /*
87      * @return
88      */

89     public TestElement createTestElement() {
90
91         MD5HexAssertion el = new MD5HexAssertion();
92         modifyTestElement(el);
93         return el;
94
95     }
96
97     /*
98      * @param element
99      */

100     public void modifyTestElement(TestElement element) {
101         configureTestElement(element);
102         String JavaDoc md5HexString = this.md5HexInput.getText();
103         //initialize to empty string, this will fail the assertion
104
if (md5HexString == null || md5HexString.length() == 0) {
105             md5HexString = "";
106         }
107         ((MD5HexAssertion)element).setAllowedMD5Hex(md5HexString);
108     }
109 }
110
Popular Tags