Source Code Cross Referenced for AbstractButtonTest.java in  » Testing » jacareto » jacareto » test » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Testing » jacareto » jacareto.test 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Jacareto Copyright (c) 2002-2005
003:         * Applied Computer Science Research Group, Darmstadt University of
004:         * Technology, Institute of Mathematics & Computer Science,
005:         * Ludwigsburg University of Education, and Computer Based
006:         * Learning Research Group, Aachen University. All rights reserved.
007:         *
008:         * Jacareto is free software; you can redistribute it and/or
009:         * modify it under the terms of the GNU General Public
010:         * License as published by the Free Software Foundation; either
011:         * version 2 of the License, or (at your option) any later version.
012:         *
013:         * Jacareto is distributed in the hope that it will be useful,
014:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
015:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
016:         * General Public License for more details.
017:         *
018:         * You should have received a copy of the GNU General Public
019:         * License along with Jacareto; if not, write to the Free
020:         * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
021:         *
022:         */
023:
024:        package jacareto.test;
025:
026:        import jacareto.comp.Components;
027:        import jacareto.system.Environment;
028:
029:        import java.awt.Component;
030:
031:        import java.util.Iterator;
032:
033:        import javax.swing.AbstractButton;
034:
035:        /**
036:         * Test class for testing <code>java.swing.AbstractButton</code> components.  The following
037:         * criteria are tested by this class:
038:         * 
039:         * <ul>
040:         * <li>
041:         * <b>button text</b> - testes if the text on the tested button is correct
042:         * </li>
043:         * </ul>
044:         * 
045:         *
046:         * @author <a href="mailto:frommer@rbg.informatik.tu-darmstadt.de">Juri Frommer</a>
047:         * @version 1.0
048:         */
049:        public class AbstractButtonTest extends JComponentTest {
050:            /** Contains the expected text of the tested component */
051:            private String buttonText;
052:
053:            /**
054:             * Creates a new test with the specified values.
055:             *
056:             * @param env env the environment
057:             * @param componentName the name of the component
058:             * @param isIgnoring if the test result should be ignored
059:             * @param isCorrecting if the values of the component should be corrected when the test has
060:             *        failed
061:             * @param hasFocus if the component has the focus
062:             * @param isEnabled if the component is set enabled
063:             * @param btnText the text on the button
064:             */
065:            public AbstractButtonTest(Environment env, String componentName,
066:                    boolean isIgnoring, boolean isCorrecting, boolean hasFocus,
067:                    boolean isEnabled, String btnText) {
068:                super (env, componentName, isIgnoring, isCorrecting, hasFocus,
069:                        isEnabled);
070:                setButtonText(btnText);
071:            }
072:
073:            /**
074:             * Creates a new test with the values of the given component and default values.
075:             *
076:             * @param env the environment.
077:             * @param components the components instance
078:             * @param component the component to test. Must be of type
079:             *        <code>javax.swing.AbstractButton</code>.
080:             */
081:            public AbstractButtonTest(Environment env, Components components,
082:                    Component component) {
083:                super (env, components, component);
084:                setButtonText(((AbstractButton) component).getText());
085:            }
086:
087:            /**
088:             * Creates a new test with default values and no environment. The environment should be defined
089:             * with the method {@link jacareto.system.EnvironmentMember#setEnvironment(Environment)}
090:             * before environment instances will be accessed.
091:             */
092:            public AbstractButtonTest() {
093:                this (null, "", false, false, false, true, "");
094:            }
095:
096:            /**
097:             * @see jacareto.struct.StructureElement#getElementName()
098:             */
099:            public String getElementName() {
100:                return language.getString("Tests.AbstractButtonTest.Name");
101:            }
102:
103:            /**
104:             * @see jacareto.struct.StructureElement#getElementDescription()
105:             */
106:            public String getElementDescription() {
107:                return language
108:                        .getString("Tests.AbstractButtonTest.Description");
109:            }
110:
111:            /**
112:             * @see jacareto.struct.StructureElement#toShortString()
113:             */
114:            public String toShortString() {
115:                return getElementName();
116:            }
117:
118:            /**
119:             * DOCUMENT ME!
120:             *
121:             * @return The expected text of the tested button
122:             */
123:            public String getButtonText() {
124:                return buttonText;
125:            }
126:
127:            /**
128:             * Specifies The expected text of the tested button
129:             *
130:             * @param string DOCUMENT ME!
131:             */
132:            public void setButtonText(String string) {
133:                buttonText = string;
134:            }
135:
136:            /**
137:             * @see jacareto.test.Test#evaluate(jacareto.comp.Components)
138:             */
139:            public boolean evaluate(Components components) {
140:                AbstractButton button = null;
141:
142:                setLastIgnored(isIgnoring());
143:                setLastResult(false);
144:                setLastCorrected(false);
145:
146:                // get the button with the componentName
147:                Component component = components
148:                        .getComponent(getComponentName());
149:
150:                if (component == null) {
151:                    setEvaluationMessage(language
152:                            .getString("Tests.Test.Failure.NoComponent"));
153:
154:                    return false;
155:                }
156:
157:                if (!(component instanceof  AbstractButton)) {
158:                    setEvaluationMessage(language
159:                            .getString("Tests.Test.Failure.WrongComponentType"));
160:
161:                    return false;
162:                }
163:
164:                button = (AbstractButton) component;
165:
166:                if (doTest(button)) {
167:                    boolean result = true;
168:                    Iterator childIter = childrenIterator();
169:
170:                    while (childIter.hasNext() && result) {
171:                        result &= evaluateChild((Test) childIter.next(),
172:                                components);
173:                    }
174:
175:                    setLastResult(result);
176:
177:                    return result;
178:                }
179:
180:                if (isCorrecting()) {
181:                    //appendToEvaluationMessage("\n" + language.getString("Test.Correct"));
182:                    correct(button);
183:                    setLastCorrected(true);
184:                }
185:
186:                //if(isIgnoring()) appendToEvaluationMessage("\n" + language.getString("Test.Ignored"));
187:                return false;
188:            }
189:
190:            /**
191:             * @see jacareto.test.JComponentTest#doTest(Component)
192:             */
193:            protected boolean doTest(Component component) {
194:                if (super .doTest(component)) {
195:                    AbstractButton button = (AbstractButton) component;
196:                    String currentText = button.getText();
197:                    String targetText = getButtonText();
198:
199:                    if (!(button.getText().equals(getButtonText()))) {
200:                        setEvaluationMessage(language
201:                                .getString("Tests.AbstractButtonTest.Failure.WrongText")
202:                                + "\n"
203:                                + language
204:                                        .getString("Tests.Test.Failure.Expected")
205:                                + ": "
206:                                + targetText
207:                                + "\n"
208:                                + language
209:                                        .getString("Tests.Test.Failure.Detected")
210:                                + ": " + currentText);
211:
212:                        return false;
213:                    }
214:                } else {
215:                    return false;
216:                }
217:
218:                return true;
219:            }
220:
221:            /**
222:             * @see jacareto.test.JComponentTest#correct(Component)
223:             */
224:            protected void correct(Component component) {
225:                super .correct(component);
226:
227:                AbstractButton button = (AbstractButton) component;
228:                button.setText(getButtonText());
229:                appendToEvaluationMessage("\n"
230:                        + getElementName()
231:                        + ": "
232:                        + language
233:                                .getString("Tests.AbstractButtonTest.Correct.Text"));
234:            }
235:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.