@Test public void executeFileNotFoundTest(){ Assert.assertEquals("Failed","unable to copy file to the host, error: java.io.FileNotFoundException: invalid.sh (No such file or directory)",systemRaider.executeScript("127.0.0.1","invalid.sh","param1","param2")); }
@Override public String executeScript(String ip, String path, String... params) { String response; SessionFactory sessionFactory; try { sessionFactory = createSessionFactory(ip); scpScript(sessionFactory, path); response = executer(ip, params); } catch (JSchException e) { return "unable to connect to " + ip; } catch (IOException e) { return "unable to copy file to the host, error: " + e; } catch (Exception e) { e.printStackTrace(); throw new RuntimeException(e); } return response; }
SystemRaiderImpl implements SystemRaider { @Override public String executeScript(String ip, String path, String... params) { String response; SessionFactory sessionFactory; try { sessionFactory = createSessionFactory(ip); scpScript(sessionFactory, path); response = executer(ip, params); } catch (JSchException e) { return "unable to connect to " + ip; } catch (IOException e) { return "unable to copy file to the host, error: " + e; } catch (Exception e) { e.printStackTrace(); throw new RuntimeException(e); } return response; } }
SystemRaiderImpl implements SystemRaider { @Override public String executeScript(String ip, String path, String... params) { String response; SessionFactory sessionFactory; try { sessionFactory = createSessionFactory(ip); scpScript(sessionFactory, path); response = executer(ip, params); } catch (JSchException e) { return "unable to connect to " + ip; } catch (IOException e) { return "unable to copy file to the host, error: " + e; } catch (Exception e) { e.printStackTrace(); throw new RuntimeException(e); } return response; } SystemRaiderImpl(); }
SystemRaiderImpl implements SystemRaider { @Override public String executeScript(String ip, String path, String... params) { String response; SessionFactory sessionFactory; try { sessionFactory = createSessionFactory(ip); scpScript(sessionFactory, path); response = executer(ip, params); } catch (JSchException e) { return "unable to connect to " + ip; } catch (IOException e) { return "unable to copy file to the host, error: " + e; } catch (Exception e) { e.printStackTrace(); throw new RuntimeException(e); } return response; } SystemRaiderImpl(); @Override String executeScript(String ip, String path, String... params); @Override String executeScript(String ip, String path, List<String> params); }
SystemRaiderImpl implements SystemRaider { @Override public String executeScript(String ip, String path, String... params) { String response; SessionFactory sessionFactory; try { sessionFactory = createSessionFactory(ip); scpScript(sessionFactory, path); response = executer(ip, params); } catch (JSchException e) { return "unable to connect to " + ip; } catch (IOException e) { return "unable to copy file to the host, error: " + e; } catch (Exception e) { e.printStackTrace(); throw new RuntimeException(e); } return response; } SystemRaiderImpl(); @Override String executeScript(String ip, String path, String... params); @Override String executeScript(String ip, String path, List<String> params);  }