@Override public void connect() throws IOException, SlimVersionMismatch { String slimServerVersionMessage = reader.readLine(); if (!isConnected(slimServerVersionMessage)) { throw new SlimVersionMismatch("Got invalid slim header from client. Read the following: " + slimServerVersionMessage); } slimServerVersion = Double.parseDouble(slimServerVersionMessage.replace(SlimVersion.SLIM_HEADER, "")); if (slimServerVersion == SlimCommandRunningClient.NO_SLIM_SERVER_CONNECTION_FLAG) { throw new SlimVersionMismatch("Slim Protocol Version Error: Server did not respond with a valid version number."); } else if (slimServerVersion < SlimCommandRunningClient.MINIMUM_REQUIRED_SLIM_VERSION) { throw new SlimVersionMismatch(String.format("Slim Protocol Version Error: Expected V%s but was V%s", SlimCommandRunningClient.MINIMUM_REQUIRED_SLIM_VERSION, slimServerVersion)); } }
@Override public void connect() throws IOException, SlimVersionMismatch { String slimServerVersionMessage = reader.readLine(); if (!isConnected(slimServerVersionMessage)) { throw new SlimVersionMismatch("Got invalid slim header from client. Read the following: " + slimServerVersionMessage); } slimServerVersion = Double.parseDouble(slimServerVersionMessage.replace(SlimVersion.SLIM_HEADER, "")); if (slimServerVersion == SlimCommandRunningClient.NO_SLIM_SERVER_CONNECTION_FLAG) { throw new SlimVersionMismatch("Slim Protocol Version Error: Server did not respond with a valid version number."); } else if (slimServerVersion < SlimCommandRunningClient.MINIMUM_REQUIRED_SLIM_VERSION) { throw new SlimVersionMismatch(String.format("Slim Protocol Version Error: Expected V%s but was V%s", SlimCommandRunningClient.MINIMUM_REQUIRED_SLIM_VERSION, slimServerVersion)); } }
protected void validateConnection() throws IOException { long timeOut = Clock.currentTimeInMillis() + connectionTimeout * 1000; LOG.finest("Trying to get SlimHeader: " + " timeout setting: " + connectionTimeout); while (!isConnected()) { if (slimRunner != null && slimRunner.isDead()) { final String slimErrorMessage = "Error SLiM server died before Header Message could be read. " + slimRunner.getCommandErrorMessage(); throw new SlimError(slimErrorMessage); } if (Clock.currentTimeInMillis() > timeOut) { throw new SlimError( "Timeout while reading slim header from client. Check that you are connecting to the right port and that the slim client is running. You can increase the timeout limit by setting 'slim.timeout' in the fitnesse properties file."); } try { slimServerVersionMessage = reader.readLine(); } catch (SocketTimeoutException e) { throw new SlimError( "Timeout while reading slim header from client. Check that you are connecting to the right port and that the slim client is running. You can increase the timeout limit by setting 'slim.timeout' in the fitnesse properties file."); } LOG.finest("Read Slim Header: >" + slimServerVersionMessage + "<"); } try { slimServerVersion = Double.parseDouble(slimServerVersionMessage.replace(SlimVersion.SLIM_HEADER, "")); } catch (Exception e) { slimServerVersion = NO_SLIM_SERVER_CONNECTION_FLAG; throw new SlimError("Got invalid slim version from Client. Read the following: " + slimServerVersionMessage); } LOG.fine("Got Slim Header: " + slimServerVersionMessage + ", and Version " + slimServerVersion); }
protected void validateConnection() throws IOException { long timeOut = Clock.currentTimeInMillis() + connectionTimeout * 1000; LOG.finest("Trying to get SlimHeader: " + " timeout setting: " + connectionTimeout); while (!isConnected()) { if (slimRunner != null && slimRunner.isDead()) { final String slimErrorMessage = "Error SLiM server died before Header Message could be read. " + slimRunner.getCommandErrorMessage(); throw new SlimError(slimErrorMessage); } if (Clock.currentTimeInMillis() > timeOut) { throw new SlimError( "Timeout while reading slim header from client. Check that you are connecting to the right port and that the slim client is running. You can increase the timeout limit by setting 'slim.timeout' in the fitnesse properties file."); } try { slimServerVersionMessage = reader.readLine(); } catch (SocketTimeoutException e) { throw new SlimError( "Timeout while reading slim header from client. Check that you are connecting to the right port and that the slim client is running. You can increase the timeout limit by setting 'slim.timeout' in the fitnesse properties file."); } LOG.finest("Read Slim Header: >" + slimServerVersionMessage + "<"); } try { slimServerVersion = Double.parseDouble(slimServerVersionMessage.replace(SlimVersion.SLIM_HEADER, "")); } catch (Exception e) { slimServerVersion = NO_SLIM_SERVER_CONNECTION_FLAG; throw new SlimError("Got invalid slim version from Client. Read the following: " + slimServerVersionMessage); } LOG.fine("Got Slim Header: " + slimServerVersionMessage + ", and Version " + slimServerVersion); }