Merge commit '852d890' into pakrym/merge22

This commit is contained in:
Pavel Krymets 2019-01-16 11:56:50 -08:00
commit f08f2af8bc
3 changed files with 17 additions and 3 deletions

View File

@ -23,6 +23,7 @@ Later on, this will be checked using this condition:
Microsoft.AspNetCore.Authentication.Google;
Microsoft.AspNetCore.Http;
Microsoft.AspNetCore.Server.IIS;
java:signalr;
</PackagesInPatch>
</PropertyGroup>

View File

@ -465,7 +465,7 @@ public class HubConnection {
*/
public void send(String method, Object... args) {
if (hubConnectionState != HubConnectionState.CONNECTED) {
throw new RuntimeException("The 'send' method cannot be called if the connection is not active");
throw new RuntimeException("The 'send' method cannot be called if the connection is not active.");
}
InvocationMessage invocationMessage = new InvocationMessage(null, method, args);
@ -483,6 +483,10 @@ public class HubConnection {
*/
@SuppressWarnings("unchecked")
public <T> Single<T> invoke(Class<T> returnType, String method, Object... args) {
if (hubConnectionState != HubConnectionState.CONNECTED) {
throw new RuntimeException("The 'invoke' method cannot be called if the connection is not active.");
}
String id = connectionState.getNextInvocationId();
InvocationMessage invocationMessage = new InvocationMessage(id, method, args);

View File

@ -1119,7 +1119,16 @@ class HubConnectionTest {
assertEquals(HubConnectionState.DISCONNECTED, hubConnection.getConnectionState());
Throwable exception = assertThrows(RuntimeException.class, () -> hubConnection.send("inc"));
assertEquals("The 'send' method cannot be called if the connection is not active", exception.getMessage());
assertEquals("The 'send' method cannot be called if the connection is not active.", exception.getMessage());
}
@Test
public void cannotInvokeBeforeStart() {
HubConnection hubConnection = TestUtils.createHubConnection("http://example.com");
assertEquals(HubConnectionState.DISCONNECTED, hubConnection.getConnectionState());
Throwable exception = assertThrows(RuntimeException.class, () -> hubConnection.invoke(String.class, "inc", "arg1"));
assertEquals("The 'invoke' method cannot be called if the connection is not active.", exception.getMessage());
}
@Test
@ -1423,4 +1432,4 @@ class HubConnectionTest {
() -> hubConnection.start().timeout(1, TimeUnit.SECONDS).blockingAwait());
assertEquals("Unexpected status code returned from negotiate: 500 Internal server error.", exception.getMessage());
}
}
}