Source Code Cross Referenced for PanelTest.java in  » Testing » UISpec4J » org » uispec4j » 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 » UISpec4J » org.uispec4j 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.uispec4j;
002:
003:        import org.uispec4j.utils.UIComponentFactory;
004:        import org.uispec4j.xml.XmlAssert;
005:        import org.uispec4j.finder.ComponentMatcher;
006:
007:        import javax.swing.*;
008:        import java.awt.Component;
009:
010:        public class PanelTest extends UIComponentTestCase {
011:
012:            public void testGetComponentTypeName() throws Exception {
013:                assertEquals("panel", UIComponentFactory.createUIComponent(
014:                        new JPanel()).getDescriptionTypeName());
015:            }
016:
017:            public void testGetDescription() throws Exception {
018:                JTabbedPane tabbedPane = new JTabbedPane();
019:                tabbedPane.setName("myTabbedPane");
020:
021:                JPanel jPanel = new JPanel();
022:                jPanel.setName("myPanel");
023:                jPanel.add(tabbedPane);
024:
025:                JTextField textField = new JTextField();
026:                textField.setName("myText");
027:                tabbedPane.addTab("1", textField);
028:                tabbedPane.addTab("2", new JButton("myButton"));
029:
030:                Panel panel = new Panel(jPanel);
031:                XmlAssert.assertEquivalent("<panel name='myPanel'>"
032:                        + "  <tabGroup name='myTabbedPane'>"
033:                        + "     <textBox name='myText'/>" + "  </tabGroup>"
034:                        + "</panel>", panel.getDescription());
035:            }
036:
037:            public void testFactory() throws Exception {
038:                checkFactory(new JPanel(), Panel.class);
039:            }
040:
041:            protected UIComponent createComponent() {
042:                return new Panel(new JPanel());
043:            }
044:
045:            public void testContainsLabel() throws Exception {
046:                JPanel jPanel = new JPanel();
047:                jPanel.add(new JLabel("Some text"));
048:                Panel panel = new Panel(jPanel);
049:                assertTrue(panel.containsLabel("Some text"));
050:                assertTrue(panel.containsLabel("text"));
051:                assertFalse(panel.containsLabel("unknown"));
052:            }
053:
054:            public void testGetSpinnerThroughModel() throws Exception {
055:                checkGetSpinnerByModel(new SpinnerDateModel(), new Getter() {
056:                    public UIComponent get(Panel panel) {
057:                        return panel.getDateSpinner();
058:                    }
059:                });
060:                checkGetSpinnerByModel(new SpinnerListModel(), new Getter() {
061:                    public UIComponent get(Panel panel) {
062:                        return panel.getListSpinner();
063:                    }
064:                });
065:                checkGetSpinnerByModel(new SpinnerNumberModel(), new Getter() {
066:                    public UIComponent get(Panel panel) {
067:                        return panel.getNumberSpinner();
068:                    }
069:                });
070:            }
071:
072:            public void testGetSpinnerThroughModelAndComponentName()
073:                    throws Exception {
074:                checkGetSpinnerByModel(new SpinnerDateModel(), new Getter() {
075:                    public UIComponent get(Panel panel) {
076:                        return panel.getDateSpinner("spinner1");
077:                    }
078:                });
079:                checkGetSpinnerByModel(new SpinnerListModel(), new Getter() {
080:                    public UIComponent get(Panel panel) {
081:                        return panel.getListSpinner("spinner1");
082:                    }
083:                });
084:                checkGetSpinnerByModel(new SpinnerNumberModel(), new Getter() {
085:                    public UIComponent get(Panel panel) {
086:                        return panel.getNumberSpinner("spinner1");
087:                    }
088:                });
089:            }
090:
091:            public void testGetSpinnerThroughModelAndMatcher() throws Exception {
092:                final ComponentMatcher myMatcher = new ComponentMatcher() {
093:                    public boolean matches(Component component) {
094:                        return true;
095:                    }
096:                };
097:                checkGetSpinnerByModel(new SpinnerDateModel(), new Getter() {
098:                    public UIComponent get(Panel panel) {
099:                        return panel.getDateSpinner(myMatcher);
100:                    }
101:                });
102:                checkGetSpinnerByModel(new SpinnerListModel(), new Getter() {
103:                    public UIComponent get(Panel panel) {
104:                        return panel.getListSpinner(myMatcher);
105:                    }
106:                });
107:                checkGetSpinnerByModel(new SpinnerNumberModel(), new Getter() {
108:                    public UIComponent get(Panel panel) {
109:                        return panel.getNumberSpinner(myMatcher);
110:                    }
111:                });
112:            }
113:
114:            private void checkGetSpinnerByModel(SpinnerModel model,
115:                    Getter getter) {
116:                JPanel jPanel = new JPanel();
117:                jPanel.add(new JSpinner(new MySpinnerModel()));
118:
119:                Panel panel = new Panel(jPanel);
120:                try {
121:                    getter.get(panel);
122:                    fail();
123:                } catch (ItemNotFoundException e) {
124:                    assertEquals("No component found", e.getMessage());
125:                }
126:
127:                JSpinner jSpinner = new JSpinner(model);
128:                jSpinner.setName("spinner1");
129:                jPanel.add(jSpinner);
130:                assertSame(jSpinner, getter.get(panel).getAwtComponent());
131:            }
132:
133:            private interface Getter {
134:                UIComponent get(Panel panel);
135:            }
136:
137:            private static class MySpinnerModel extends AbstractSpinnerModel {
138:                public Object getNextValue() {
139:                    return null;
140:                }
141:
142:                public Object getPreviousValue() {
143:                    return null;
144:                }
145:
146:                public Object getValue() {
147:                    return null;
148:                }
149:
150:                public void setValue(Object value) {
151:                }
152:            }
153:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.