@Test
  public void undeployJarFromAllServersWithRestart() throws Exception {
    // Deploy a jar to all servers
    gfshConnector.executeAndAssertThat("deploy --jar=" + jar1).statusIsSuccess();
    String resultString = gfshConnector.getGfshOutput();

    assertThat(resultString).contains(server1.getName());
    assertThat(resultString).contains(server2.getName());
    assertThat(resultString).contains(jarName1);

    server1.invoke(() -> assertThatCanLoad(jarName1, class1));
    server2.invoke(() -> assertThatCanLoad(jarName1, class1));

    gfshConnector.executeAndAssertThat("undeploy --jar=" + jar1.getName()).statusIsSuccess();
    server1.invoke(() -> assertThatCannotLoad(jarName1, class1));
    server2.invoke(() -> assertThatCannotLoad(jarName1, class1));

    server1.getVM().bounce();
    server2.getVM().bounce();

    // Restart the actual cache
    Properties props = new Properties();
    props.setProperty(GROUPS, GROUP1);
    server1 = lsRule.startServerVM(1, props, locator.getPort());

    props.setProperty(GROUPS, GROUP2);
    server2 = lsRule.startServerVM(2, props, locator.getPort());

    server1.invoke(() -> assertThatCannotLoad(jarName1, class1));
    server2.invoke(() -> assertThatCannotLoad(jarName1, class1));
  }
Unit tests for DeployCommand, UndeployCommand, ListDeployedCommand

@since GemFire 7.0
geode-gfsh/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/DeployWithGroupsDUnitTest.java