コード例 #1
0
/** Created by pcyprian on 3.9.15. */
@RunWith(Arquillian.class)
@Category(Shared.class)
public class RemoteAcceptorTestCase {

  private static final Logger log = LoggerFactory.getLogger(RemoteAcceptorTestCase.class);

  private static final String NAME = "remote-test-acceptor";
  private static final String BINDING = "socket-binding";
  private static final String ADD =
      "/subsystem=messaging-activemq/server=default/remote-acceptor="
          + NAME
          + ":add(socket-binding="
          + BINDING
          + ")";
  private static final String DOMAIN = "/profile=full-ha";

  private String command;
  private String remove =
      "/subsystem=messaging-activemq/server=default/remote-acceptor=" + NAME + ":remove";
  private String addProperty =
      "/subsystem=messaging-activemq/server=default/remote-acceptor="
          + NAME
          + ":write-attribute(name=params.prop,value=test)";
  private ModelNode path =
      new ModelNode("/subsystem=messaging-activemq/server=default/remote-acceptor=" + NAME);
  private ModelNode domainPath =
      new ModelNode(
          "/profile=full-ha/subsystem=messaging-activemq/server=default/remote-acceptor=" + NAME);
  private ResourceAddress address;
  private static Dispatcher dispatcher;
  private static ResourceVerifier verifier;
  CliClient cliClient = CliClientFactory.getClient();

  @BeforeClass
  public static void setUp() {
    dispatcher = new Dispatcher();
    verifier = new ResourceVerifier(dispatcher);
  }

  @AfterClass
  public static void tearDown() {
    dispatcher.close();
  }

  @Drone private WebDriver browser;
  @Page private MessagingPage page;

  @Before
  public void before() {
    if (ConfigUtils.isDomain()) {
      address = new ResourceAddress(domainPath);
      command = DOMAIN + ADD;
      remove = DOMAIN + remove;
      addProperty = DOMAIN + addProperty;
    } else {
      address = new ResourceAddress(path);
      command = ADD;
    }
  }

  @After
  public void after() {
    cliClient.executeCommand(remove);
  }

  @Test
  public void addRemoteAcceptor() {
    page.navigateToMessaging();
    page.selectView("Connections");
    // same fields in acceptor adding
    page.addDiscoveryGroup(NAME, BINDING);

    verifier.verifyResource(address, true);

    cliClient.executeCommand(remove);

    verifier.verifyResource(address, false);
  }

  @Test
  public void updateAcceptorSocketBinding() throws IOException, CommandFailedException {
    cliClient.executeCommand(command);
    page.navigateToMessaging();
    page.selectView("Connections");
    page.selectInTable(NAME, 0);
    page.edit();

    String socketBindingName = "RemoteAcceptorSB" + RandomStringUtils.randomAlphanumeric(5);

    try (OnlineManagementClient client = ManagementClientProvider.createOnlineManagementClient()) {
      int port = AvailablePortFinder.getNextAvailable(1024);
      log.info("Obtained port for socket binding '" + socketBindingName + "' is " + port);
      client.apply(new AddSocketBinding.Builder(socketBindingName).port(port).build());
    }

    ConfigFragment editPanelFragment = page.getConfigFragment();

    editPanelFragment.getEditor().text("socketBinding", socketBindingName);
    boolean finished = editPanelFragment.save();

    assertTrue("Config should be saved and closed.", finished);
    verifier.verifyAttribute(address, "socket-binding", socketBindingName, 500);

    cliClient.executeCommand(remove);
  }

  @Test
  public void updateAcceptorProperties() {
    cliClient.executeCommand(command);
    page.navigateToMessaging();
    page.selectView("Connections");
    page.selectInTable(NAME, 0);

    ConfigPropertiesFragment properties = page.getConfig().propertiesConfig();
    ConfigPropertyWizard wizard = properties.addProperty();
    boolean result = wizard.name("prop").value("test").finish();

    assertTrue("Property should be added and wizard closed.", result);

    verifier.verifyAttribute(address, "params", "{\"prop\" => \"test\"}", 500);

    cliClient.executeCommand(remove);
  }

  @Test
  public void removeAcceptorProperties() {
    cliClient.executeCommand(command);
    cliClient.executeCommand(addProperty);
    page.navigateToMessaging();
    page.selectView("Connections");

    page.selectInTable(NAME, 0);

    ConfigPropertiesFragment properties = page.getConfig().propertiesConfig();
    properties.removeProperty("prop");

    verifier.verifyAttribute(address, "params", "undefined", 500);

    cliClient.executeCommand(remove);
  }

  @Test
  public void removeRemoteAcceptor() {
    cliClient.executeCommand(command);

    page.navigateToMessaging();
    page.selectView("Connections");

    verifier.verifyResource(address, true);

    page.selectInTable(NAME, 0);
    page.remove();

    verifier.verifyResource(address, false);
  }
}
コード例 #2
0
/** Created by pcyprian on 7.9.15. */
@RunWith(Arquillian.class)
@Category(Shared.class)
public class InVMAcceptorTestCase {
  private static final String NAME = "in-vm-test-acceptor";
  private static final String SERVER = "1";
  private static final String ADD =
      "/subsystem=messaging-activemq/server=default/in-vm-acceptor="
          + NAME
          + ":add(server-id="
          + SERVER
          + ")";
  private static final String DOMAIN = "/profile=full-ha";

  private String command;
  private String remove =
      "/subsystem=messaging-activemq/server=default/in-vm-acceptor=" + NAME + ":remove";
  private String addProperty =
      "/subsystem=messaging-activemq/server=default/in-vm-acceptor="
          + NAME
          + ":write-attribute(name=params.prop,value=test)";
  private ModelNode path =
      new ModelNode("/subsystem=messaging-activemq/server=default/in-vm-acceptor=" + NAME);
  private ModelNode domainPath =
      new ModelNode(
          "/profile=full-ha/subsystem=messaging-activemq/server=default/in-vm-acceptor=" + NAME);
  private ResourceAddress address;
  private static Dispatcher dispatcher;
  private static ResourceVerifier verifier;
  CliClient cliClient = CliClientFactory.getClient();

  @BeforeClass
  public static void setUp() {
    dispatcher = new Dispatcher();
    verifier = new ResourceVerifier(dispatcher);
  }

  @AfterClass
  public static void tearDown() {
    dispatcher.close();
  }

  @Drone private WebDriver browser;
  @Page private MessagingPage page;

  @Before
  public void before() {
    if (ConfigUtils.isDomain()) {
      address = new ResourceAddress(domainPath);
      command = DOMAIN + ADD;
      remove = DOMAIN + remove;
      addProperty = DOMAIN + addProperty;
    } else {
      address = new ResourceAddress(path);
      command = ADD;
    }
  }

  @After
  public void after() {
    cliClient.executeCommand(remove);
  }

  @Test
  public void addInVmAcceptor() {
    page.navigateToMessaging();
    page.selectView("Connections");
    page.switchType("Type: In-VM");
    page.addInVmAcceptor(NAME, SERVER);

    verifier.verifyResource(address, true);

    cliClient.executeCommand(remove);

    verifier.verifyResource(address, false);
  }

  @Test
  public void updateAcceptorServerID() {
    cliClient.executeCommand(command);
    page.navigateToMessaging();
    page.selectView("Connections");
    page.switchType("Type: In-VM");
    page.selectInTable(NAME, 0);
    page.edit();

    ConfigFragment editPanelFragment = page.getConfigFragment();

    editPanelFragment.getEditor().text("serverId", "0");
    boolean finished = editPanelFragment.save();

    assertTrue("Config should be saved and closed.", finished);
    verifier.verifyAttribute(address, "server-id", "0", 500);

    cliClient.executeCommand(remove);
  }

  @Test
  public void updateAcceptorProperties() {
    cliClient.executeCommand(command);
    page.navigateToMessaging();
    page.selectView("Connections");
    page.switchType("Type: In-VM");
    page.selectInTable(NAME, 0);

    ConfigPropertiesFragment properties = page.getConfig().propertiesConfig();
    ConfigPropertyWizard wizard = properties.addProperty();
    boolean result = wizard.name("prop").value("test").finish();

    assertTrue("Property should be added and wizard closed.", result);
    verifier.verifyAttribute(address, "params", "{\"prop\" => \"test\"}", 500);

    cliClient.executeCommand(remove);
  }

  @Test
  public void removeAcceptorProperties() {
    cliClient.executeCommand(command);
    cliClient.executeCommand(addProperty);
    page.navigateToMessaging();
    page.selectView("Connections");
    page.switchType("Type: In-VM");
    page.selectInTable(NAME, 0);
    ConfigPropertiesFragment properties = page.getConfig().propertiesConfig();
    properties.removeProperty("prop");

    verifier.verifyAttribute(address, "params", "undefined", 500);

    cliClient.executeCommand(remove);
  }

  @Test
  public void removeInVmAcceptor() {
    cliClient.executeCommand(command);

    page.navigateToMessaging();
    page.selectView("Connections");
    page.switchType("Type: In-VM");

    verifier.verifyResource(address, true);

    page.selectInTable(NAME, 0);
    page.remove();

    verifier.verifyResource(address, false);
  }
}
コード例 #3
0
/** Created by pcyprian on 3.9.15. */
@RunWith(Arquillian.class)
@Category(Shared.class)
public class DiscoveryGroupsTestCase {

  private static final Logger log = LoggerFactory.getLogger(DiscoveryGroupsTestCase.class);

  private static final String NAME = "dg-group-test";
  private static final String BINDING = "socket-binding";
  private static final String ADD =
      "/subsystem=messaging-activemq/server=default/discovery-group="
          + NAME
          + ":add(socket-binding="
          + BINDING
          + ")";
  private static final String DOMAIN = "/profile=full-ha";

  private String command;
  private String remove =
      "/subsystem=messaging-activemq/server=default/discovery-group=" + NAME + ":remove";

  private ModelNode path =
      new ModelNode("/subsystem=messaging-activemq/server=default/discovery-group=" + NAME);
  private ModelNode domainPath =
      new ModelNode(
          "/profile=full-ha/subsystem=messaging-activemq/server=default/discovery-group=" + NAME);
  private ResourceAddress address;
  private static Dispatcher dispatcher;
  private static ResourceVerifier verifier;
  CliClient cliClient = CliClientFactory.getClient();

  @BeforeClass
  public static void setUp() {
    dispatcher = new Dispatcher();
    verifier = new ResourceVerifier(dispatcher);
  }

  @AfterClass
  public static void tearDown() {
    dispatcher.close();
  }

  @Drone private WebDriver browser;
  @Page private MessagingPage page;

  @Before
  public void before() {
    if (ConfigUtils.isDomain()) {
      address = new ResourceAddress(domainPath);
      command = DOMAIN + ADD;
      remove = DOMAIN + remove;
    } else {
      address = new ResourceAddress(path);
      command = ADD;
    }
  }

  @After
  public void after() {
    cliClient.executeCommand(remove);
  }

  @Test
  public void addDiscoveryGroup() {
    page.navigateToMessaging();
    page.selectView("Clustering");
    page.switchToDiscovery();

    page.addDiscoveryGroup(NAME, BINDING);

    verifier.verifyResource(address, true);

    cliClient.executeCommand(remove);

    verifier.verifyResource(address, false);
  }

  @Test
  public void updateDiscoveryGroupSocketBinding() throws IOException, CommandFailedException {
    cliClient.executeCommand(command);
    page.navigateToMessaging();
    page.selectView("Clustering");
    page.switchToDiscovery();
    page.selectInTable(NAME, 0);
    page.edit();

    String socketBindingName = "DiscGroupSocketBinding_" + RandomStringUtils.randomAlphanumeric(5);

    try (OnlineManagementClient client = ManagementClientProvider.createOnlineManagementClient()) {
      int port = AvailablePortFinder.getNextAvailable(1024);
      log.info("Obtained port for socket binding '" + socketBindingName + "' is " + port);
      client.apply(new AddSocketBinding.Builder(socketBindingName).port(port).build());
    }

    ConfigFragment editPanelFragment = page.getConfigFragment();

    editPanelFragment.getEditor().text("socketBinding", socketBindingName);
    boolean finished = editPanelFragment.save();

    assertTrue("Config should be saved and closed.", finished);

    verifier.verifyAttribute(address, "socket-binding", socketBindingName, 500);

    cliClient.executeCommand(remove);
  }

  @Test
  public void updateDiscoveryGroupRefreshTimeout() {
    cliClient.executeCommand(command);
    page.navigateToMessaging();
    page.selectView("Clustering");
    page.switchToDiscovery();
    page.selectInTable(NAME, 0);
    page.edit();

    ConfigFragment editPanelFragment = page.getConfigFragment();

    editPanelFragment.getEditor().text("refreshTimeout", "2000");
    boolean finished = editPanelFragment.save();

    assertTrue("Config should be saved and closed.", finished);
    verifier.verifyAttribute(address, "refresh-timeout", "2000", 500);

    cliClient.executeCommand(remove);
  }

  @Test
  public void updateBroadcastGroupRefreshTimeoutNegativeValue() {
    cliClient.executeCommand(command);
    page.navigateToMessaging();
    page.selectView("Clustering");
    page.switchToDiscovery();
    page.selectInTable(NAME, 0);
    page.edit();

    ConfigFragment editPanelFragment = page.getConfigFragment();

    editPanelFragment.getEditor().text("refreshTimeout", "-1");
    boolean finished = editPanelFragment.save();

    assertFalse("Config should not be saved and closed.Negative value.", finished);
    verifier.verifyAttribute(address, "refresh-timeout", "10000", 500);

    cliClient.executeCommand(remove);
  }

  @Test
  public void updateDiscoveryGroupInitialTimeout() {
    cliClient.executeCommand(command);
    page.navigateToMessaging();
    page.selectView("Clustering");
    page.switchToDiscovery();
    page.selectInTable(NAME, 0);
    page.edit();

    ConfigFragment editPanelFragment = page.getConfigFragment();

    editPanelFragment.getEditor().text("initialWaitTimeout", "200");
    boolean finished = editPanelFragment.save();

    assertTrue("Config should be saved and closed.", finished);
    verifier.verifyAttribute(address, "initial-wait-timeout", "200", 500);

    cliClient.executeCommand(remove);
  }

  @Test
  public void updateBroadcastGroupInitialTimeoutNegativeValue() {
    cliClient.executeCommand(command);
    page.navigateToMessaging();
    page.selectView("Clustering");
    page.switchToDiscovery();
    page.selectInTable(NAME, 0);
    page.edit();

    ConfigFragment editPanelFragment = page.getConfigFragment();

    editPanelFragment.getEditor().text("initialWaitTimeout", "-1");
    boolean finished = editPanelFragment.save();

    assertFalse("Config should not be saved and closed.Negative value.", finished);
    verifier.verifyAttribute(address, "initial-wait-timeout", "10000", 500);

    cliClient.executeCommand(remove);
  }

  @Test
  public void removeDiscoveryGroup() {
    cliClient.executeCommand(command);

    page.navigateToMessaging();
    page.selectView("Clustering");
    page.switchToDiscovery();

    verifier.verifyResource(address, true);

    page.selectInTable(NAME, 0);
    page.remove();

    verifier.verifyResource(address, false);
  }
}