Source Code Cross Referenced for JLabelTest.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.JLabel;
034:
035:        /**
036:         * Test class for testing <code>java.swing.JLabel</code> components.  The following criteria are
037:         * tested by this class:
038:         * 
039:         * <ul>
040:         * <li>
041:         * <b>label text</b> - testes if the text on the tested label is correct
042:         * </li>
043:         * </ul>
044:         * 
045:         *
046:         * @author carola
047:         */
048:        public class JLabelTest extends JComponentTest {
049:            /** Contains the expected label text */
050:            private String labelText;
051:
052:            /**
053:             * Creates a new test with the specified values.
054:             *
055:             * @param env env the environment
056:             * @param componentName the name of the component
057:             * @param isIgnoring if the test result should be ignored
058:             * @param isCorrecting if the values of the component should be corrected when the test has
059:             *        failed
060:             * @param hasFocus if the component has the focus
061:             * @param isEnabled if the component is set enabled
062:             * @param labelText the text on the label
063:             */
064:            public JLabelTest(Environment env, String componentName,
065:                    boolean isIgnoring, boolean isCorrecting, boolean hasFocus,
066:                    boolean isEnabled, String labelText) {
067:                super (env, componentName, isIgnoring, isCorrecting, hasFocus,
068:                        isEnabled);
069:                setLabelText(labelText);
070:            }
071:
072:            /**
073:             * Creates a new test with the values of the given component and default values.
074:             *
075:             * @param env the environment.
076:             * @param components the components instance
077:             * @param component the component to test. Must be of type <code>javax.swing.JLabel</code>.
078:             */
079:            public JLabelTest(Environment env, Components components,
080:                    Component component) {
081:                super (env, components, component);
082:                setLabelText(((JLabel) component).getText());
083:                setFocus(((JLabel) component).hasFocus());
084:            }
085:
086:            /**
087:             * Creates a new test with default values and no environment. The environment should be defined
088:             * with the method {@link jacareto.system.EnvironmentMember#setEnvironment(Environment)}
089:             * before environment instances will be accessed.
090:             */
091:            public JLabelTest() {
092:                this (null, "", false, false, false, true, "");
093:            }
094:
095:            /**
096:             * @see jacareto.test.Test#evaluate(jacareto.comp.Components)
097:             */
098:            public boolean evaluate(Components components) {
099:                JLabel label = null;
100:
101:                setLastIgnored(isIgnoring());
102:                setLastResult(false);
103:                setLastCorrected(false);
104:
105:                // get the button with the componentName
106:                Component component = components
107:                        .getComponent(getComponentName());
108:
109:                if (component == null) {
110:                    setEvaluationMessage(language
111:                            .getString("Tests.Test.Failure.NoComponent"));
112:
113:                    return false;
114:                }
115:
116:                if (!(component instanceof  JLabel)) {
117:                    setEvaluationMessage(language
118:                            .getString("Tests.Test.Failure.WrongComponentType"));
119:
120:                    return false;
121:                }
122:
123:                label = (JLabel) component;
124:
125:                if (doTest(label)) {
126:                    boolean result = true;
127:                    Iterator childIter = childrenIterator();
128:
129:                    while (childIter.hasNext() && result) {
130:                        result &= evaluateChild((Test) childIter.next(),
131:                                components);
132:                    }
133:
134:                    setLastResult(result);
135:
136:                    return result;
137:                }
138:
139:                if (isCorrecting()) {
140:                    //appendToEvaluationMessage("\n" + language.getString("Test.Correct"));
141:                    correct(label);
142:                    setLastCorrected(true);
143:                }
144:
145:                //if(isIgnoring()) appendToEvaluationMessage("\n" + language.getString("Test.Ignored")); 
146:                return false;
147:            }
148:
149:            /**
150:             * @see jacareto.test.JComponentTest#doTest(Component)
151:             */
152:            protected boolean doTest(Component component) {
153:                if (super .doTest(component)) {
154:                    JLabel label = (JLabel) component;
155:                    String currentText = label.getText();
156:                    String targetText = getLabelText();
157:
158:                    if (!(label.getText().equals(getLabelText()))) {
159:                        setEvaluationMessage(language
160:                                .getString("Tests.JLabelTest.Failure.WrongText")
161:                                + "\n"
162:                                + language
163:                                        .getString("Tests.Test.Failure.Expected")
164:                                + ": "
165:                                + targetText
166:                                + "\n"
167:                                + language
168:                                        .getString("Tests.Test.Failure.Detected")
169:                                + ": " + currentText);
170:
171:                        return false;
172:                    }
173:                } else {
174:                    return false;
175:                }
176:
177:                return true;
178:            }
179:
180:            /**
181:             * @see jacareto.test.JComponentTest#correct(Component)
182:             */
183:            protected void correct(Component component) {
184:                super .correct(component);
185:
186:                JLabel label = (JLabel) component;
187:                label.setText(getLabelText());
188:                appendToEvaluationMessage("\n"
189:                        + getElementName()
190:                        + ": "
191:                        + language
192:                                .getString("Tests.JLabelTest.Correct.LabelText"));
193:            }
194:
195:            /**
196:             * @see jacareto.struct.StructureElement#getElementName()
197:             */
198:            public String getElementName() {
199:                return language.getString("Tests.JLabelTest.Name");
200:            }
201:
202:            /**
203:             * @see jacareto.struct.StructureElement#getElementDescription()
204:             */
205:            public String getElementDescription() {
206:                return language.getString("Tests.JLabelTest.Description");
207:            }
208:
209:            /**
210:             * @see jacareto.struct.StructureElement#toShortString()
211:             */
212:            public String toShortString() {
213:                return getElementName();
214:            }
215:
216:            /**
217:             * DOCUMENT ME!
218:             *
219:             * @return the expected text of the tested label
220:             */
221:            public String getLabelText() {
222:                return labelText;
223:            }
224:
225:            /**
226:             * Specifies the expected text of the tested label
227:             *
228:             * @param string DOCUMENT ME!
229:             */
230:            public void setLabelText(String string) {
231:                labelText = string;
232:            }
233:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.