Source Code Cross Referenced for ValueTypesTest.java in  » Ajax » GWT » com » google » gwt » user » client » rpc » 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.user.client.rpc 
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.user.client.rpc;
017:
018:        import com.google.gwt.core.client.GWT;
019:        import com.google.gwt.junit.client.GWTTestCase;
020:
021:        /**
022:         * TODO: document me.
023:         */
024:        public class ValueTypesTest extends GWTTestCase {
025:            private static final int TEST_DELAY = 5000;
026:
027:            public String getModuleName() {
028:                return "com.google.gwt.user.RPCSuite";
029:            }
030:
031:            public void testBoolean_FALSE() {
032:                delayTestFinish(TEST_DELAY);
033:                ValueTypesTestServiceAsync service = getServiceAsync();
034:                service.echo_FALSE(false, new AsyncCallback() {
035:
036:                    public void onFailure(Throwable caught) {
037:                        TestSetValidator.rethrowException(caught);
038:                    }
039:
040:                    public void onSuccess(Object result) {
041:                        assertNotNull(result);
042:                        assertFalse(((Boolean) result).booleanValue());
043:                        finishTest();
044:                    }
045:                });
046:            }
047:
048:            public void testBoolean_TRUE() {
049:                delayTestFinish(TEST_DELAY);
050:                ValueTypesTestServiceAsync service = getServiceAsync();
051:                service.echo_TRUE(true, new AsyncCallback() {
052:
053:                    public void onFailure(Throwable caught) {
054:                        TestSetValidator.rethrowException(caught);
055:                    }
056:
057:                    public void onSuccess(Object result) {
058:                        assertNotNull(result);
059:                        assertTrue(((Boolean) result).booleanValue());
060:                        finishTest();
061:                    }
062:                });
063:            }
064:
065:            public void testByte() {
066:                delayTestFinish(TEST_DELAY);
067:                ValueTypesTestServiceAsync service = getServiceAsync();
068:                service.echo((byte) (Byte.MAX_VALUE / (byte) 2),
069:                        new AsyncCallback() {
070:
071:                            public void onFailure(Throwable caught) {
072:                                TestSetValidator.rethrowException(caught);
073:                            }
074:
075:                            public void onSuccess(Object result) {
076:                                assertNotNull(result);
077:                                assertEquals(Byte.MAX_VALUE / 2,
078:                                        ((Byte) result).byteValue());
079:                                finishTest();
080:                            }
081:                        });
082:            }
083:
084:            public void testByte_MAX_VALUE() {
085:                delayTestFinish(TEST_DELAY);
086:                ValueTypesTestServiceAsync service = getServiceAsync();
087:                service.echo_MAX_VALUE(Byte.MAX_VALUE, new AsyncCallback() {
088:
089:                    public void onFailure(Throwable caught) {
090:                        TestSetValidator.rethrowException(caught);
091:                    }
092:
093:                    public void onSuccess(Object result) {
094:                        assertNotNull(result);
095:                        assertEquals(Byte.MAX_VALUE, ((Byte) result)
096:                                .byteValue());
097:                        finishTest();
098:                    }
099:                });
100:            }
101:
102:            public void testByte_MIN_VALUE() {
103:                delayTestFinish(TEST_DELAY);
104:                ValueTypesTestServiceAsync service = getServiceAsync();
105:                service.echo_MIN_VALUE(Byte.MIN_VALUE, new AsyncCallback() {
106:
107:                    public void onFailure(Throwable caught) {
108:                        TestSetValidator.rethrowException(caught);
109:                    }
110:
111:                    public void onSuccess(Object result) {
112:                        assertNotNull(result);
113:                        assertEquals(Byte.MIN_VALUE, ((Byte) result)
114:                                .byteValue());
115:                        finishTest();
116:                    }
117:                });
118:            }
119:
120:            public void testChar() {
121:                delayTestFinish(TEST_DELAY);
122:                ValueTypesTestServiceAsync service = getServiceAsync();
123:                service.echo((char) (Character.MAX_VALUE / (char) 2),
124:                        new AsyncCallback() {
125:
126:                            public void onFailure(Throwable caught) {
127:                                TestSetValidator.rethrowException(caught);
128:                            }
129:
130:                            public void onSuccess(Object result) {
131:                                assertNotNull(result);
132:                                assertEquals(
133:                                        (char) (Character.MAX_VALUE / (char) 2),
134:                                        ((Character) result).charValue());
135:                                finishTest();
136:                            }
137:                        });
138:            }
139:
140:            public void testChar_MAX_VALUE() {
141:                delayTestFinish(TEST_DELAY);
142:                ValueTypesTestServiceAsync service = getServiceAsync();
143:                service.echo_MAX_VALUE(Character.MAX_VALUE,
144:                        new AsyncCallback() {
145:
146:                            public void onFailure(Throwable caught) {
147:                                TestSetValidator.rethrowException(caught);
148:                            }
149:
150:                            public void onSuccess(Object result) {
151:                                assertNotNull(result);
152:                                assertEquals(Character.MAX_VALUE,
153:                                        ((Character) result).charValue());
154:                                finishTest();
155:                            }
156:                        });
157:            }
158:
159:            public void testChar_MIN_VALUE() {
160:                delayTestFinish(TEST_DELAY);
161:                ValueTypesTestServiceAsync service = getServiceAsync();
162:                service.echo_MIN_VALUE(Character.MIN_VALUE,
163:                        new AsyncCallback() {
164:
165:                            public void onFailure(Throwable caught) {
166:                                TestSetValidator.rethrowException(caught);
167:                            }
168:
169:                            public void onSuccess(Object result) {
170:                                assertNotNull(result);
171:                                assertEquals(Character.MIN_VALUE,
172:                                        ((Character) result).charValue());
173:                                finishTest();
174:                            }
175:                        });
176:            }
177:
178:            public void testDouble() {
179:                delayTestFinish(TEST_DELAY);
180:                ValueTypesTestServiceAsync service = getServiceAsync();
181:                service.echo(Double.MAX_VALUE / 2, new AsyncCallback() {
182:
183:                    public void onFailure(Throwable caught) {
184:                        TestSetValidator.rethrowException(caught);
185:                    }
186:
187:                    public void onSuccess(Object result) {
188:                        assertNotNull(result);
189:                        assertEquals(Double.MAX_VALUE / 2, ((Double) result)
190:                                .doubleValue(), 0.0);
191:                        finishTest();
192:                    }
193:                });
194:            }
195:
196:            public void testDouble_MAX_VALUE() {
197:                delayTestFinish(TEST_DELAY);
198:                ValueTypesTestServiceAsync service = getServiceAsync();
199:                service.echo_MAX_VALUE(Double.MAX_VALUE, new AsyncCallback() {
200:
201:                    public void onFailure(Throwable caught) {
202:                        TestSetValidator.rethrowException(caught);
203:                    }
204:
205:                    public void onSuccess(Object result) {
206:                        assertNotNull(result);
207:                        assertEquals(Double.MAX_VALUE, ((Double) result)
208:                                .doubleValue(), 0.0);
209:                        finishTest();
210:                    }
211:                });
212:            }
213:
214:            public void testDouble_MIN_VALUE() {
215:                delayTestFinish(TEST_DELAY);
216:                ValueTypesTestServiceAsync service = getServiceAsync();
217:                service.echo_MIN_VALUE(Double.MIN_VALUE, new AsyncCallback() {
218:
219:                    public void onFailure(Throwable caught) {
220:                        TestSetValidator.rethrowException(caught);
221:                    }
222:
223:                    public void onSuccess(Object result) {
224:                        assertNotNull(result);
225:                        assertEquals(Double.MIN_VALUE, ((Double) result)
226:                                .doubleValue(), 0.0);
227:                        finishTest();
228:                    }
229:                });
230:            }
231:
232:            /**
233:             * Validate that NaNs (not-a-number, such as 0/0) propagate
234:             * properly via RPC.
235:             */
236:            public void testDouble_NaN() {
237:                delayTestFinish(TEST_DELAY);
238:                ValueTypesTestServiceAsync service = getServiceAsync();
239:                service.echo(Double.NaN, new AsyncCallback() {
240:
241:                    public void onFailure(Throwable caught) {
242:                        TestSetValidator.rethrowException(caught);
243:                    }
244:
245:                    public void onSuccess(Object result) {
246:                        assertNotNull(result);
247:                        assertTrue(Double
248:                                .isNaN(((Double) result).doubleValue()));
249:                        finishTest();
250:                    }
251:                });
252:            }
253:
254:            /**
255:             * Validate that negative infinity propagates properly via RPC.
256:             */
257:            public void testDouble_NegInfinity() {
258:                delayTestFinish(TEST_DELAY);
259:                ValueTypesTestServiceAsync service = getServiceAsync();
260:                service.echo(Double.NEGATIVE_INFINITY, new AsyncCallback() {
261:
262:                    public void onFailure(Throwable caught) {
263:                        TestSetValidator.rethrowException(caught);
264:                    }
265:
266:                    public void onSuccess(Object result) {
267:                        assertNotNull(result);
268:                        double doubleValue = ((Double) result).doubleValue();
269:                        assertTrue(Double.isInfinite(doubleValue)
270:                                && doubleValue < 0);
271:                        finishTest();
272:                    }
273:                });
274:            }
275:
276:            /**
277:             * Validate that positive infinity propagates properly via RPC.
278:             */
279:            public void testDouble_PosInfinity() {
280:                delayTestFinish(TEST_DELAY);
281:                ValueTypesTestServiceAsync service = getServiceAsync();
282:                service.echo(Double.POSITIVE_INFINITY, new AsyncCallback() {
283:
284:                    public void onFailure(Throwable caught) {
285:                        TestSetValidator.rethrowException(caught);
286:                    }
287:
288:                    public void onSuccess(Object result) {
289:                        assertNotNull(result);
290:                        double doubleValue = ((Double) result).doubleValue();
291:                        assertTrue(Double.isInfinite(doubleValue)
292:                                && doubleValue > 0);
293:                        finishTest();
294:                    }
295:                });
296:            }
297:
298:            public void testFloat() {
299:                delayTestFinish(TEST_DELAY);
300:                ValueTypesTestServiceAsync service = getServiceAsync();
301:                service.echo(Float.MAX_VALUE / 2, new AsyncCallback() {
302:
303:                    public void onFailure(Throwable caught) {
304:                        TestSetValidator.rethrowException(caught);
305:                    }
306:
307:                    public void onSuccess(Object result) {
308:                        assertNotNull(result);
309:                        assertEquals(Float.MAX_VALUE / 2, ((Float) result)
310:                                .floatValue(), 0.0);
311:                        finishTest();
312:                    }
313:                });
314:            }
315:
316:            public void testFloat_MAX_VALUE() {
317:                delayTestFinish(TEST_DELAY);
318:                ValueTypesTestServiceAsync service = getServiceAsync();
319:                service.echo_MAX_VALUE(Float.MAX_VALUE, new AsyncCallback() {
320:
321:                    public void onFailure(Throwable caught) {
322:                        TestSetValidator.rethrowException(caught);
323:                    }
324:
325:                    public void onSuccess(Object result) {
326:                        assertNotNull(result);
327:                        assertEquals(Float.MAX_VALUE, ((Float) result)
328:                                .floatValue(), 0.0);
329:                        finishTest();
330:                    }
331:                });
332:            }
333:
334:            public void testFloat_MIN_VALUE() {
335:                delayTestFinish(TEST_DELAY);
336:                ValueTypesTestServiceAsync service = getServiceAsync();
337:                service.echo_MIN_VALUE(Float.MIN_VALUE, new AsyncCallback() {
338:
339:                    public void onFailure(Throwable caught) {
340:                        TestSetValidator.rethrowException(caught);
341:                    }
342:
343:                    public void onSuccess(Object result) {
344:                        assertNotNull(result);
345:                        assertEquals(Float.MIN_VALUE, ((Float) result)
346:                                .floatValue(), 0.0);
347:                        finishTest();
348:                    }
349:                });
350:            }
351:
352:            /**
353:             * Validate that NaNs (not-a-number, such as 0/0) propagate
354:             * properly via RPC.
355:             */
356:            public void testFloat_NaN() {
357:                delayTestFinish(TEST_DELAY);
358:                ValueTypesTestServiceAsync service = getServiceAsync();
359:                service.echo(Float.NaN, new AsyncCallback() {
360:
361:                    public void onFailure(Throwable caught) {
362:                        TestSetValidator.rethrowException(caught);
363:                    }
364:
365:                    public void onSuccess(Object result) {
366:                        assertNotNull(result);
367:                        assertTrue(Float.isNaN(((Float) result).floatValue()));
368:                        finishTest();
369:                    }
370:                });
371:            }
372:
373:            /**
374:             * Validate that negative infinity propagates properly via RPC.
375:             */
376:            public void testFloat_NegInfinity() {
377:                delayTestFinish(TEST_DELAY);
378:                ValueTypesTestServiceAsync service = getServiceAsync();
379:                service.echo(Float.NEGATIVE_INFINITY, new AsyncCallback() {
380:
381:                    public void onFailure(Throwable caught) {
382:                        TestSetValidator.rethrowException(caught);
383:                    }
384:
385:                    public void onSuccess(Object result) {
386:                        assertNotNull(result);
387:                        float floatValue = ((Float) result).floatValue();
388:                        assertTrue(Float.isInfinite(floatValue)
389:                                && floatValue < 0);
390:                        finishTest();
391:                    }
392:                });
393:            }
394:
395:            /**
396:             * Validate that positive infinity propagates properly via RPC.
397:             */
398:            public void testFloat_PosInfinity() {
399:                delayTestFinish(TEST_DELAY);
400:                ValueTypesTestServiceAsync service = getServiceAsync();
401:                service.echo(Float.POSITIVE_INFINITY, new AsyncCallback() {
402:
403:                    public void onFailure(Throwable caught) {
404:                        TestSetValidator.rethrowException(caught);
405:                    }
406:
407:                    public void onSuccess(Object result) {
408:                        assertNotNull(result);
409:                        float floatValue = ((Float) result).floatValue();
410:                        assertTrue(Float.isInfinite(floatValue)
411:                                && floatValue > 0);
412:                        finishTest();
413:                    }
414:                });
415:            }
416:
417:            public void testInteger() {
418:                delayTestFinish(TEST_DELAY);
419:                ValueTypesTestServiceAsync service = getServiceAsync();
420:                service.echo(Integer.MAX_VALUE / 2, new AsyncCallback() {
421:
422:                    public void onFailure(Throwable caught) {
423:                        TestSetValidator.rethrowException(caught);
424:                    }
425:
426:                    public void onSuccess(Object result) {
427:                        assertNotNull(result);
428:                        assertEquals(Integer.MAX_VALUE / 2, ((Integer) result)
429:                                .intValue());
430:                        finishTest();
431:                    }
432:                });
433:            }
434:
435:            public void testInteger_MAX_VALUE() {
436:                delayTestFinish(TEST_DELAY);
437:                ValueTypesTestServiceAsync service = getServiceAsync();
438:                service.echo_MAX_VALUE(Integer.MAX_VALUE, new AsyncCallback() {
439:
440:                    public void onFailure(Throwable caught) {
441:                        TestSetValidator.rethrowException(caught);
442:                    }
443:
444:                    public void onSuccess(Object result) {
445:                        assertNotNull(result);
446:                        assertEquals(Integer.MAX_VALUE, ((Integer) result)
447:                                .intValue());
448:                        finishTest();
449:                    }
450:                });
451:            }
452:
453:            public void testInteger_MIN_VALUE() {
454:                delayTestFinish(TEST_DELAY);
455:                ValueTypesTestServiceAsync service = getServiceAsync();
456:                service.echo_MIN_VALUE(Integer.MIN_VALUE, new AsyncCallback() {
457:
458:                    public void onFailure(Throwable caught) {
459:                        TestSetValidator.rethrowException(caught);
460:                    }
461:
462:                    public void onSuccess(Object result) {
463:                        assertNotNull(result);
464:                        assertEquals(Integer.MIN_VALUE, ((Integer) result)
465:                                .intValue());
466:                        finishTest();
467:                    }
468:                });
469:            }
470:
471:            public void disabledTestLong() {
472:                delayTestFinish(TEST_DELAY);
473:                ValueTypesTestServiceAsync service = getServiceAsync();
474:                service.echo(Long.MAX_VALUE / 2, new AsyncCallback() {
475:
476:                    public void onFailure(Throwable caught) {
477:                        TestSetValidator.rethrowException(caught);
478:                    }
479:
480:                    public void onSuccess(Object result) {
481:                        assertNotNull(result);
482:                        long expected = Long.MAX_VALUE / 2;
483:                        // TODO: resolve off-by-one problem (probably just a side effect of
484:                        // loss of precision).
485:                        // ++expected;
486:                        assertEquals(expected, ((Long) result).longValue());
487:                        finishTest();
488:                    }
489:                });
490:            }
491:
492:            public void disabledTestLong_MAX_VALUE() {
493:                delayTestFinish(TEST_DELAY);
494:                ValueTypesTestServiceAsync service = getServiceAsync();
495:                service.echo_MAX_VALUE(Long.MAX_VALUE, new AsyncCallback() {
496:
497:                    public void onFailure(Throwable caught) {
498:                        TestSetValidator.rethrowException(caught);
499:                    }
500:
501:                    public void onSuccess(Object result) {
502:                        assertNotNull(result);
503:                        assertEquals(Long.MAX_VALUE, ((Long) result)
504:                                .longValue());
505:                        finishTest();
506:                    }
507:                });
508:            }
509:
510:            public void disabledTestLong_MIN_VALUE() {
511:                delayTestFinish(TEST_DELAY);
512:                ValueTypesTestServiceAsync service = getServiceAsync();
513:                service.echo_MIN_VALUE(Long.MIN_VALUE, new AsyncCallback() {
514:
515:                    public void onFailure(Throwable caught) {
516:                        TestSetValidator.rethrowException(caught);
517:                    }
518:
519:                    public void onSuccess(Object result) {
520:                        assertNotNull(result);
521:                        assertEquals(Long.MIN_VALUE, ((Long) result)
522:                                .longValue());
523:                        finishTest();
524:                    }
525:                });
526:            }
527:
528:            public void testShort() {
529:                delayTestFinish(TEST_DELAY);
530:                ValueTypesTestServiceAsync service = getServiceAsync();
531:                service.echo((short) (Short.MAX_VALUE / (short) 2),
532:                        new AsyncCallback() {
533:
534:                            public void onFailure(Throwable caught) {
535:                                TestSetValidator.rethrowException(caught);
536:                            }
537:
538:                            public void onSuccess(Object result) {
539:                                assertNotNull(result);
540:                                assertEquals(Short.MAX_VALUE / 2,
541:                                        ((Short) result).shortValue());
542:                                finishTest();
543:                            }
544:                        });
545:            }
546:
547:            public void testShort_MAX_VALUE() {
548:                delayTestFinish(TEST_DELAY);
549:                ValueTypesTestServiceAsync service = getServiceAsync();
550:                service.echo_MAX_VALUE(Short.MAX_VALUE, new AsyncCallback() {
551:
552:                    public void onFailure(Throwable caught) {
553:                        TestSetValidator.rethrowException(caught);
554:                    }
555:
556:                    public void onSuccess(Object result) {
557:                        assertNotNull(result);
558:                        assertEquals(Short.MAX_VALUE, ((Short) result)
559:                                .shortValue());
560:                        finishTest();
561:                    }
562:                });
563:            }
564:
565:            public void testShort_MIN_VALUE() {
566:                delayTestFinish(TEST_DELAY);
567:                ValueTypesTestServiceAsync service = getServiceAsync();
568:                service.echo_MIN_VALUE(Short.MIN_VALUE, new AsyncCallback() {
569:
570:                    public void onFailure(Throwable caught) {
571:                        TestSetValidator.rethrowException(caught);
572:                    }
573:
574:                    public void onSuccess(Object result) {
575:                        assertNotNull(result);
576:                        assertEquals(Short.MIN_VALUE, ((Short) result)
577:                                .shortValue());
578:                        finishTest();
579:                    }
580:                });
581:            }
582:
583:            private ValueTypesTestServiceAsync getServiceAsync() {
584:                if (primitiveTypeTestService == null) {
585:                    primitiveTypeTestService = (ValueTypesTestServiceAsync) GWT
586:                            .create(ValueTypesTestService.class);
587:                    ((ServiceDefTarget) primitiveTypeTestService)
588:                            .setServiceEntryPoint(GWT.getModuleBaseURL()
589:                                    + "valuetypes");
590:                }
591:                return primitiveTypeTestService;
592:            }
593:
594:            private ValueTypesTestServiceAsync primitiveTypeTestService;
595:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.