diff options
author | Leif Åstrand <leif@vaadin.com> | 2014-01-07 13:13:58 +0200 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2014-01-08 09:20:43 +0000 |
commit | 171e68da0d072cb7a7f256d2d27c8b2674759358 (patch) | |
tree | 1fb02162654eedf76a06c484ba6f611fa954d8a5 | |
parent | 5e8e866664f0301ab442c0013bdec0f27e9f550d (diff) | |
download | vaadin-framework-171e68da0d072cb7a7f256d2d27c8b2674759358.tar.gz vaadin-framework-171e68da0d072cb7a7f256d2d27c8b2674759358.zip |
Only use ClientRcp and ServerRpc types that are interfaces (#13056)
Change-Id: I73b062628052ec545d5f53314a0cc479806ee89d
6 files changed, 186 insertions, 2 deletions
diff --git a/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/ConnectorBundle.java b/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/ConnectorBundle.java index cbdd3e89aa..4d6a7ff6d7 100644 --- a/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/ConnectorBundle.java +++ b/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/ConnectorBundle.java @@ -430,11 +430,11 @@ public class ConnectorBundle { } private static boolean isClientRpc(JClassType type) { - return isType(type, ClientRpc.class); + return isInterfaceType(type, ClientRpc.class); } private static boolean isServerRpc(JClassType type) { - return isType(type, ServerRpc.class); + return isInterfaceType(type, ServerRpc.class); } public static boolean isConnectedConnector(JClassType type) { @@ -451,6 +451,10 @@ public class ConnectorBundle { return isConnected(type) && isType(type, ComponentConnector.class); } + private static boolean isInterfaceType(JClassType type, Class<?> class1) { + return type.isInterface() != null && isType(type, class1); + } + private static boolean isType(JClassType type, Class<?> class1) { try { return type.getOracle().getType(class1.getName()) diff --git a/uitest/src/com/vaadin/tests/widgetset/client/ClientRpcClassConnector.java b/uitest/src/com/vaadin/tests/widgetset/client/ClientRpcClassConnector.java new file mode 100644 index 0000000000..fb28e94bfa --- /dev/null +++ b/uitest/src/com/vaadin/tests/widgetset/client/ClientRpcClassConnector.java @@ -0,0 +1,36 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.widgetset.client; + +import com.vaadin.client.ui.label.LabelConnector; +import com.vaadin.shared.ui.Connect; +import com.vaadin.shared.ui.MediaControl; +import com.vaadin.tests.widgetset.server.ClientRpcClassComponent; + +@Connect(ClientRpcClassComponent.class) +public class ClientRpcClassConnector extends LabelConnector { + + @Override + protected void init() { + super.init(); + registerRpc(MediaControl.class, getWidget()); + } + + @Override + public ClientRpcClassWidget getWidget() { + return (ClientRpcClassWidget) super.getWidget(); + } +} diff --git a/uitest/src/com/vaadin/tests/widgetset/client/ClientRpcClassWidget.java b/uitest/src/com/vaadin/tests/widgetset/client/ClientRpcClassWidget.java new file mode 100644 index 0000000000..91b4f19d92 --- /dev/null +++ b/uitest/src/com/vaadin/tests/widgetset/client/ClientRpcClassWidget.java @@ -0,0 +1,33 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.widgetset.client; + +import com.vaadin.client.ui.VLabel; +import com.vaadin.shared.ui.MediaControl; + +public class ClientRpcClassWidget extends VLabel implements MediaControl { + + @Override + public void play() { + setText("play"); + } + + @Override + public void pause() { + setText("pause"); + } + +} diff --git a/uitest/src/com/vaadin/tests/widgetset/server/ClientRpcClass.java b/uitest/src/com/vaadin/tests/widgetset/server/ClientRpcClass.java new file mode 100644 index 0000000000..cbc46b26f5 --- /dev/null +++ b/uitest/src/com/vaadin/tests/widgetset/server/ClientRpcClass.java @@ -0,0 +1,47 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.widgetset.server; + +import com.vaadin.annotations.Widgetset; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.tests.widgetset.TestingWidgetSet; + +@Widgetset(TestingWidgetSet.NAME) +public class ClientRpcClass extends AbstractTestUI { + + public static String TEST_COMPONENT_ID = "testComponent"; + + @Override + protected void setup(VaadinRequest request) { + ClientRpcClassComponent component = new ClientRpcClassComponent(); + component.setId(TEST_COMPONENT_ID); + addComponent(component); + + component.pause(); + } + + @Override + protected String getTestDescription() { + return "UI showing dummy component where the wiget type is implementing the RPC interface."; + } + + @Override + protected Integer getTicketNumber() { + return Integer.valueOf(13056); + } + +} diff --git a/uitest/src/com/vaadin/tests/widgetset/server/ClientRpcClassComponent.java b/uitest/src/com/vaadin/tests/widgetset/server/ClientRpcClassComponent.java new file mode 100644 index 0000000000..135f112fe4 --- /dev/null +++ b/uitest/src/com/vaadin/tests/widgetset/server/ClientRpcClassComponent.java @@ -0,0 +1,29 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.widgetset.server; + +import com.vaadin.shared.ui.MediaControl; +import com.vaadin.ui.Label; + +public class ClientRpcClassComponent extends Label { + public void play() { + getRpcProxy(MediaControl.class).play(); + } + + public void pause() { + getRpcProxy(MediaControl.class).pause(); + } +} diff --git a/uitest/src/com/vaadin/tests/widgetset/server/ClientRpcClassTest.java b/uitest/src/com/vaadin/tests/widgetset/server/ClientRpcClassTest.java new file mode 100644 index 0000000000..16c5ba4b61 --- /dev/null +++ b/uitest/src/com/vaadin/tests/widgetset/server/ClientRpcClassTest.java @@ -0,0 +1,35 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.widgetset.server; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class ClientRpcClassTest extends MultiBrowserTest { + + @Test + public void pauseDisplayed() { + openTestURL(); + + WebElement element = getDriver().findElement( + By.id(ClientRpcClass.TEST_COMPONENT_ID)); + Assert.assertEquals("pause", element.getText()); + } +} |