Use HubException for error in HandShakeResponse (#2914)
This commit is contained in:
parent
b67137bc00
commit
b0155446ab
|
|
@ -50,7 +50,7 @@ public class HubConnection {
|
|||
if (handshakeResponse.error != null) {
|
||||
String errorMessage = "Error in handshake " + handshakeResponse.error;
|
||||
logger.log(LogLevel.Error, errorMessage);
|
||||
throw new Exception(errorMessage);
|
||||
throw new HubException(errorMessage);
|
||||
}
|
||||
handshakeReceived = true;
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,9 @@ import static org.junit.Assert.*;
|
|||
public class HubConnectionTest {
|
||||
private static final String RECORD_SEPARATOR = "\u001e";
|
||||
|
||||
@Rule
|
||||
public ExpectedException exceptionRule = ExpectedException.none();
|
||||
|
||||
@Test
|
||||
public void checkHubConnectionState() throws Exception {
|
||||
Transport mockTransport = new MockTransport();
|
||||
|
|
@ -40,6 +43,18 @@ public class HubConnectionTest {
|
|||
assertEquals(HubConnectionState.DISCONNECTED, hubConnection.getConnectionState());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void HubConnectionReceiveHandshakeResponseWithError() throws Exception {
|
||||
exceptionRule.expect(HubException.class);
|
||||
exceptionRule.expectMessage("Requested protocol 'messagepack' is not available.");
|
||||
|
||||
MockTransport mockTransport = new MockTransport();
|
||||
HubConnection hubConnection = new HubConnection("http://example.com", mockTransport);
|
||||
|
||||
hubConnection.start();
|
||||
mockTransport.receiveMessage("{\"error\": \"Requested protocol 'messagepack' is not available.\"}" + RECORD_SEPARATOR);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void RegisteringMultipleHandlersAndBothGetTriggered() throws Exception {
|
||||
AtomicReference<Double> value = new AtomicReference<>(0.0);
|
||||
|
|
@ -673,9 +688,6 @@ public class HubConnectionTest {
|
|||
assertEquals(HubConnectionState.DISCONNECTED, hubConnection.getConnectionState());
|
||||
}
|
||||
|
||||
@Rule
|
||||
public ExpectedException exceptionRule = ExpectedException.none();
|
||||
|
||||
@Test
|
||||
public void CannotSendBeforeStart() throws Exception {
|
||||
exceptionRule.expect(HubException.class);
|
||||
|
|
|
|||
Loading…
Reference in New Issue