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.CrudOperations;
22  import org.jboss.hal.testsuite.container.WildFlyContainer;
23  import org.jboss.hal.testsuite.fragment.FormFragment;
24  import org.jboss.hal.testsuite.page.configuration.DistributableWebPage;
25  import org.jboss.hal.testsuite.test.Manatoko;
26  import org.junit.jupiter.api.BeforeAll;
27  import org.junit.jupiter.api.BeforeEach;
28  import org.junit.jupiter.api.Test;
29  import org.testcontainers.junit.jupiter.Container;
30  import org.testcontainers.junit.jupiter.Testcontainers;
31  import org.wildfly.extras.creaper.core.online.OnlineManagementClient;
32  import org.wildfly.extras.creaper.core.online.operations.Operations;
33  import org.wildfly.extras.creaper.core.online.operations.Values;
34  
35  import static org.jboss.hal.dmr.ModelDescriptionConstants.CACHE_CONTAINER;
36  import static org.jboss.hal.dmr.ModelDescriptionConstants.INFINISPAN;
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.DEFAULT_SESSION_MANAGEMENT;
40  import static org.jboss.hal.testsuite.fixtures.DistributableWebFixtures.DEFAULT_SSO_MANAGEMENT;
41  import static org.jboss.hal.testsuite.fixtures.DistributableWebFixtures.GRANULARITY;
42  import static org.jboss.hal.testsuite.fixtures.DistributableWebFixtures.INFINISPAN_SESSION_REF;
43  import static org.jboss.hal.testsuite.fixtures.DistributableWebFixtures.INFINISPAN_SSO_REF;
44  import static org.jboss.hal.testsuite.fixtures.DistributableWebFixtures.SESSION;
45  import static org.jboss.hal.testsuite.fixtures.DistributableWebFixtures.SUBSYSTEM_ADDRESS;
46  import static org.jboss.hal.testsuite.fixtures.DistributableWebFixtures.infinispanSSOAddress;
47  import static org.jboss.hal.testsuite.fixtures.DistributableWebFixtures.infinispanSessionAddress;
48  import static org.jboss.hal.testsuite.fixtures.InfinispanFixtures.CC_READ;
49  import static org.jboss.hal.testsuite.test.configuration.distributableweb.DistributableWebOperations.addCacheContainer;
50  
51  @Manatoko
52  @Testcontainers
53  class DistributableWebConfigurationTest {
54  
55      @Container static WildFlyContainer wildFly = WildFlyContainer.standalone(FULL);
56  
57      @BeforeAll
58      static void setupModel() throws Exception {
59          OnlineManagementClient client = wildFly.managementClient();
60          Operations operations = new Operations(client);
61          addCacheContainer(client, operations, CC_READ);
62          operations.add(SUBSYSTEM_ADDRESS.and(ROUTING, INFINISPAN), Values.of(CACHE_CONTAINER, CC_READ)).assertSuccess();
63          operations.add(infinispanSessionAddress(INFINISPAN_SESSION_REF), Values.of(CACHE_CONTAINER, CC_READ)
64                  .and(GRANULARITY, SESSION)).assertSuccess();
65          operations.add(infinispanSSOAddress(INFINISPAN_SSO_REF), Values.of(CACHE_CONTAINER, CC_READ)).assertSuccess();
66      }
67  
68      @Page DistributableWebPage page;
69      @Inject CrudOperations crud;
70      @Inject Console console;
71      FormFragment form;
72  
73      @BeforeEach
74      void prepare() {
75          page.navigate();
76          console.verticalNavigation().selectPrimary("dw-configuration-item");
77          form = page.getConfigurationForm();
78      }
79  
80      @Test
81      void update() throws Exception {
82          crud.update(SUBSYSTEM_ADDRESS, form,
83                  f -> {
84                      f.text(DEFAULT_SESSION_MANAGEMENT, INFINISPAN_SESSION_REF);
85                      f.text(DEFAULT_SSO_MANAGEMENT, INFINISPAN_SSO_REF);
86                  },
87                  verifier -> {
88                      verifier.verifyAttribute(DEFAULT_SESSION_MANAGEMENT, INFINISPAN_SESSION_REF);
89                      verifier.verifyAttribute(DEFAULT_SSO_MANAGEMENT, INFINISPAN_SSO_REF);
90                  });
91      }
92  }