public void shutdownNow() { shutdownNow(null); }
@AfterClass public void teardown() { if (em != null) em.shutdownNow(); em = null; }
@AfterMethod public void tearDown() { if (em != null) em.shutdownNow(); }
@AfterMethod(alwaysRun=true) public void tearDown() throws Exception { if (em != null) em.shutdownNow(); }
@AfterMethod(alwaysRun=true) public void tearDown() throws Exception { if (em != null) em.shutdownNow(); }
@AfterMethod(alwaysRun=true) public void tearDown() throws Exception { if (em != null) em.shutdownNow(); if (ex != null) ex.shutdownNow(); }
@AfterMethod(alwaysRun=true) public void tearDown() throws Exception { if (em != null) em.shutdownNow(); if (data != null) data.clear(); }
@AfterMethod(alwaysRun=true) public void tearDown() throws Exception { if (em != null) { // need to await termination, otherwise interrupted-but-still-running threads // may update the cancellations/messages and interfere with subsequent tests Assert.assertTrue(em.shutdownNow(Duration.FIVE_SECONDS)); } }
@Override public void terminate() { if (terminated.getAndSet(true)) { log.trace("Already terminated management context "+this); // no harm in doing it twice, but it makes logs ugly! return; } log.debug("Terminating management context "+this); INSTANCES.remove(this); super.terminate(); if (osgiManager!=null) { osgiManager.stop(); osgiManager = null; } if (usageManager != null) usageManager.terminate(); if (execution != null) execution.shutdownNow(); if (gc != null) gc.shutdownNow(); log.debug("Terminated management context "+this); }
@Test(groups = "Integration") @Override public void testGetMachineDetails() throws Exception { BasicExecutionManager execManager = new BasicExecutionManager("mycontextid"); BasicExecutionContext execContext = new BasicExecutionContext(execManager); try { MachineDetails details = execContext.submit(new Callable<MachineDetails>() { @Override public MachineDetails call() { return host.getMachineDetails(); }}).get(); LOG.info("machineDetails="+details); assertNotNull(details); } finally { execManager.shutdownNow(); } }
@Test public void testGetMachineDetails() throws Exception { String response = Joiner.on("\n").join( "name:Test OS Y", "version:1.2.3", "architecture:x86_64", "ram:1234", "cpus:3"); RecordingSshTool.setCustomResponse(".*uname.*", new CustomResponse(0, response, "")); BasicExecutionManager execManager = new BasicExecutionManager("mycontextid"); BasicExecutionContext execContext = new BasicExecutionContext(execManager); try { MachineDetails details = execContext.submit(new Callable<MachineDetails>() { @Override public MachineDetails call() { return host.getMachineDetails(); }}).get(); LOG.info("machineDetails="+details); assertNotNull(details); assertEquals(details.getOsDetails().getName(), "Test OS Y", "details="+details); assertEquals(details.getOsDetails().getVersion(), "1.2.3", "details="+details); assertEquals(details.getOsDetails().getArch(), "x86_64", "details="+details); assertEquals(details.getHardwareDetails().getCpuCount(), Integer.valueOf(3), "details="+details); assertEquals(details.getHardwareDetails().getRam(), Integer.valueOf(1234), "details="+details); } finally { execManager.shutdownNow(); } }
assertEquals(details.getHardwareDetails().getRam(), Integer.valueOf(15948), "details="+details); } finally { execManager.shutdownNow();
"\nSTDERR:\n"+script.getResultStderr()); } finally { em.shutdownNow();