public void testOnlyRetryAuthWhenSetViaProperties() {
   Properties props = new Properties();
   props.setProperty("jclouds.ssh.retry-auth", "true");
   SshjSshClient ssh1 = createClient(props);
   assert ssh1.shouldRetry(new AuthorizationException("problem", null));
   assert ssh1.shouldRetry(new UserAuthException("problem", null));
 }
 public void testOnlyRetryAuthWhenSet() {
   SshjSshClient ssh1 = createClient();
   assert !ssh1.shouldRetry(new AuthorizationException("problem", null));
   assert !ssh1.shouldRetry(new UserAuthException("problem", null));
   ssh1.retryAuth = true;
   assert ssh1.shouldRetry(new AuthorizationException("problem", null));
   assert ssh1.shouldRetry(new UserAuthException("problem", null));
 }
 public void testRetryNotOnToStringCustomMismatch() {
   Exception nex = new ExceptionWithStrangeToString();
   Properties props = new Properties();
   props.setProperty("jclouds.ssh.retryable-messages", "foo-baR");
   SshjSshClient ssh1 = createClient(props);
   assert !ssh1.shouldRetry(new RuntimeException(nex));
 }
 public void testRetryOnToStringNpe() {
   Exception nex = new NullPointerException();
   Properties props = new Properties();
   // ensure we test toString on the exception independently
   props.setProperty("jclouds.ssh.retryable-messages", nex.toString());
   SshjSshClient ssh1 = createClient(props);
   assert ssh1.shouldRetry(new RuntimeException(nex));
 }
 public void testExceptionClassesRetry() {
   assert ssh.shouldRetry(
       new ConnectionException(
           "Read timed out",
           new SSHException("Read timed out", new SocketTimeoutException("Read timed out"))));
   assert ssh.shouldRetry(new SFTPException("Failure!"));
   assert ssh.shouldRetry(new SocketTimeoutException("connect timed out"));
   assert ssh.shouldRetry(new TransportException("socket closed"));
   assert ssh.shouldRetry(new ConnectionException("problem"));
   assert ssh.shouldRetry(new ConnectException("Connection refused"));
   assert !ssh.shouldRetry(new IOException("channel %s is not open", new NullPointerException()));
 }
 public void testExceptionMessagesRetry() {
   assert !ssh.shouldRetry(new SSHException(""));
   assert !ssh.shouldRetry(new NullPointerException((String) null));
 }
 public void testExceptionClassesRetry() {
   assert ssh.shouldRetry(new TransportException("socket closed"));
   assert ssh.shouldRetry(new ConnectionException("problem"));
   assert !ssh.shouldRetry(new IOException("channel %s is not open", new NullPointerException()));
 }