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.command.AddLocalSocketBinding;
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.SocketBindingPage;
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  
37  import static org.jboss.hal.dmr.ModelDescriptionConstants.NAME;
38  import static org.jboss.hal.dmr.ModelDescriptionConstants.SOCKET_BINDING_REF;
39  import static org.jboss.hal.testsuite.command.SocketBindingCommand.refName;
40  import static org.jboss.hal.testsuite.container.WildFlyConfiguration.DEFAULT;
41  import static org.jboss.hal.testsuite.fixtures.SocketBindingFixtures.OUTBOUND_LOCAL_CREATE;
42  import static org.jboss.hal.testsuite.fixtures.SocketBindingFixtures.OUTBOUND_LOCAL_DELETE;
43  import static org.jboss.hal.testsuite.fixtures.SocketBindingFixtures.OUTBOUND_LOCAL_UPDATE;
44  import static org.jboss.hal.testsuite.fixtures.SocketBindingFixtures.SOURCE_PORT;
45  import static org.jboss.hal.testsuite.fixtures.SocketBindingFixtures.STANDARD_SOCKETS;
46  import static org.jboss.hal.testsuite.fixtures.SocketBindingFixtures.outboundLocalAddress;
47  
48  @Manatoko
49  @Testcontainers
50  class OutboundLocalTest {
51  
52      @Container static WildFlyContainer wildFly = WildFlyContainer.standalone(DEFAULT);
53  
54      @BeforeAll
55      static void setupModel() throws Exception {
56          OnlineManagementClient client = wildFly.managementClient();
57          client.apply(
58                  new AddSocketBinding.Builder(refName(OUTBOUND_LOCAL_CREATE)).build(),
59                  new AddLocalSocketBinding(OUTBOUND_LOCAL_UPDATE),
60                  new AddLocalSocketBinding(OUTBOUND_LOCAL_DELETE));
61      }
62  
63      @Inject Console console;
64      @Inject CrudOperations crud;
65      @Page SocketBindingPage page;
66      TableFragment table;
67      FormFragment form;
68  
69      @BeforeEach
70      void prepare() {
71          page.navigate(NAME, STANDARD_SOCKETS);
72          console.verticalNavigation().selectPrimary(Ids.SOCKET_BINDING_GROUP_OUTBOUND_LOCAL + "-" + Ids.ITEM);
73  
74          table = page.getOutboundLocalTable();
75          form = page.getOutboundLocalForm();
76          table.bind(form);
77      }
78  
79      @Test
80      void create() throws Exception {
81          crud.create(outboundLocalAddress(STANDARD_SOCKETS, OUTBOUND_LOCAL_CREATE), table, form -> {
82              form.text(NAME, OUTBOUND_LOCAL_CREATE);
83              form.text(SOCKET_BINDING_REF, refName(OUTBOUND_LOCAL_CREATE));
84          });
85      }
86  
87      @Test
88      void update() throws Exception {
89          table.select(OUTBOUND_LOCAL_UPDATE);
90          crud.update(outboundLocalAddress(STANDARD_SOCKETS, OUTBOUND_LOCAL_UPDATE), form, SOURCE_PORT, 1234);
91      }
92  
93      @Test
94      void updateInvalidPort() {
95          table.select(OUTBOUND_LOCAL_UPDATE);
96          crud.updateWithError(form, SOURCE_PORT, -1);
97      }
98  
99      @Test
100     void reset() throws Exception {
101         table.select(OUTBOUND_LOCAL_UPDATE);
102         crud.reset(outboundLocalAddress(STANDARD_SOCKETS, OUTBOUND_LOCAL_UPDATE), form);
103     }
104 
105     @Test
106     void delete() throws Exception {
107         crud.delete(outboundLocalAddress(STANDARD_SOCKETS, OUTBOUND_LOCAL_DELETE), table, OUTBOUND_LOCAL_DELETE);
108     }
109 }