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.remoting;
17  
18  import org.jboss.arquillian.core.api.annotation.Inject;
19  import org.jboss.arquillian.graphene.page.Page;
20  import org.jboss.hal.resources.Ids;
21  import org.jboss.hal.testsuite.Console;
22  import org.jboss.hal.testsuite.CrudOperations;
23  import org.jboss.hal.testsuite.Random;
24  import org.jboss.hal.testsuite.container.WildFlyContainer;
25  import org.jboss.hal.testsuite.fragment.FormFragment;
26  import org.jboss.hal.testsuite.fragment.TableFragment;
27  import org.jboss.hal.testsuite.page.configuration.RemotingPage;
28  import org.jboss.hal.testsuite.test.Manatoko;
29  import org.junit.jupiter.api.BeforeAll;
30  import org.junit.jupiter.api.BeforeEach;
31  import org.junit.jupiter.api.Test;
32  import org.testcontainers.junit.jupiter.Container;
33  import org.testcontainers.junit.jupiter.Testcontainers;
34  import org.wildfly.extras.creaper.commands.socketbindings.AddSocketBinding;
35  import org.wildfly.extras.creaper.core.online.OnlineManagementClient;
36  import org.wildfly.extras.creaper.core.online.operations.Operations;
37  import org.wildfly.extras.creaper.core.online.operations.Values;
38  
39  import static org.jboss.hal.dmr.ModelDescriptionConstants.NAME;
40  import static org.jboss.hal.dmr.ModelDescriptionConstants.SOCKET_BINDING;
41  import static org.jboss.hal.testsuite.container.WildFlyConfiguration.DEFAULT;
42  import static org.jboss.hal.testsuite.fixtures.RemotingFixtures.AUTHENTICATION_PROVIDER;
43  import static org.jboss.hal.testsuite.fixtures.RemotingFixtures.CONNECTOR_CREATE;
44  import static org.jboss.hal.testsuite.fixtures.RemotingFixtures.CONNECTOR_DELETE;
45  import static org.jboss.hal.testsuite.fixtures.RemotingFixtures.CONNECTOR_READ;
46  import static org.jboss.hal.testsuite.fixtures.RemotingFixtures.CONNECTOR_UPDATE;
47  import static org.jboss.hal.testsuite.fixtures.RemotingFixtures.connectorAddress;
48  import static org.jboss.hal.testsuite.fixtures.SocketBindingFixtures.INBOUND_READ;
49  import static org.junit.jupiter.api.Assertions.assertEquals;
50  
51  @Manatoko
52  @Testcontainers
53  class ConnectorTest {
54  
55      @Container static WildFlyContainer wildFly = WildFlyContainer.standalone(DEFAULT);
56  
57      @BeforeAll
58      static void setupModel() throws Exception {
59          OnlineManagementClient client = wildFly.managementClient();
60          Operations operations = new Operations(client);
61          client.apply(new AddSocketBinding.Builder(INBOUND_READ).build());
62          operations.add(connectorAddress(CONNECTOR_READ), Values.of(SOCKET_BINDING, INBOUND_READ));
63          operations.add(connectorAddress(CONNECTOR_UPDATE), Values.of(SOCKET_BINDING, INBOUND_READ));
64          operations.add(connectorAddress(CONNECTOR_DELETE), Values.of(SOCKET_BINDING, INBOUND_READ));
65      }
66  
67      @Inject Console console;
68      @Inject CrudOperations crud;
69      @Page RemotingPage page;
70      TableFragment table;
71      FormFragment form;
72  
73      @BeforeEach
74      void setUp() {
75          page.navigate();
76          console.verticalNavigation().selectSecondary("remoting-remote-connector-item",
77                  "remoting-connector-sub-item");
78          table = page.getConnectorTable();
79          form = page.getConnectorAttributesForm();
80          table.bind(form);
81      }
82  
83      @Test
84      void create() throws Exception {
85          crud.create(connectorAddress(CONNECTOR_CREATE), table, form -> {
86              form.text(NAME, CONNECTOR_CREATE);
87              form.text(SOCKET_BINDING, INBOUND_READ);
88          });
89      }
90  
91      @Test
92      void read() {
93          table.select(CONNECTOR_READ);
94          page.getConnectorTabs().select(Ids.REMOTING_CONNECTOR_TAB);
95          form.showSensitive(SOCKET_BINDING);
96          assertEquals(INBOUND_READ, form.value(SOCKET_BINDING));
97      }
98  
99      @Test
100     void update() throws Exception {
101         table.select(CONNECTOR_UPDATE);
102         page.getConnectorTabs().select(Ids.REMOTING_CONNECTOR_TAB);
103         crud.update(connectorAddress(CONNECTOR_UPDATE), form, AUTHENTICATION_PROVIDER, Random.name());
104     }
105 
106     @Test
107     void reset() throws Exception {
108         table.select(CONNECTOR_UPDATE);
109         page.getConnectorTabs().select(Ids.REMOTING_CONNECTOR_TAB);
110         crud.reset(connectorAddress(CONNECTOR_UPDATE), form);
111     }
112 }