01: package org.uispec4j;
02:
03: import junit.framework.Assert;
04: import org.uispec4j.assertion.Assertion;
05:
06: import javax.swing.JPasswordField;
07: import java.awt.Component;
08:
09: /** Wrapper for JPasswordField components. */
10: public class PasswordField extends AbstractUIComponent {
11: public static final String TYPE_NAME = "passwordField";
12: public static final Class[] SWING_CLASSES = { JPasswordField.class };
13:
14: private JPasswordField jPasswordField;
15:
16: public PasswordField(JPasswordField passwordField) {
17: this .jPasswordField = passwordField;
18: }
19:
20: public Component getAwtComponent() {
21: return jPasswordField;
22: }
23:
24: public String getDescriptionTypeName() {
25: return TYPE_NAME;
26: }
27:
28: public Assertion passwordEquals(final String hiddenPassword) {
29: return new Assertion() {
30: public void check() throws Exception {
31: Assert.assertEquals(hiddenPassword, new String(
32: jPasswordField.getPassword()));
33: }
34: };
35: }
36:
37: public void setPassword(String passsword) {
38: jPasswordField.setText(passsword);
39: }
40: }
|