Source Code Cross Referenced for BitwiseOperatorTest.java in  » Library » Apache-commons-jexl-1.1-src » org » apache » commons » jexl » 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 » Library » Apache commons jexl 1.1 src » org.apache.commons.jexl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2002-2006 The Apache Software Foundation.
003:         *
004:         * Licensed under the Apache License, Version 2.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         *
008:         *      http://www.apache.org/licenses/LICENSE-2.0
009:         *
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:
017:        package org.apache.commons.jexl;
018:
019:        import junit.framework.TestCase;
020:
021:        /**
022:         * Tests for the bitwise operators.
023:         * @author Dion Gillard
024:         * @since 1.1
025:         */
026:        public class BitwiseOperatorTest extends TestCase {
027:
028:            /**
029:             * Create the named test.
030:             * @param name test name
031:             */
032:            public BitwiseOperatorTest(String name) {
033:                super (name);
034:            }
035:
036:            public void testAndWithTwoNulls() throws Exception {
037:                Expression e = ExpressionFactory
038:                        .createExpression("null & null");
039:                JexlContext jc = JexlHelper.createContext();
040:                Object o = e.evaluate(jc);
041:                assertEquals("Result is wrong", new Long(0), o);
042:            }
043:
044:            public void testAndWithLeftNull() throws Exception {
045:                Expression e = ExpressionFactory.createExpression("null & 1");
046:                JexlContext jc = JexlHelper.createContext();
047:                Object o = e.evaluate(jc);
048:                assertEquals("Result is wrong", new Long(0), o);
049:            }
050:
051:            public void testAndWithRightNull() throws Exception {
052:                Expression e = ExpressionFactory.createExpression("1 & null");
053:                JexlContext jc = JexlHelper.createContext();
054:                Object o = e.evaluate(jc);
055:                assertEquals("Result is wrong", new Long(0), o);
056:            }
057:
058:            public void testAndSimple() throws Exception {
059:                Expression e = ExpressionFactory.createExpression("15 & 3");
060:                JexlContext jc = JexlHelper.createContext();
061:                Object o = e.evaluate(jc);
062:                assertEquals("Result is wrong", new Long(3), o);
063:            }
064:
065:            public void testAndVariableNumberCoercion() throws Exception {
066:                Expression e = ExpressionFactory.createExpression("x & y");
067:                JexlContext jc = JexlHelper.createContext();
068:                jc.getVars().put("x", new Integer(15));
069:                jc.getVars().put("y", new Short((short) 7));
070:                Object o = e.evaluate(jc);
071:                assertEquals("Result is wrong", new Long(7), o);
072:            }
073:
074:            public void testAndVariableStringCoercion() throws Exception {
075:                Expression e = ExpressionFactory.createExpression("x & y");
076:                JexlContext jc = JexlHelper.createContext();
077:                jc.getVars().put("x", new Integer(15));
078:                jc.getVars().put("y", "7");
079:                Object o = e.evaluate(jc);
080:                assertEquals("Result is wrong", new Long(7), o);
081:            }
082:
083:            public void testComplementWithNull() throws Exception {
084:                Expression e = ExpressionFactory.createExpression("~null");
085:                JexlContext jc = JexlHelper.createContext();
086:                Object o = e.evaluate(jc);
087:                assertEquals("Result is wrong", new Long(-1), o);
088:            }
089:
090:            public void testComplementSimple() throws Exception {
091:                Expression e = ExpressionFactory.createExpression("~128");
092:                JexlContext jc = JexlHelper.createContext();
093:                Object o = e.evaluate(jc);
094:                assertEquals("Result is wrong", new Long(-129), o);
095:            }
096:
097:            public void testComplementVariableNumberCoercion() throws Exception {
098:                Expression e = ExpressionFactory.createExpression("~x");
099:                JexlContext jc = JexlHelper.createContext();
100:                jc.getVars().put("x", new Integer(15));
101:                Object o = e.evaluate(jc);
102:                assertEquals("Result is wrong", new Long(-16), o);
103:            }
104:
105:            public void testComplementVariableStringCoercion() throws Exception {
106:                Expression e = ExpressionFactory.createExpression("~x");
107:                JexlContext jc = JexlHelper.createContext();
108:                jc.getVars().put("x", "15");
109:                Object o = e.evaluate(jc);
110:                assertEquals("Result is wrong", new Long(-16), o);
111:            }
112:
113:            public void testOrWithTwoNulls() throws Exception {
114:                Expression e = ExpressionFactory
115:                        .createExpression("null | null");
116:                JexlContext jc = JexlHelper.createContext();
117:                Object o = e.evaluate(jc);
118:                assertEquals("Result is wrong", new Long(0), o);
119:            }
120:
121:            public void testOrWithLeftNull() throws Exception {
122:                Expression e = ExpressionFactory.createExpression("null | 1");
123:                JexlContext jc = JexlHelper.createContext();
124:                Object o = e.evaluate(jc);
125:                assertEquals("Result is wrong", new Long(1), o);
126:            }
127:
128:            public void testOrWithRightNull() throws Exception {
129:                Expression e = ExpressionFactory.createExpression("1 | null");
130:                JexlContext jc = JexlHelper.createContext();
131:                Object o = e.evaluate(jc);
132:                assertEquals("Result is wrong", new Long(1), o);
133:            }
134:
135:            public void testOrSimple() throws Exception {
136:                Expression e = ExpressionFactory.createExpression("12 | 3");
137:                JexlContext jc = JexlHelper.createContext();
138:                Object o = e.evaluate(jc);
139:                assertEquals("Result is wrong", new Long(15), o);
140:            }
141:
142:            public void testOrVariableNumberCoercion() throws Exception {
143:                Expression e = ExpressionFactory.createExpression("x | y");
144:                JexlContext jc = JexlHelper.createContext();
145:                jc.getVars().put("x", new Integer(12));
146:                jc.getVars().put("y", new Short((short) 3));
147:                Object o = e.evaluate(jc);
148:                assertEquals("Result is wrong", new Long(15), o);
149:            }
150:
151:            public void testOrVariableStringCoercion() throws Exception {
152:                Expression e = ExpressionFactory.createExpression("x | y");
153:                JexlContext jc = JexlHelper.createContext();
154:                jc.getVars().put("x", new Integer(12));
155:                jc.getVars().put("y", "3");
156:                Object o = e.evaluate(jc);
157:                assertEquals("Result is wrong", new Long(15), o);
158:            }
159:
160:            public void testXorWithTwoNulls() throws Exception {
161:                Expression e = ExpressionFactory
162:                        .createExpression("null ^ null");
163:                JexlContext jc = JexlHelper.createContext();
164:                Object o = e.evaluate(jc);
165:                assertEquals("Result is wrong", new Long(0), o);
166:            }
167:
168:            public void testXorWithLeftNull() throws Exception {
169:                Expression e = ExpressionFactory.createExpression("null ^ 1");
170:                JexlContext jc = JexlHelper.createContext();
171:                Object o = e.evaluate(jc);
172:                assertEquals("Result is wrong", new Long(1), o);
173:            }
174:
175:            public void testXorWithRightNull() throws Exception {
176:                Expression e = ExpressionFactory.createExpression("1 ^ null");
177:                JexlContext jc = JexlHelper.createContext();
178:                Object o = e.evaluate(jc);
179:                assertEquals("Result is wrong", new Long(1), o);
180:            }
181:
182:            public void testXorSimple() throws Exception {
183:                Expression e = ExpressionFactory.createExpression("1 ^ 3");
184:                JexlContext jc = JexlHelper.createContext();
185:                Object o = e.evaluate(jc);
186:                assertEquals("Result is wrong", new Long(2), o);
187:            }
188:
189:            public void testXorVariableNumberCoercion() throws Exception {
190:                Expression e = ExpressionFactory.createExpression("x ^ y");
191:                JexlContext jc = JexlHelper.createContext();
192:                jc.getVars().put("x", new Integer(1));
193:                jc.getVars().put("y", new Short((short) 3));
194:                Object o = e.evaluate(jc);
195:                assertEquals("Result is wrong", new Long(2), o);
196:            }
197:
198:            public void testXorVariableStringCoercion() throws Exception {
199:                Expression e = ExpressionFactory.createExpression("x ^ y");
200:                JexlContext jc = JexlHelper.createContext();
201:                jc.getVars().put("x", new Integer(1));
202:                jc.getVars().put("y", "3");
203:                Object o = e.evaluate(jc);
204:                assertEquals("Result is wrong", new Long(2), o);
205:            }
206:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.