@BeforeMethod(alwaysRun = true) public void setUp() throws Exception { tempDataDir = Files.createTempDir(); managementContext = new LocalManagementContext(); localhost = managementContext .getLocationManager() .createLocation(LocationSpec.create(LocalhostMachineProvisioningLocation.class)); machine127 = managementContext .getLocationManager() .createLocation( LocationSpec.create(SshMachineLocation.class).configure("address", "localhost")); app = ApplicationBuilder.newManagedApp(TestApplication.class, managementContext); }
@BeforeMethod(alwaysRun = true) public void setUp() throws Exception { managementContext = new LocalManagementContext(); host = managementContext .getLocationManager() .createLocation( LocationSpec.create(SshMachineLocation.class) .configure("address", Networking.getLocalHost()) .configure(SshTool.PROP_TOOL_CLASS, RecordingSshjTool.class.getName())); }
@Test(groups = "Integration") public void testSshCacheExpiresEvenIfNotUsed() throws Exception { SshMachineLocation host2 = managementContext .getLocationManager() .createLocation( LocationSpec.create(SshMachineLocation.class) .configure("address", InetAddress.getLocalHost()) .configure(SshMachineLocation.SSH_CACHE_EXPIRY_DURATION, Duration.ONE_SECOND) .configure(SshTool.PROP_TOOL_CLASS, RecordingSshjTool.class.getName())); Map<String, Object> props = customSshConfigKeys(); host2.execScript(props, "mysummary", ImmutableList.of("exit")); Asserts.succeedsEventually( new Runnable() { @Override public void run() { assertEquals(RecordingSshjTool.disconnectionCount.get(), 1); } }); }