SshFeed extends org.apache.brooklyn.feed.AbstractCommandFeed { public static Builder builder() { return new Builder(); } SshFeed();  SshFeed(final Builder builder); static Builder builder(); static final Logger log; }
@Test(groups="Integration") public void testSharesCallWhenSameCommand() throws Exception { final RecordingSshMachineLocation recordingMachine = mgmt.getLocationManager().createLocation(LocationSpec.create(RecordingSshMachineLocation.class)); app.start(ImmutableList.of(recordingMachine)); final String cmd = "myCommand"; feed = SshFeed.builder() .period(Duration.PRACTICALLY_FOREVER) .entity(entity) .poll(new SshPollConfig<String>(SENSOR_STRING) .env(ImmutableMap.of("mykey", "myval")) .command(cmd) .onSuccess(Functions.constant("success"))) .poll(new SshPollConfig<String>(SENSOR_STRING2) .env(ImmutableMap.of("mykey", "myval")) .command(cmd) .onSuccess(Functions.constant("success2"))) .build(); Asserts.succeedsEventually(new Runnable() { @Override public void run() { assertEquals(RecordingSshMachineLocation.execScriptCalls, ImmutableList.of(ImmutableList.of(cmd))); }}); Asserts.succeedsContinually(ImmutableMap.of("timeout", Duration.FIVE_SECONDS), new Runnable() { @Override public void run() { assertEquals(RecordingSshMachineLocation.execScriptCalls, ImmutableList.of(ImmutableList.of(cmd))); }}); }
@Test public void testDifferentCallsWhenDifferentCommands() throws Exception { final RecordingSshMachineLocation recordingMachine = mgmt.getLocationManager().createLocation(LocationSpec.create(RecordingSshMachineLocation.class)); app.start(ImmutableList.of(recordingMachine)); final String cmd = "myCommand"; final String cmd2 = "myCommand2"; feed = SshFeed.builder() .period(Duration.PRACTICALLY_FOREVER) .entity(entity) .poll(new SshPollConfig<String>(SENSOR_STRING) .command(cmd) .onSuccess(Functions.constant("success"))) .poll(new SshPollConfig<String>(SENSOR_STRING2) .command(cmd2) .onSuccess(Functions.constant("success"))) .build(); Asserts.succeedsEventually(new Runnable() { @Override public void run() { assertEquals(ImmutableSet.copyOf(RecordingSshMachineLocation.execScriptCalls), ImmutableSet.of(ImmutableList.of(cmd), ImmutableList.of(cmd2))); }}); }
@Test public void testDifferentCallsWhenDifferentEnv() throws Exception { final RecordingSshMachineLocation recordingMachine = mgmt.getLocationManager().createLocation(LocationSpec.create(RecordingSshMachineLocation.class)); app.start(ImmutableList.of(recordingMachine)); final String cmd = "myCommand"; feed = SshFeed.builder() .period(Duration.PRACTICALLY_FOREVER) .entity(entity) .poll(new SshPollConfig<String>(SENSOR_STRING) .env(ImmutableMap.of("mykey", "myval")) .command(cmd) .onSuccess(Functions.constant("success"))) .poll(new SshPollConfig<String>(SENSOR_STRING2) .env(ImmutableMap.of("mykey", "myval2")) .command(cmd) .onSuccess(Functions.constant("success"))) .build(); Asserts.succeedsEventually(new Runnable() { @Override public void run() { assertEquals(RecordingSshMachineLocation.execScriptCalls, ImmutableList.of(ImmutableList.of(cmd), ImmutableList.of(cmd))); }}); }