Source Code Cross Referenced for RpcDispatcherAnycastMultipleCallsTest.java in  » Net » JGroups-2.4.1-sp3 » org » jgroups » blocks » 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 » Net » JGroups 2.4.1 sp3 » org.jgroups.blocks 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.jgroups.blocks;
002:
003:        import org.jgroups.tests.ChannelTestBase;
004:
005:        public class RpcDispatcherAnycastMultipleCallsTest extends
006:                ChannelTestBase {
007:            private RpcDispatcherAnycastServerObject[] targets = null;
008:
009:            public void tearDown() throws Exception {
010:                if (targets != null) {
011:                    for (int i = 0; i < targets.length; i++) {
012:                        if (targets[i] != null)
013:                            targets[i].shutdown();
014:                        targets[i] = null;
015:                    }
016:                    targets = null;
017:                }
018:                super .tearDown();
019:            }
020:
021:            public void test2InstancesAnycastIncludeSelf() throws Exception {
022:                performTest(true, 2, false);
023:            }
024:
025:            public void test3InstancesAnycastIncludeSelf() throws Exception {
026:                performTest(true, 3, false);
027:            }
028:
029:            public void test2InstancesMcastIncludeSelf() throws Exception {
030:                performTest(false, 2, false);
031:            }
032:
033:            public void test3InstancesMcastIncludeSelf() throws Exception {
034:                performTest(false, 3, false);
035:            }
036:
037:            public void test2InstancesAnycastExcludeSelf() throws Exception {
038:                performTest(true, 2, true);
039:            }
040:
041:            public void test3InstancesAnycastExcludeSelf() throws Exception {
042:                performTest(true, 3, true);
043:            }
044:
045:            public void test2InstancesMcastExcludeSelf() throws Exception {
046:                performTest(false, 2, true);
047:            }
048:
049:            public void test3InstancesMcastExcludeSelf() throws Exception {
050:                performTest(false, 3, true);
051:            }
052:
053:            /**
054:             * Simple test that creates n instances of {@link org.jgroups.blocks.RpcDispatcherAnycastServerObject}, each one creates a Channel
055:             * and registers an RpcDispatcher.
056:             *
057:             * This test then calls {@link org.jgroups.blocks.RpcDispatcherAnycastServerObject#callRemote(boolean, boolean)} once on each of the n instances
058:             * and then tests that the method calls have in fact been executed on each of the n instances.
059:             *
060:             * @param useAnycast if true, anycast is used for remote calls.
061:             * @param n number of instances
062:             * @param excludeSelf whether or not  to exclude self in rpc calls
063:             */
064:            private void performTest(boolean useAnycast, int n,
065:                    boolean excludeSelf) throws Exception {
066:                // create n instances
067:                targets = new RpcDispatcherAnycastServerObject[n];
068:                for (int i = 0; i < n; i++) {
069:                    targets[i] = new RpcDispatcherAnycastServerObject(
070:                            createChannel("A"));
071:                }
072:
073:                // test that the target method has been invoked 0 times on each instance.
074:                for (int i = 0; i < n; i++)
075:                    assertEquals(0, targets[i].i);
076:
077:                // if we don't exclude self, the state of all instances should be identical.
078:                int value = 0;
079:
080:                // if we are excluding self, we need an array of expected values.
081:                int[] expectedValues = null;
082:
083:                if (excludeSelf) {
084:                    expectedValues = new int[n];
085:                    for (int i = 0; i < n; i++)
086:                        expectedValues[i] = 0;
087:                }
088:
089:                for (int instances = 0; instances < n; instances++) {
090:                    targets[instances].callRemote(useAnycast, excludeSelf);
091:
092:                    // the assertions and how we measure test success is different depending on whether we exclude self or not.
093:
094:                    if (excludeSelf) {
095:                        for (int i = 0; i < n; i++) {
096:                            if (i != instances)
097:                                expectedValues[i]++;
098:                        }
099:                        for (int i = 0; i < n; i++)
100:                            assertEquals(
101:                                    "Failure when invoking call on instance "
102:                                            + instances
103:                                            + ".  Did not reach instance " + i
104:                                            + ".", expectedValues[i],
105:                                    targets[i].i);
106:                    } else {
107:                        value++;
108:                        for (int i = 0; i < n; i++)
109:                            assertEquals(
110:                                    "Failure when invoking call on instance "
111:                                            + instances
112:                                            + ".  Did not reach instance " + i
113:                                            + ".", value, targets[i].i);
114:                    }
115:                }
116:
117:            }
118:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.