01: package org.drools.brms.client;
02:
03: /*
04: * Copyright 2005 JBoss Inc
05: *
06: * Licensed under the Apache License, Version 2.0 (the "License");
07: * you may not use this file except in compliance with the License.
08: * You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS,
14: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: */
18:
19: import java.lang.reflect.Method;
20:
21: import org.drools.brms.client.rpc.RepositoryService;
22: import org.drools.brms.client.rpc.RepositoryServiceAsync;
23: import org.drools.brms.client.rpc.SecurityService;
24: import org.drools.brms.client.rpc.SecurityServiceAsync;
25: import org.drools.brms.server.ServiceImplementation;
26:
27: import com.google.gwt.user.client.rpc.AsyncCallback;
28:
29: import junit.framework.TestCase;
30:
31: /**
32: * This will verify that the interfaces are kosher for GWT to use.
33: * @author Michael Neale
34: */
35: public class AsyncInterfaceTest extends TestCase {
36:
37: public void testService() throws Exception {
38:
39: checkService(RepositoryService.class,
40: RepositoryServiceAsync.class);
41: checkService(SecurityService.class, SecurityServiceAsync.class);
42:
43: }
44:
45: private void checkService(Class clsInt, Class clsAsync)
46: throws NoSuchMethodException {
47: for (Method m : clsInt.getMethods()) {
48:
49: Class[] paramClasses = new Class[m.getParameterTypes().length + 1];
50: Class[] sourceParamClasses = m.getParameterTypes();
51: for (int i = 0; i < sourceParamClasses.length; i++) {
52: paramClasses[i] = sourceParamClasses[i];
53: }
54: paramClasses[sourceParamClasses.length] = AsyncCallback.class;
55: assertNotNull(clsAsync.getMethod(m.getName(), paramClasses));
56: }
57: }
58:
59: }
|