-
Notifications
You must be signed in to change notification settings - Fork 730
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle unknown connectors consistently and quietly as described in #8111
- Loading branch information
1 parent
637afe2
commit 4ecf4f9
Showing
2 changed files
with
63 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
server/src/test/java/com/vaadin/server/communication/ServerRpcHandlerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package com.vaadin.server.communication; | ||
|
||
import org.junit.Test; | ||
import org.mockito.Mockito; | ||
|
||
import com.vaadin.server.VaadinRequest; | ||
import com.vaadin.server.VaadinService; | ||
import com.vaadin.tests.util.AlwaysLockedVaadinSession; | ||
import com.vaadin.ui.UI; | ||
|
||
import elemental.json.Json; | ||
import elemental.json.JsonArray; | ||
|
||
public class ServerRpcHandlerTest { | ||
|
||
public static class TestUI extends UI { | ||
|
||
@Override | ||
protected void init(VaadinRequest request) { | ||
|
||
} | ||
|
||
} | ||
|
||
@Test | ||
public void handleUnknownConnector() { | ||
ServerRpcHandler rpcHandler = new ServerRpcHandler(); | ||
JsonArray invocation = Json.createArray(); | ||
invocation.set(0, "12"); | ||
invocation.set(1, "someInterface"); | ||
invocation.set(2, "someMethod"); | ||
JsonArray params = Json.createArray(); | ||
invocation.set(3, params); | ||
|
||
JsonArray invocationData = Json.createArray(); | ||
invocationData.set(0, invocation); | ||
|
||
AlwaysLockedVaadinSession s = new AlwaysLockedVaadinSession( | ||
Mockito.mock(VaadinService.class)); | ||
TestUI ui = new TestUI(); | ||
ui.doInit(Mockito.mock(VaadinRequest.class), 1, null); | ||
ui.setSession(s); | ||
s.addUI(ui); | ||
rpcHandler.handleInvocations(ui, 1, invocationData); | ||
|
||
// This only tests that an invocation for a non-existant connector does | ||
// not cause any exceptions | ||
} | ||
} |