コード例 #1
0
@RunWith(Arquillian.class)
@Category(Shared.class)
public class BridgesTestCase extends AbstractMessagingTestCase {

  private static final String BRIDGE = "bridge_" + RandomStringUtils.randomAlphanumeric(5);
  private static final String BRIDGE_TBA = "bridge-TBA_" + RandomStringUtils.randomAlphanumeric(5);
  private static final String BRIDGE_TBR = "bridge-TBR_" + RandomStringUtils.randomAlphanumeric(5);

  private static final Address BRIDGE_ADDRESS = DEFAULT_MESSAGING_SERVER.and("bridge", BRIDGE);
  private static final Address BRIDGE_TBR_ADDRESS =
      DEFAULT_MESSAGING_SERVER.and("bridge", BRIDGE_TBR);
  private static final Address BRIDGE_TBA_ADDRESS =
      DEFAULT_MESSAGING_SERVER.and("bridge", BRIDGE_TBA);

  private static final String CONNECTOR = "http-connector";
  private static final String QUEUE_CREATE_BRIDGE =
      "testQueue_" + RandomStringUtils.randomAlphanumeric(5);
  private static final String QUEUE_EDIT_BRIDGE =
      "testQueue_" + RandomStringUtils.randomAlphanumeric(5);
  private static final String DISCOVERY_GROUP_EDIT =
      "discoveryGroupBridges_" + RandomStringUtils.randomAlphanumeric(5);

  @BeforeClass
  public static void setUp() throws Exception {
    // add queues
    List<String> entriesQueueCreateBridge = Collections.singletonList(QUEUE_CREATE_BRIDGE);
    List<String> entriesQueueEditBridge = Collections.singletonList(QUEUE_EDIT_BRIDGE);
    client.apply(
        new AddQueue.Builder(QUEUE_CREATE_BRIDGE).jndiEntries(entriesQueueCreateBridge).build());
    client.apply(
        new AddQueue.Builder(QUEUE_EDIT_BRIDGE).jndiEntries(entriesQueueEditBridge).build());
    // add bridges
    createBridge(BRIDGE_ADDRESS);
    createBridge(BRIDGE_TBR_ADDRESS);

    administration.reloadIfRequired();
  }

  @Page private MessagingPage page;

  @Before
  public void before() {
    page.navigateToMessaging();
    page.selectConnectionsView();
    page.switchToBridges();
    page.selectInTable(BRIDGE);
  }

  @After
  public void after() throws InterruptedException, TimeoutException, IOException {
    administration.reloadIfRequired();
  }

  @AfterClass
  public static void afterClass()
      throws IOException, OperationException, CommandFailedException, TimeoutException,
          InterruptedException {
    // remove bridges
    operations.removeIfExists(BRIDGE_ADDRESS);
    operations.removeIfExists(BRIDGE_TBA_ADDRESS);
    operations.removeIfExists(BRIDGE_TBR_ADDRESS);
    // remove queues
    client.apply(new RemoveQueue(QUEUE_CREATE_BRIDGE));
    client.apply(new RemoveQueue(QUEUE_EDIT_BRIDGE));
  }

  @Test
  public void addBridge() throws Exception {
    page.addBridge(BRIDGE_TBA, QUEUE_CREATE_BRIDGE, "testAddress", CONNECTOR);
    new ResourceVerifier(BRIDGE_TBA_ADDRESS, client).verifyExists();
  }

  @Test
  public void updateBridgeFilter() throws Exception {
    editTextAndVerify(BRIDGE_ADDRESS, "filter", "testFilter");
  }

  @Test
  public void updateBridgeQueue() throws Exception {
    editTextAndVerify(BRIDGE_ADDRESS, "queueName", "queue-name", QUEUE_EDIT_BRIDGE);
  }

  @Test
  public void updateBridgeForwardingAddress() throws Exception {
    editTextAndVerify(BRIDGE_ADDRESS, "forwardingAddress", "forwarding-address", "127.0.0.1");
  }

  @Test
  public void updateBridgeTransformerClass() throws Exception {
    try {
      new ConfigChecker.Builder(client, BRIDGE_ADDRESS)
          .configFragment(page.getConfigFragment())
          .editAndSave(ConfigChecker.InputType.TEXT, "transformerClass", "clazz")
          .verifyFormSaved()
          .verifyAttribute("transformer-class-name", "clazz");
    } finally {
      operations.undefineAttribute(BRIDGE_ADDRESS, "transformer-class-name");
    }
  }

  @Test
  public void updateBridgeDiscoveryGroup() throws Exception {
    try {
      ConfigFragment editPanelFragment = page.getConfigFragment();
      Editor editor = editPanelFragment.edit();

      editor.text("staticConnectors", "");
      editor.text("discoveryGroup", DISCOVERY_GROUP_EDIT);
      boolean finished = editPanelFragment.save();

      Assert.assertTrue("Config should be saved and closed.", finished);
      new ResourceVerifier(BRIDGE_ADDRESS, client)
          .verifyAttribute("discovery-group", DISCOVERY_GROUP_EDIT);
    } finally {
      operations.undefineAttribute(BRIDGE_ADDRESS, "discovery-group");
    }
  }

  @Test
  public void updateBridgePassword() throws Exception {
    page.switchToConnectionManagementTab();
    editTextAndVerify(BRIDGE_ADDRESS, "password", "pwd1");
  }

  @Test
  public void updateBridgeRetryInterval() throws Exception {
    page.switchToConnectionManagementTab();
    editTextAndVerify(BRIDGE_ADDRESS, "retryInterval", "retry-interval", 1L);
  }

  @Test
  public void updateBridgeRetryIntervalWrongValue() {
    page.switchToConnectionManagementTab();
    verifyIfErrorAppears("retryInterval", "-10");
  }

  @Test
  public void updateBridgeReconnectAttempts() throws Exception {
    page.switchToConnectionManagementTab();
    editTextAndVerify(BRIDGE_ADDRESS, "reconnectAttempts", "reconnect-attempts", -1);
  }

  @Test
  public void removeBridge() throws Exception {
    page.remove(BRIDGE_TBR);
    new ResourceVerifier(BRIDGE_TBR_ADDRESS, client).verifyDoesNotExist();
  }

  private static void createBridge(Address address) throws Exception {
    operations.add(
        address,
        Values.empty()
            .andList("static-connectors", CONNECTOR)
            .and("queue-name", QUEUE_CREATE_BRIDGE));
    new ResourceVerifier(address, client).verifyExists();
  }
}
コード例 #2
0
@RunWith(Arquillian.class)
@Category(Shared.class)
public class QueuesTopicsTestCase extends AbstractMessagingTestCase {

  private static final String QUEUE_TBA =
      "test-queue-TBA_" + RandomStringUtils.randomAlphanumeric(5);
  private static final String QUEUE_TBR =
      "test-queue-TBR_" + RandomStringUtils.randomAlphanumeric(5);

  private static final Address QUEUE_TBA_ADDRESS =
      DEFAULT_MESSAGING_SERVER.and("jms-queue", QUEUE_TBA);
  private static final Address QUEUE_TBR_ADDRESS =
      DEFAULT_MESSAGING_SERVER.and("jms-queue", QUEUE_TBR);

  private static final String TOPIC = "test-topic_" + RandomStringUtils.randomAlphanumeric(5);
  private static final String TOPIC_TBA =
      "test-topic-TBA_" + RandomStringUtils.randomAlphanumeric(5);
  private static final String TOPIC_TBR =
      "test-topic-TBR_" + RandomStringUtils.randomAlphanumeric(5);

  private static final Address TOPIC_ADDRESS = DEFAULT_MESSAGING_SERVER.and("jms-topic", TOPIC);
  private static final Address TOPIC_TBA_ADDRESS =
      DEFAULT_MESSAGING_SERVER.and("jms-topic", TOPIC_TBA);
  private static final Address TOPIC_TBR_ADDRESS =
      DEFAULT_MESSAGING_SERVER.and("jms-topic", TOPIC_TBR);

  private static final String JNDI_NAME =
      "java:/jndi-queue_" + RandomStringUtils.randomAlphanumeric(5);
  private static final String JNDI_TOPICS_NAME = "java:/jndi-topics";

  @BeforeClass
  public static void setUp()
      throws CommandFailedException, InterruptedException, TimeoutException, IOException {
    client.apply(new AddQueue.Builder(QUEUE_TBR).jndiEntries(getJNDIEntriesList()).build());
    client.apply(new AddTopic.Builder(TOPIC).jndiEntries(getJNDIEntriesList()).build());
    client.apply(new AddTopic.Builder(TOPIC_TBR).jndiEntries(getJNDIEntriesList()).build());
    administration.reloadIfRequired();
  }

  @AfterClass
  public static void tearDown() throws CommandFailedException, IOException, OperationException {
    operations.removeIfExists(QUEUE_TBA_ADDRESS);
    operations.removeIfExists(QUEUE_TBR_ADDRESS);
    operations.removeIfExists(TOPIC_ADDRESS);
    operations.removeIfExists(TOPIC_TBA_ADDRESS);
    operations.removeIfExists(TOPIC_TBR_ADDRESS);
  }

  @Page private MessagingPage page;

  @Before
  public void before() {
    page.navigateToMessaging();
    page.selectQueuesAndTopics();
    page.switchToJmsQueuesTopics();
    page.selectInTable(TOPIC);
  }

  @After
  public void after() throws InterruptedException, TimeoutException, IOException {
    administration.reloadIfRequired();
  }

  @Test
  public void addJmsQueue() throws Exception {
    page.addQueue(QUEUE_TBA, JNDI_NAME);
    new ResourceVerifier(QUEUE_TBA_ADDRESS, client).verifyExists();
  }

  @Test
  public void removeJmsQueue() throws Exception {
    page.remove(QUEUE_TBR);
    new ResourceVerifier(QUEUE_TBR_ADDRESS, client).verifyDoesNotExist();
  }

  @Test
  public void addJmsTopics() throws Exception {
    page.getConfig().topicsConfig();
    page.addTopic(TOPIC_TBA, JNDI_TOPICS_NAME);
    new ResourceVerifier(TOPIC_TBA_ADDRESS, client).verifyExists();
  }

  @Test
  public void updateTopicsJndiNames() throws InterruptedException, TimeoutException, IOException {
    page.getConfig().topicsConfig();
    page.selectInTable(TOPIC);

    String jndiName = "java:/jndi-name" + RandomStringUtils.randomAlphanumeric(5);

    ConfigFragment editPanelFragment = page.getConfigFragment();

    editPanelFragment.edit().text("entries", jndiName);
    boolean finished = editPanelFragment.save();

    administration.reloadIfRequired();

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

    ModelNodeResult result = operations.readAttribute(TOPIC_ADDRESS, "entries");

    Assert.assertTrue(result.hasDefinedValue() && result.stringValue().contains(jndiName));
  }

  @Test
  public void removeJmsTopics() throws Exception {
    page.getConfig().topicsConfig();
    page.remove(TOPIC_TBR);
    new ResourceVerifier(TOPIC_TBR_ADDRESS, client).verifyDoesNotExist();
  }

  private static List<String> getJNDIEntriesList() {
    List<String> jndi = new LinkedList<>();
    jndi.add("java:/jndi-entry-dummy_" + RandomStringUtils.randomAlphanumeric(5));
    return jndi;
  }
}