@Test public void executeCommandRC() throws Exception { Assert.assertEquals("Expected 0, got", mockCommand(0), service.executeCommandRC("test cmd")); Assert.assertEquals("Expected 100, got", mockCommand(100), service.executeCommandRC("test cmd")); Mockito.when(systemCall.execute(ArgumentMatchers.anyString())).thenThrow(new IOException()); Assert.assertEquals("Expected 1, got", 1, service.executeCommandRC("invalid cmd")); }
public int executeCommandRC(String command) { LOG.debug("Execute CMD : {}", command); try { final Process p = processFunction.execute(command); p.waitFor(3, TimeUnit.SECONDS); LOG.debug("Executed CMD : {} --> RC={}", command, p.exitValue()); return p.exitValue(); } catch (InterruptedException | IOException e) { return 1; } }
LinuxRoutingService implements Routing { public int executeCommandRC(String command) { LOG.debug("Execute CMD : {}", command); try { final Process p = processFunction.execute(command); p.waitFor(3, TimeUnit.SECONDS); LOG.debug("Executed CMD : {} --> RC={}", command, p.exitValue()); return p.exitValue(); } catch (InterruptedException | IOException e) { return 1; } } }
LinuxRoutingService implements Routing { public int executeCommandRC(String command) { LOG.debug("Execute CMD : {}", command); try { final Process p = processFunction.execute(command); p.waitFor(3, TimeUnit.SECONDS); LOG.debug("Executed CMD : {} --> RC={}", command, p.exitValue()); return p.exitValue(); } catch (InterruptedException | IOException e) { return 1; } } LinuxRoutingService(SystemCall systemCall, RoutingDefinition initializer); }
LinuxRoutingService implements Routing { public int executeCommandRC(String command) { LOG.debug("Execute CMD : {}", command); try { final Process p = processFunction.execute(command); p.waitFor(3, TimeUnit.SECONDS); LOG.debug("Executed CMD : {} --> RC={}", command, p.exitValue()); return p.exitValue(); } catch (InterruptedException | IOException e) { return 1; } } LinuxRoutingService(SystemCall systemCall, RoutingDefinition initializer); String executeCommand(String command); int executeCommandRC(String command); @Override synchronized Routing setInterface(String inf); @Override Routing setNetmask(final IpAddress netmask); @Override IpAddress getNetmask(); @Override synchronized String getInterface(); @Override synchronized IpAddress getVirtualIp(); @Override synchronized boolean isActive(); @Override synchronized boolean removeRouteForCurrentService(); @Override synchronized boolean addRouteForCurrentService(); @Override boolean updateArpTableForCurrentService(); @Override String toString(); }
LinuxRoutingService implements Routing { public int executeCommandRC(String command) { LOG.debug("Execute CMD : {}", command); try { final Process p = processFunction.execute(command); p.waitFor(3, TimeUnit.SECONDS); LOG.debug("Executed CMD : {} --> RC={}", command, p.exitValue()); return p.exitValue(); } catch (InterruptedException | IOException e) { return 1; } } LinuxRoutingService(SystemCall systemCall, RoutingDefinition initializer); String executeCommand(String command); int executeCommandRC(String command); @Override synchronized Routing setInterface(String inf); @Override Routing setNetmask(final IpAddress netmask); @Override IpAddress getNetmask(); @Override synchronized String getInterface(); @Override synchronized IpAddress getVirtualIp(); @Override synchronized boolean isActive(); @Override synchronized boolean removeRouteForCurrentService(); @Override synchronized boolean addRouteForCurrentService(); @Override boolean updateArpTableForCurrentService(); @Override String toString();  }