KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > wsdl > jaxrpchandlereval > HandlerTracker


1 package test.wsdl.jaxrpchandlereval;
2
3 import java.util.*;
4
5 public class HandlerTracker {
6     private static List clientHandlers;
7     private static List serverHandlers;
8
9     public static void init() {
10         clientHandlers = new ArrayList();
11         serverHandlers = new ArrayList();
12     }
13
14     public static void addClientHandler(String JavaDoc s) {
15         clientHandlers.add(s);
16     }
17
18     public static void addServerHandler(String JavaDoc s) {
19         serverHandlers.add(s);
20     }
21
22     public static void assertClientHandlerOrder(String JavaDoc[] arr) throws Exception JavaDoc {
23         assertHandlerOrder(clientHandlers, arr);
24     }
25
26     public static void assertServerHandlerOrder(String JavaDoc[] arr) throws Exception JavaDoc {
27         assertHandlerOrder(serverHandlers, arr);
28     }
29
30     public static void assertHandlerOrder(List handlers, String JavaDoc[] expected) throws Exception JavaDoc {
31         String JavaDoc[] actual = new String JavaDoc[handlers.size()];
32         handlers.toArray(actual);
33
34         System.out.print("excepted order:");
35         for (int i = 0; i < expected.length; i++) {
36             System.out.print(expected[i] + " ");
37         }
38         System.out.println("\n");
39
40         System.out.print("actual order:");
41         for (int i = 0; i < actual.length; i++) {
42             System.out.print(actual[i] + " ");
43         }
44         System.out.println("\n");
45         
46         if (expected.length != actual.length) {
47             throw new Exception JavaDoc("Handler length not match");
48         }
49
50         System.out.println("\n");
51         for (int i = 0; i < expected.length; i++) {
52             if (!expected[i].equals(actual[i])) {
53                 throw new Exception JavaDoc("Handler order not match : expected = " + expected[i] + ", actual = " + actual[i]);
54             }
55         }
56         return;
57     }
58
59 }
60
Popular Tags