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.configuration.distributableweb;
17  
18  import org.jboss.arquillian.core.api.annotation.Inject;
19  import org.jboss.arquillian.graphene.page.Page;
20  import org.jboss.hal.testsuite.Console;
21  import org.jboss.hal.testsuite.container.WildFlyContainer;
22  import org.jboss.hal.testsuite.fragment.SelectFragment;
23  import org.jboss.hal.testsuite.page.configuration.DistributableWebPage;
24  import org.jboss.hal.testsuite.test.Manatoko;
25  import org.junit.jupiter.api.BeforeAll;
26  import org.junit.jupiter.api.BeforeEach;
27  import org.junit.jupiter.api.Test;
28  import org.testcontainers.junit.jupiter.Container;
29  import org.testcontainers.junit.jupiter.Testcontainers;
30  import org.wildfly.extras.creaper.core.online.OnlineManagementClient;
31  import org.wildfly.extras.creaper.core.online.operations.Operations;
32  import org.wildfly.extras.creaper.core.online.operations.Values;
33  
34  import static org.jboss.hal.dmr.ModelDescriptionConstants.CACHE_CONTAINER;
35  import static org.jboss.hal.dmr.ModelDescriptionConstants.INFINISPAN;
36  import static org.jboss.hal.dmr.ModelDescriptionConstants.LOCAL;
37  import static org.jboss.hal.dmr.ModelDescriptionConstants.ROUTING;
38  import static org.jboss.hal.testsuite.container.WildFlyConfiguration.FULL;
39  import static org.jboss.hal.testsuite.fixtures.DistributableWebFixtures.SUBSYSTEM_ADDRESS;
40  import static org.jboss.hal.testsuite.fixtures.InfinispanFixtures.CC_READ;
41  import static org.jboss.hal.testsuite.test.configuration.distributableweb.DistributableWebOperations.addCacheContainer;
42  import static org.junit.jupiter.api.Assertions.fail;
43  
44  /**
45   * Switch from infinispan to local routing
46   */
47  @Manatoko
48  @Testcontainers
49  class DistributableWebLocalRoutingTest {
50  
51      @Container static WildFlyContainer wildFly = WildFlyContainer.standalone(FULL);
52  
53      @BeforeAll
54      static void setupModel() throws Exception {
55          OnlineManagementClient client = wildFly.managementClient();
56          Operations operations = new Operations(client);
57          addCacheContainer(client, operations, CC_READ);
58          operations.add(SUBSYSTEM_ADDRESS.and(ROUTING, INFINISPAN), Values.of(CACHE_CONTAINER, CC_READ));
59      }
60  
61      @Page DistributableWebPage page;
62      @Inject Console console;
63  
64      @BeforeEach
65      void prepare() {
66          page.navigate();
67          console.verticalNavigation().selectPrimary("dw-routing-item");
68      }
69  
70      @Test
71      void switchToInfinispan() {
72          console.waitNoNotification();
73          SelectFragment select = page.getSwitchRouting();
74          if (select != null) {
75              select.select(LOCAL, LOCAL);
76              console.verifySuccess();
77          } else {
78              fail("Select control to switch routing not found!");
79          }
80      }
81  }