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) {
|
if (handshakeResponse.error != null) {
|
||||||
String errorMessage = "Error in handshake " + handshakeResponse.error;
|
String errorMessage = "Error in handshake " + handshakeResponse.error;
|
||||||
logger.log(LogLevel.Error, errorMessage);
|
logger.log(LogLevel.Error, errorMessage);
|
||||||
throw new Exception(errorMessage);
|
throw new HubException(errorMessage);
|
||||||
}
|
}
|
||||||
handshakeReceived = true;
|
handshakeReceived = true;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,9 @@ import static org.junit.Assert.*;
|
||||||
public class HubConnectionTest {
|
public class HubConnectionTest {
|
||||||
private static final String RECORD_SEPARATOR = "\u001e";
|
private static final String RECORD_SEPARATOR = "\u001e";
|
||||||
|
|
||||||
|
@Rule
|
||||||
|
public ExpectedException exceptionRule = ExpectedException.none();
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void checkHubConnectionState() throws Exception {
|
public void checkHubConnectionState() throws Exception {
|
||||||
Transport mockTransport = new MockTransport();
|
Transport mockTransport = new MockTransport();
|
||||||
|
|
@ -40,6 +43,18 @@ public class HubConnectionTest {
|
||||||
assertEquals(HubConnectionState.DISCONNECTED, hubConnection.getConnectionState());
|
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
|
@Test
|
||||||
public void RegisteringMultipleHandlersAndBothGetTriggered() throws Exception {
|
public void RegisteringMultipleHandlersAndBothGetTriggered() throws Exception {
|
||||||
AtomicReference<Double> value = new AtomicReference<>(0.0);
|
AtomicReference<Double> value = new AtomicReference<>(0.0);
|
||||||
|
|
@ -673,9 +688,6 @@ public class HubConnectionTest {
|
||||||
assertEquals(HubConnectionState.DISCONNECTED, hubConnection.getConnectionState());
|
assertEquals(HubConnectionState.DISCONNECTED, hubConnection.getConnectionState());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Rule
|
|
||||||
public ExpectedException exceptionRule = ExpectedException.none();
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void CannotSendBeforeStart() throws Exception {
|
public void CannotSendBeforeStart() throws Exception {
|
||||||
exceptionRule.expect(HubException.class);
|
exceptionRule.expect(HubException.class);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue