diff options
author | Artur Signell <artur@vaadin.com> | 2015-04-16 16:40:36 +0300 |
---|---|---|
committer | Artur Signell <artur@vaadin.com> | 2015-07-13 17:19:07 +0300 |
commit | 90b4c678d139fc4927811cdcad87d0b91eca98b6 (patch) | |
tree | 67dc629b9627efcebeabb0d0360f20f304e8615a /uitest | |
parent | 2e8d06f89b99a63f4b4fa6ece11b4119ae55fd57 (diff) | |
download | vaadin-framework-90b4c678d139fc4927811cdcad87d0b91eca98b6.tar.gz vaadin-framework-90b4c678d139fc4927811cdcad87d0b91eca98b6.zip |
Separate server message sending to its own class (#11733)
Change-Id: Ib3c4ac687387f2a239908b7e25e2753dbbf7e98b
Diffstat (limited to 'uitest')
-rw-r--r-- | uitest/src/com/vaadin/tests/widgetset/client/MockApplicationConnection.java | 25 | ||||
-rw-r--r-- | uitest/src/com/vaadin/tests/widgetset/client/MockServerCommunicationHandler.java | 36 |
2 files changed, 45 insertions, 16 deletions
diff --git a/uitest/src/com/vaadin/tests/widgetset/client/MockApplicationConnection.java b/uitest/src/com/vaadin/tests/widgetset/client/MockApplicationConnection.java index b6d8495a64..2ff8948e29 100644 --- a/uitest/src/com/vaadin/tests/widgetset/client/MockApplicationConnection.java +++ b/uitest/src/com/vaadin/tests/widgetset/client/MockApplicationConnection.java @@ -16,12 +16,8 @@ package com.vaadin.tests.widgetset.client; import com.vaadin.client.ApplicationConnection; -import com.vaadin.shared.ApplicationConstants; import com.vaadin.tests.widgetset.server.csrf.ui.CsrfTokenDisabled; -import elemental.json.JsonObject; -import elemental.json.JsonValue; - /** * Mock ApplicationConnection for several issues where we need to hack it. * @@ -34,16 +30,21 @@ public class MockApplicationConnection extends ApplicationConnection { super(); serverMessageHandler = new MockServerMessageHandler(); serverMessageHandler.setConnection(this); + serverCommunicationHandler = new MockServerCommunicationHandler(); + serverCommunicationHandler.setConnection(this); } - // The last token sent to the server. - private String lastCsrfTokenSent; - @Override public MockServerMessageHandler getServerMessageHandler() { return (MockServerMessageHandler) super.getServerMessageHandler(); } + @Override + public MockServerCommunicationHandler getServerCommunicationHandler() { + return (MockServerCommunicationHandler) super + .getServerCommunicationHandler(); + } + /** * Provide the last token received from the server. <br/> * We added this to test the change done on CSRF token. @@ -61,15 +62,7 @@ public class MockApplicationConnection extends ApplicationConnection { * @see CsrfTokenDisabled */ public String getLastCsrfTokenSent() { - return lastCsrfTokenSent; - } - - @Override - public void doUidlRequest(String uri, JsonObject payload, boolean retry) { - JsonValue jsonValue = payload.get(ApplicationConstants.CSRF_TOKEN); - lastCsrfTokenSent = jsonValue != null ? jsonValue.toJson() : null; - - super.doUidlRequest(uri, payload, retry); + return getServerCommunicationHandler().lastCsrfTokenSent; } } diff --git a/uitest/src/com/vaadin/tests/widgetset/client/MockServerCommunicationHandler.java b/uitest/src/com/vaadin/tests/widgetset/client/MockServerCommunicationHandler.java new file mode 100644 index 0000000000..54feeece78 --- /dev/null +++ b/uitest/src/com/vaadin/tests/widgetset/client/MockServerCommunicationHandler.java @@ -0,0 +1,36 @@ +/* + * Copyright 2000-2014 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.communication.ServerCommunicationHandler; +import com.vaadin.shared.ApplicationConstants; + +import elemental.json.JsonObject; +import elemental.json.JsonValue; + +public class MockServerCommunicationHandler extends ServerCommunicationHandler { + + // The last token sent to the server. + String lastCsrfTokenSent; + + @Override + public void doUidlRequest(String uri, JsonObject payload, boolean retry) { + JsonValue jsonValue = payload.get(ApplicationConstants.CSRF_TOKEN); + lastCsrfTokenSent = jsonValue != null ? jsonValue.toJson() : null; + + super.doUidlRequest(uri, payload, retry); + } +} |