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