View Javadoc
1   /*
2    *  Copyright 2022 Red Hat
3    *
4    *  Licensed under the Apache License, Version 2.0 (the "License");
5    *  you may not use this file except in compliance with the License.
6    *  You may obtain a copy of the License at
7    *
8    *      https://www.apache.org/licenses/LICENSE-2.0
9    *
10   *  Unless required by applicable law or agreed to in writing, software
11   *  distributed under the License is distributed on an "AS IS" BASIS,
12   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *  See the License for the specific language governing permissions and
14   *  limitations under the License.
15   */
16  package org.jboss.hal.testsuite.test.runtime.messaging;
17  
18  import java.io.IOException;
19  
20  import org.jboss.arquillian.core.api.annotation.Inject;
21  import org.jboss.hal.meta.token.NameTokens;
22  import org.jboss.hal.resources.Ids;
23  import org.jboss.hal.testsuite.Console;
24  import org.jboss.hal.testsuite.command.AddJmsBridge;
25  import org.jboss.hal.testsuite.container.WildFlyContainer;
26  import org.jboss.hal.testsuite.fragment.finder.FinderFragment;
27  import org.jboss.hal.testsuite.fragment.finder.FinderPath;
28  import org.jboss.hal.testsuite.fragment.finder.FinderPreviewFragment;
29  import org.jboss.hal.testsuite.model.ServerEnvironmentUtils;
30  import org.jboss.hal.testsuite.test.Manatoko;
31  import org.junit.jupiter.api.Assertions;
32  import org.junit.jupiter.api.BeforeAll;
33  import org.junit.jupiter.api.BeforeEach;
34  import org.junit.jupiter.api.Test;
35  import org.testcontainers.junit.jupiter.Container;
36  import org.testcontainers.junit.jupiter.Testcontainers;
37  import org.wildfly.extras.creaper.core.online.OnlineManagementClient;
38  
39  import static org.jboss.hal.dmr.ModelDescriptionConstants.MESSAGING_ACTIVEMQ;
40  import static org.jboss.hal.testsuite.container.WildFlyConfiguration.FULL_HA;
41  import static org.jboss.hal.testsuite.fixtures.MessagingFixtures.JMS_BRIDGE_READ;
42  import static org.jboss.hal.testsuite.fragment.finder.FinderFragment.runtimeSubsystemPath;
43  
44  @Manatoko
45  @Testcontainers
46  public class JmsBridgeTest {
47  
48      @Container static WildFlyContainer wildFly = WildFlyContainer.standalone(FULL_HA);
49      static ServerEnvironmentUtils serverEnvironmentUtils;
50  
51      @BeforeAll
52      static void setupModel() throws Exception {
53          OnlineManagementClient client = wildFly.managementClient();
54          client.apply(new AddJmsBridge(JMS_BRIDGE_READ));
55          serverEnvironmentUtils = new ServerEnvironmentUtils(client);
56      }
57  
58      @Inject Console console;
59      FinderFragment finder;
60  
61      @BeforeEach
62      void setUp() throws IOException {
63          FinderPath path = runtimeSubsystemPath(serverEnvironmentUtils.getServerHostName(), MESSAGING_ACTIVEMQ)
64                  .append(Ids.MESSAGING_CATEGORY_RUNTIME, Ids.JMS_BRIDGE_ITEM)
65                  .append(Ids.JMS_BRIDGE_RUNTIME, Ids.jmsBridge(JMS_BRIDGE_READ));
66          finder = console.finder(NameTokens.RUNTIME, path);
67      }
68  
69      @Test
70      void messageCount() {
71          FinderPreviewFragment preview = finder.preview();
72          String messageCount = preview.getMainAttributes().get("Message Count");
73          String abortedMessageCount = preview.getMainAttributes().get("Aborted Message Count");
74          Assertions.assertEquals(0, Integer.parseInt(messageCount));
75          Assertions.assertEquals(0, Integer.parseInt(abortedMessageCount));
76      }
77  }