ConnectCommand extends OfflineGfshCommand { static boolean shouldConnect(String ourSerializationVersion, String remoteVersion, String remoteSerializationVersion) { if (remoteVersion == null) { return false; } if (remoteSerializationVersion != null) { int ourMajor = versionComponent(ourSerializationVersion, VERSION_MAJOR); int remoteMajor = versionComponent(remoteSerializationVersion, VERSION_MAJOR); return remoteMajor >= 1 && remoteMajor <= ourMajor; } int remoteMajorVersion = versionComponent(remoteVersion, VERSION_MAJOR); int remoteMinorVersion = versionComponent(remoteVersion, VERSION_MINOR); return remoteMajorVersion == 9 && remoteMinorVersion == 9 || remoteMajorVersion == 1 && remoteMinorVersion == 10 || remoteMajorVersion == 1 && remoteMinorVersion == 11; }  @CliCommand(value = {CliStrings.CONNECT}, help = CliStrings.CONNECT__HELP) @CliMetaData(shellOnly = true, relatedTopic = {CliStrings.TOPIC_GFSH, CliStrings.TOPIC_GEODE_JMX, CliStrings.TOPIC_GEODE_MANAGER}) ResultModel connect(
      @CliOption(key = {CliStrings.CONNECT__LOCATOR},
          unspecifiedDefaultValue = ConnectionEndpointConverter.DEFAULT_LOCATOR_ENDPOINTS,
          optionContext = ConnectionEndpoint.LOCATOR_OPTION_CONTEXT,
          help = CliStrings.CONNECT__LOCATOR__HELP) ConnectionEndpoint locatorEndPoint,
      @CliOption(key = {CliStrings.CONNECT__JMX_MANAGER},
          optionContext = ConnectionEndpoint.JMXMANAGER_OPTION_CONTEXT,
          help = CliStrings.CONNECT__JMX_MANAGER__HELP) ConnectionEndpoint jmxManagerEndPoint,
      @CliOption(key = {CliStrings.CONNECT__USE_HTTP}, specifiedDefaultValue = "true",
          unspecifiedDefaultValue = "false",
          help = CliStrings.CONNECT__USE_HTTP__HELP) boolean useHttp,
      @CliOption(key = {CliStrings.CONNECT__URL}, help = CliStrings.CONNECT__URL__HELP) String url,
      @CliOption(key = {CliStrings.CONNECT__USERNAME}, specifiedDefaultValue = "",
          help = CliStrings.CONNECT__USERNAME__HELP) String userName,
      @CliOption(key = {CliStrings.CONNECT__PASSWORD}, specifiedDefaultValue = "",
          help = CliStrings.CONNECT__PASSWORD__HELP) String password,
      @CliOption(key = {CliStrings.CONNECT__TOKEN}, specifiedDefaultValue = "",
          help = CliStrings.CONNECT__TOKEN__HELP) String token,
      @CliOption(key = {CliStrings.CONNECT__KEY_STORE},
          help = CliStrings.CONNECT__KEY_STORE__HELP) String keystore,
      @CliOption(key = {CliStrings.CONNECT__KEY_STORE_PASSWORD},
          help = CliStrings.CONNECT__KEY_STORE_PASSWORD__HELP) String keystorePassword,
      @CliOption(key = {CliStrings.CONNECT__TRUST_STORE},
          help = CliStrings.CONNECT__TRUST_STORE__HELP) String truststore,
      @CliOption(key = {CliStrings.CONNECT__TRUST_STORE_PASSWORD},
          help = CliStrings.CONNECT__TRUST_STORE_PASSWORD__HELP) String truststorePassword,
      @CliOption(key = {CliStrings.CONNECT__SSL_CIPHERS},
          help = CliStrings.CONNECT__SSL_CIPHERS__HELP) String sslCiphers,
      @CliOption(key = {CliStrings.CONNECT__SSL_PROTOCOLS},
          help = CliStrings.CONNECT__SSL_PROTOCOLS__HELP) String sslProtocols,
      @CliOption(key = CliStrings.CONNECT__SECURITY_PROPERTIES, optionContext = ConverterHint.FILE,
          help = CliStrings.CONNECT__SECURITY_PROPERTIES__HELP) final File gfSecurityPropertiesFile,
      @CliOption(key = {CliStrings.CONNECT__USE_SSL}, specifiedDefaultValue = "true",
          unspecifiedDefaultValue = "false",
          help = CliStrings.CONNECT__USE_SSL__HELP) boolean useSsl,
      @CliOption(key = {"skip-ssl-validation"}, specifiedDefaultValue = "true",
          unspecifiedDefaultValue = "false",
          help = "When connecting via HTTP, connects using 1-way SSL validation rather than 2-way SSL validation.") boolean skipSslValidation); static ConnectToLocatorResult connectToLocator(String host, int port, int timeout,
      Properties props);  }
@Test public void isCompatibleWOneDotX() { assertThat(ConnectCommand.shouldConnect("1", null, null)).isFalse(); assertThat(ConnectCommand.shouldConnect("1", "1.5.0", null)).isFalse(); assertThat(ConnectCommand.shouldConnect("1", "1.9.0", null)).isFalse(); assertThat(ConnectCommand.shouldConnect("1", "1.10.0", null)).isTrue(); assertThat(ConnectCommand.shouldConnect("1", "1.11.0", null)).isTrue(); assertThat(ConnectCommand.shouldConnect("1", "9.9.0", null)).isTrue(); assertThat(ConnectCommand.shouldConnect("1", "9.9.0", "9.9.0")).isFalse(); assertThat(ConnectCommand.shouldConnect("1", "1.12.0", "1.12.0")).isTrue(); assertThat(ConnectCommand.shouldConnect("1", "1.13.0", "1.13.0")).isTrue(); assertThat(ConnectCommand.shouldConnect("1", "1.14.0", "1.14.0")).isTrue(); assertThat(ConnectCommand.shouldConnect("1", "2.0.0", "2.0.0")).isFalse(); assertThat(ConnectCommand.shouldConnect("1", "badstring", "badstring")).isFalse(); }
@Test public void isCompatibleTwoDotX() { assertThat(ConnectCommand.shouldConnect("1", null, null)).isFalse(); assertThat(ConnectCommand.shouldConnect("2", "1.5.0", null)).isFalse(); assertThat(ConnectCommand.shouldConnect("2", "1.9.0", null)).isFalse(); assertThat(ConnectCommand.shouldConnect("2", "1.10.0", null)).isTrue(); assertThat(ConnectCommand.shouldConnect("2", "1.11.0", null)).isTrue(); assertThat(ConnectCommand.shouldConnect("2", "9.9.0", null)).isTrue(); assertThat(ConnectCommand.shouldConnect("2", "9.9.0", "9.9.0")).isFalse(); assertThat(ConnectCommand.shouldConnect("2", "1.12.0", "1.12.0")).isTrue(); assertThat(ConnectCommand.shouldConnect("2", "1.13.0", "1.13.0")).isTrue(); assertThat(ConnectCommand.shouldConnect("2", "1.14.0", "1.14.0")).isTrue(); assertThat(ConnectCommand.shouldConnect("2", "2.0.0", "2.0.0")).isTrue(); assertThat(ConnectCommand.shouldConnect("2", "badstring", "badstring")).isFalse(); }