Source Code Cross Referenced for EditMaskLexerAndTokenTest.java in  » IDE-Eclipse » jface » org » eclipse » jface » tests » examples » databinding » mask » internal » 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 » IDE Eclipse » jface » org.eclipse.jface.tests.examples.databinding.mask.internal 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2005, 2007 IBM Corporation and others.
003:         * All rights reserved. This program and the accompanying materials
004:         * are made available under the terms of the Eclipse Public License v1.0
005:         * which accompanies this distribution, and is available at
006:         * http://www.eclipse.org/legal/epl-v10.html
007:         *
008:         * Contributors:
009:         *     IBM Corporation - initial API and implementation
010:         *******************************************************************************/package org.eclipse.jface.tests.examples.databinding.mask.internal;
011:
012:        import junit.framework.TestCase;
013:
014:        import org.eclipse.jface.examples.databinding.mask.internal.EditMaskLexerAndToken;
015:
016:        public class EditMaskLexerAndTokenTest extends TestCase {
017:
018:            private EditMaskLexerAndToken token;
019:
020:            protected void setUp() throws Exception {
021:                token = new EditMaskLexerAndToken();
022:            }
023:
024:            public void testInitWithNumeric() throws Exception {
025:                token.initializeEditMask("#", 0);
026:                assertTrue("Should accept a digit", token.accept("0"));
027:                token.clear();
028:                assertTrue("Should accept a digit", token.accept("1"));
029:                token.clear();
030:                assertTrue("Should accept a digit", token.accept("2"));
031:                token.clear();
032:                assertTrue("Should accept a digit", token.accept("3"));
033:                token.clear();
034:                assertTrue("Should accept a digit", token.accept("4"));
035:                token.clear();
036:                assertTrue("Should accept a digit", token.accept("5"));
037:                token.clear();
038:                assertTrue("Should accept a digit", token.accept("6"));
039:                token.clear();
040:                assertTrue("Should accept a digit", token.accept("7"));
041:                token.clear();
042:                assertTrue("Should accept a digit", token.accept("8"));
043:                token.clear();
044:                assertTrue("Should accept a digit", token.accept("9"));
045:                token.clear();
046:                assertFalse("Should not accept an alpha", token.accept("A"));
047:                token.clear();
048:                assertFalse("Should not accept an alpha", token.accept("z"));
049:                assertFalse("Placeholders are not read-only", token
050:                        .isReadOnly());
051:            }
052:
053:            public void testInitWithLiteral() throws Exception {
054:                token.initializeEditMask("(", 0);
055:                assertEquals("Literals automatically set their input", "(",
056:                        token.getInput());
057:                assertFalse("Literals don't accept anything", token.accept("("));
058:                assertTrue("literals are read-only", token.isReadOnly());
059:                assertTrue("Literals are complete", token.isComplete());
060:                assertFalse("Literals cannot accept characters", token
061:                        .canAcceptMoreCharacters());
062:            }
063:
064:            public void testInitWithBackslashLiteral() throws Exception {
065:                token.initializeEditMask("\\#", 0);
066:                assertEquals("Should get backslash literal", "#", token
067:                        .getInput());
068:            }
069:
070:            public void testAcceptWithValidInputAndEmpty() throws Exception {
071:                token.initializeEditMask("#", 0);
072:                assertTrue("Should accept a 0", token.accept("0"));
073:            }
074:
075:            public void testAcceptWhenParserCannotAcceptMoreCharacters()
076:                    throws Exception {
077:                token.initializeEditMask("#", 0);
078:                assertTrue("Should accept a 0", token.accept("0"));
079:                assertFalse("Should not accept a 0 -- input full", token
080:                        .accept("0"));
081:            }
082:
083:            public void testGetInput() throws Exception {
084:                token.initializeEditMask("#", 0);
085:                assertTrue("Should accept a #", token.accept("0"));
086:                assertEquals(token.getInput(), "0");
087:            }
088:
089:            public void testClear_withNonLiteral() throws Exception {
090:                token.initializeEditMask("#", 0);
091:                assertTrue("Should accept a 0", token.accept("0"));
092:                assertNotNull("Input should not be null", token.getInput());
093:                token.clear();
094:                assertNull("Input should be null after clear", token.getInput());
095:            }
096:
097:            public void testClear_withLiteral() throws Exception {
098:                token.initializeEditMask("(", 0);
099:                assertNotNull("Input should not be null", token.getInput());
100:                token.clear();
101:                assertNotNull(
102:                        "Input should still not be null after clear of read-only literal",
103:                        token.getInput());
104:            }
105:
106:            public void testIsComplete_withNonLiteral() throws Exception {
107:                token.initializeEditMask("#", 0);
108:                assertFalse("should not be complete", token.isComplete());
109:                token.accept("1");
110:                assertTrue("should be complete", token.isComplete());
111:                token.clear();
112:                assertFalse("should not be complete", token.isComplete());
113:            }
114:
115:        }
w_ww__.___j_a__v_a___2__s_.__c_o__m___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.