aboutsummaryrefslogtreecommitdiffstats
path: root/server/src/test/java/com/vaadin/ui/ComponentTest.java
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2016-09-14 13:24:28 +0300
committerVaadin Code Review <review@vaadin.com>2016-09-14 12:25:36 +0000
commit5a95ba20104d3da4d64bcdac00236436321ca8b1 (patch)
tree90dafe20cff242bfe6527e8fa32b0c621e739f38 /server/src/test/java/com/vaadin/ui/ComponentTest.java
parenta7f874e9422fe8bc7dad15dadf74a32aa4c75c8d (diff)
downloadvaadin-framework-5a95ba20104d3da4d64bcdac00236436321ca8b1.tar.gz
vaadin-framework-5a95ba20104d3da4d64bcdac00236436321ca8b1.zip
Implement support for binding multi-select components
Also updates ComponentTest.getRpcProxy to use an approach that doesn't require the component to be attached to a UI. Change-Id: Iab4603a7818cd0fd2a3410660b90a2a839fb8a76
Diffstat (limited to 'server/src/test/java/com/vaadin/ui/ComponentTest.java')
-rw-r--r--server/src/test/java/com/vaadin/ui/ComponentTest.java34
1 files changed, 13 insertions, 21 deletions
diff --git a/server/src/test/java/com/vaadin/ui/ComponentTest.java b/server/src/test/java/com/vaadin/ui/ComponentTest.java
index 8cd9afa776..cc58dbbf93 100644
--- a/server/src/test/java/com/vaadin/ui/ComponentTest.java
+++ b/server/src/test/java/com/vaadin/ui/ComponentTest.java
@@ -15,12 +15,10 @@
*/
package com.vaadin.ui;
-import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
import com.vaadin.server.ClientConnector;
-import com.vaadin.server.ServerRpcMethodInvocation;
+import com.vaadin.server.ServerRpcManager;
import com.vaadin.shared.communication.ServerRpc;
/**
@@ -67,32 +65,26 @@ public class ComponentTest {
}
/**
- * Gets a proxy object which invokes ServerRpc methods.
+ * Gets the server rpc handler registered for a component.
*
* @param component
* the component which listens to the RPC
* @param serverRpcClass
* the server RPC class
- * @return a proxy which can be used to invoke RPC methods
+ * @return the server RPC handler
*/
- @SuppressWarnings("unchecked")
public static <T extends ServerRpc> T getRpcProxy(Component component,
Class<T> serverRpcClass) {
- return (T) Proxy.newProxyInstance(component.getClass().getClassLoader(),
- new Class[] { serverRpcClass }, new InvocationHandler() {
-
- @Override
- public Object invoke(Object proxy, Method method,
- Object[] args) throws Throwable {
- ServerRpcMethodInvocation invocation = new ServerRpcMethodInvocation(
- component.getConnectorId(), serverRpcClass,
- method.getName(), args.length);
- invocation.setParameters(args);
- component.getRpcManager(serverRpcClass.getName())
- .applyInvocation(invocation);
- return null;
- }
- });
+ try {
+ ServerRpcManager<?> rpcManager = component
+ .getRpcManager(serverRpcClass.getName());
+ Method method = ServerRpcManager.class
+ .getDeclaredMethod("getImplementation");
+ method.setAccessible(true);
+ return serverRpcClass.cast(method.invoke(rpcManager));
+ } catch (ReflectiveOperationException e) {
+ throw new RuntimeException(e);
+ }
}
}