Source Code Cross Referenced for SystemTest.java in  » Ajax » GWT » com » google » gwt » emultest » java » lang » 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 » Ajax » GWT » com.google.gwt.emultest.java.lang 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2007 Google Inc.
003:         * 
004:         * Licensed under the Apache License, Version 2.0 (the "License"); you may not
005:         * use this file except in compliance with the License. You may obtain a copy of
006:         * 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, WITHOUT
012:         * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
013:         * License for the specific language governing permissions and limitations under
014:         * the License.
015:         */
016:        package com.google.gwt.emultest.java.lang;
017:
018:        import com.google.gwt.junit.client.GWTTestCase;
019:
020:        /**
021:         * Tests java.lang.System.
022:         */
023:        public class SystemTest extends GWTTestCase {
024:
025:            private static class Bar extends Foo {
026:                public Bar() {
027:                }
028:            }
029:
030:            private static class Foo {
031:                public Foo() {
032:                }
033:            }
034:
035:            public String getModuleName() {
036:                return "com.google.gwt.emultest.EmulSuite";
037:            }
038:
039:            public void testArraycopyFailures() {
040:                int[] src = new int[4];
041:                int[] dest = new int[] { 1, 1, 1, 1 };
042:                double[] destDouble = new double[4];
043:                String[] strings = new String[4];
044:                try {
045:                    System.arraycopy(src, 5, dest, 0, 7);
046:                    fail("Should have thrown IndexOutOfBoundsException: src past end");
047:                } catch (IndexOutOfBoundsException e) {
048:                }
049:                try {
050:                    System.arraycopy(src, 0, dest, 5, 7);
051:                    fail("Should have thrown IndexOutOfBoundsException: dest past end");
052:                } catch (IndexOutOfBoundsException e) {
053:                }
054:                try {
055:                    System.arraycopy(src, -1, dest, 0, 4);
056:                    fail("Should have thrown IndexOutOfBoundsException: src ofs negative");
057:                } catch (IndexOutOfBoundsException e) {
058:                }
059:                try {
060:                    System.arraycopy(src, 0, dest, -1, 4);
061:                    fail("Should have thrown IndexOutOfBoundsException: dest ofs negative");
062:                } catch (IndexOutOfBoundsException e) {
063:                }
064:                try {
065:                    System.arraycopy(src, 0, dest, 0, -1);
066:                    fail("Should have thrown IndexOutOfBoundsException: negative length");
067:                } catch (IndexOutOfBoundsException e) {
068:                }
069:                try {
070:                    System.arraycopy("test", 0, dest, 0, 4);
071:                    fail("Should have thrown ArrayStoreException: src not array");
072:                } catch (ArrayStoreException e) {
073:                }
074:                try {
075:                    System.arraycopy(src, 0, "test", 0, 4);
076:                    fail("Should have thrown ArrayStoreException: dest not array");
077:                } catch (ArrayStoreException e) {
078:                }
079:                try {
080:                    System.arraycopy(src, 0, destDouble, 0, 4);
081:                    fail("Should have thrown ArrayStoreException: different primitive types");
082:                } catch (ArrayStoreException e) {
083:                }
084:                try {
085:                    System.arraycopy(strings, 0, dest, 0, 4);
086:                    fail("Should have thrown ArrayStoreException: reference/primitive mismatch");
087:                } catch (ArrayStoreException e) {
088:                }
089:                try {
090:                    System.arraycopy(src, 0, strings, 0, 4);
091:                    fail("Should have thrown ArrayStoreException: primitive/reference mismatch");
092:                } catch (ArrayStoreException e) {
093:                }
094:            }
095:
096:            public void testArraycopyMultidim() {
097:                Object[][] objArray = new Object[1][1];
098:                String[][] strArray = new String[1][1];
099:                strArray[0][0] = "Test";
100:                Integer[][] intArray = new Integer[1][1];
101:                intArray[0][0] = new Integer(1);
102:                System.arraycopy(strArray, 0, objArray, 0, 1);
103:                assertEquals("Test", objArray[0][0]);
104:                try {
105:                    System.arraycopy(strArray, 0, intArray, 0, 1);
106:                    fail("Should have thrown ArrayStoreException: incompatible multidimensional arrays");
107:                } catch (ArrayStoreException e) {
108:                }
109:                try {
110:                    System.arraycopy(new String[] { "T2" }, 0, objArray, 0, 1);
111:                    fail("Should have thrown ArrayStoreException: store string array in multi-dim Object array");
112:                } catch (ArrayStoreException e) {
113:                }
114:            }
115:
116:            public void testArraycopyNulls() {
117:                int[] src = new int[4];
118:                int[] dest = new int[] { 1, 1, 1, 1 };
119:                try {
120:                    System.arraycopy(null, 0, dest, 0, 4);
121:                    fail("Should have thrown NullPointerException: src null");
122:                } catch (NullPointerException e) {
123:                    // verify dest unchanged
124:                    for (int i = 0; i < dest.length; ++i) {
125:                        assertEquals(1, dest[i]);
126:                    }
127:                }
128:                try {
129:                    System.arraycopy(src, 0, null, 0, 4);
130:                    fail("Should have thrown NullPointerException: dest null");
131:                } catch (NullPointerException e) {
132:                }
133:            }
134:
135:            public void testArraycopyObjects() {
136:                Foo[] fooArray = new Foo[4];
137:                Bar[] barArray = new Bar[4];
138:                Object[] src = new Object[] { new Bar(), new Bar(), new Foo(),
139:                        new Bar() };
140:                System.arraycopy(src, 0, fooArray, 0, src.length);
141:                for (int i = 0; i < src.length; ++i) {
142:                    assertEquals(src[i], fooArray[i]);
143:                }
144:                try {
145:                    System.arraycopy(src, 0, barArray, 0, 4);
146:                    fail("Should have thrown ArrayStoreException: foo into bar");
147:                } catch (ArrayStoreException e) {
148:                    // verify we changed only up to the element causing the exception
149:                    assertEquals(src[0], barArray[0]);
150:                    assertEquals(src[1], barArray[1]);
151:                    assertNull(barArray[2]);
152:                    assertNull(barArray[3]);
153:                }
154:            }
155:
156:            public void testArraycopyOverlap() {
157:                int[] intArray = new int[] { 0, 1, 2, 3 };
158:                String[] strArray = new String[] { "0", "1", "2", "3" };
159:
160:                System.arraycopy(intArray, 0, intArray, 1, intArray.length - 1);
161:                assertEquals(0, intArray[0]);
162:                for (int i = 1; i < intArray.length; ++i) {
163:                    assertEquals("rev int copy index " + i, i - 1, intArray[i]);
164:                }
165:                System.arraycopy(intArray, 1, intArray, 0, intArray.length - 1);
166:                for (int i = 0; i < intArray.length - 1; ++i) {
167:                    assertEquals("fwd int copy index " + i, i, intArray[i]);
168:                }
169:                assertEquals("fwd int copy index " + (intArray.length - 2),
170:                        intArray.length - 2, intArray[intArray.length - 1]);
171:                System.arraycopy(strArray, 0, strArray, 1, strArray.length - 1);
172:                assertEquals(0, Integer.valueOf(strArray[0]).intValue());
173:                for (int i = 1; i < strArray.length; ++i) {
174:                    assertEquals("rev str copy index " + i, i - 1, Integer
175:                            .valueOf(strArray[i]).intValue());
176:                }
177:                System.arraycopy(strArray, 1, strArray, 0, strArray.length - 1);
178:                for (int i = 0; i < strArray.length - 1; ++i) {
179:                    assertEquals("fwd str copy index " + i, i, Integer.valueOf(
180:                            strArray[i]).intValue());
181:                }
182:                assertEquals("fwd str copy index " + (strArray.length - 2),
183:                        strArray.length - 2, Integer.valueOf(
184:                                strArray[strArray.length - 1]).intValue());
185:                /*
186:                 * TODO(jat): how is it supposed to behave with overlapped copies if there
187:                 * is a failure in the middle of the copy? We should figure that out and
188:                 * test for it.
189:                 */
190:            }
191:
192:            public void testArraycopyPrimitives() {
193:                int[] src = new int[] { 0, 1, 2, 3, 4, 5, 6, 7 };
194:                int[] dest = new int[8];
195:
196:                System.arraycopy(src, 0, dest, 0, src.length);
197:                for (int i = 0; i < src.length; ++i) {
198:                    assertEquals(src[i], dest[i]);
199:                }
200:                System.arraycopy(src, 2, dest, 1, 5);
201:                assertEquals(0, dest[0]);
202:                for (int i = 1; i < 6; ++i) {
203:                    assertEquals(src[i + 1], dest[i]);
204:                }
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.