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.socketbinding;
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.container.WildFlyContainer;
24  import org.jboss.hal.testsuite.fragment.FormFragment;
25  import org.jboss.hal.testsuite.fragment.TableFragment;
26  import org.jboss.hal.testsuite.page.configuration.SocketBindingPage;
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.commands.socketbindings.AddSocketBinding;
34  import org.wildfly.extras.creaper.core.online.OnlineManagementClient;
35  
36  import static org.jboss.hal.dmr.ModelDescriptionConstants.NAME;
37  import static org.jboss.hal.dmr.ModelDescriptionConstants.PORT;
38  import static org.jboss.hal.testsuite.container.WildFlyConfiguration.DEFAULT;
39  import static org.jboss.hal.testsuite.fixtures.SocketBindingFixtures.INBOUND_CREATE;
40  import static org.jboss.hal.testsuite.fixtures.SocketBindingFixtures.INBOUND_DELETE;
41  import static org.jboss.hal.testsuite.fixtures.SocketBindingFixtures.INBOUND_UPDATE;
42  import static org.jboss.hal.testsuite.fixtures.SocketBindingFixtures.STANDARD_SOCKETS;
43  import static org.jboss.hal.testsuite.fixtures.SocketBindingFixtures.inboundAddress;
44  
45  @Manatoko
46  @Testcontainers
47  class InboundTest {
48  
49      @Container static WildFlyContainer wildFly = WildFlyContainer.standalone(DEFAULT);
50  
51      @BeforeAll
52      static void setupModel() throws Exception {
53          OnlineManagementClient client = wildFly.managementClient();
54          client.apply(
55                  new AddSocketBinding.Builder(INBOUND_UPDATE).build(),
56                  new AddSocketBinding.Builder(INBOUND_DELETE).build());
57      }
58  
59      @Inject Console console;
60      @Inject CrudOperations crud;
61      @Page SocketBindingPage page;
62      TableFragment table;
63      FormFragment form;
64  
65      @BeforeEach
66      void setUp() {
67          page.navigate(NAME, STANDARD_SOCKETS);
68          console.verticalNavigation().selectPrimary(Ids.SOCKET_BINDING_GROUP_INBOUND + "-" + Ids.ITEM);
69  
70          table = page.getInboundTable();
71          form = page.getInboundForm();
72          table.bind(form);
73      }
74  
75      @Test
76      void create() throws Exception {
77          crud.create(inboundAddress(STANDARD_SOCKETS, INBOUND_CREATE), table, INBOUND_CREATE);
78      }
79  
80      @Test
81      void update() throws Exception {
82          table.select(INBOUND_UPDATE);
83          crud.update(inboundAddress(STANDARD_SOCKETS, INBOUND_UPDATE), form, PORT, 1234);
84      }
85  
86      @Test
87      void updateInvalidPort() {
88          table.select(INBOUND_UPDATE);
89          crud.updateWithError(form, PORT, -1);
90      }
91  
92      @Test
93      void reset() throws Exception {
94          table.select(INBOUND_UPDATE);
95          crud.reset(inboundAddress(STANDARD_SOCKETS, INBOUND_UPDATE), form);
96      }
97  
98      @Test
99      void delete() throws Exception {
100         crud.delete(inboundAddress(STANDARD_SOCKETS, INBOUND_DELETE), table, INBOUND_DELETE);
101     }
102 }