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.core.online.OnlineManagementClient;
34  import org.wildfly.extras.creaper.core.online.operations.Operations;
35  import org.wildfly.extras.creaper.core.online.operations.Values;
36  
37  import static org.jboss.hal.dmr.ModelDescriptionConstants.HOST;
38  import static org.jboss.hal.dmr.ModelDescriptionConstants.NAME;
39  import static org.jboss.hal.dmr.ModelDescriptionConstants.PORT;
40  import static org.jboss.hal.testsuite.container.WildFlyConfiguration.DEFAULT;
41  import static org.jboss.hal.testsuite.fixtures.SocketBindingFixtures.LOCALHOST;
42  import static org.jboss.hal.testsuite.fixtures.SocketBindingFixtures.OUTBOUND_REMOTE_CREATE;
43  import static org.jboss.hal.testsuite.fixtures.SocketBindingFixtures.OUTBOUND_REMOTE_DELETE;
44  import static org.jboss.hal.testsuite.fixtures.SocketBindingFixtures.OUTBOUND_REMOTE_PORT;
45  import static org.jboss.hal.testsuite.fixtures.SocketBindingFixtures.OUTBOUND_REMOTE_UPDATE;
46  import static org.jboss.hal.testsuite.fixtures.SocketBindingFixtures.SOURCE_PORT;
47  import static org.jboss.hal.testsuite.fixtures.SocketBindingFixtures.STANDARD_SOCKETS;
48  import static org.jboss.hal.testsuite.fixtures.SocketBindingFixtures.outboundRemoteAddress;
49  
50  @Manatoko
51  @Testcontainers
52  class OutboundRemoteTest {
53  
54      @Container static WildFlyContainer wildFly = WildFlyContainer.standalone(DEFAULT);
55  
56      @BeforeAll
57      static void setupModel() throws Exception {
58          OnlineManagementClient client = wildFly.managementClient();
59          Operations operations = new Operations(client);
60          operations.add(outboundRemoteAddress(STANDARD_SOCKETS, OUTBOUND_REMOTE_UPDATE),
61                  Values.of(HOST, LOCALHOST).and(PORT, OUTBOUND_REMOTE_PORT));
62          operations.add(outboundRemoteAddress(STANDARD_SOCKETS, OUTBOUND_REMOTE_DELETE),
63                  Values.of(HOST, LOCALHOST).and(PORT, OUTBOUND_REMOTE_PORT + 1));
64      }
65  
66      @Inject Console console;
67      @Inject CrudOperations crud;
68      @Page SocketBindingPage page;
69      TableFragment table;
70      FormFragment form;
71  
72      @BeforeEach
73      void setUp() {
74          page.navigate(NAME, STANDARD_SOCKETS);
75          console.verticalNavigation().selectPrimary(Ids.SOCKET_BINDING_GROUP_OUTBOUND_REMOTE + "-" + Ids.ITEM);
76  
77          table = page.getOutboundRemoteTable();
78          form = page.getOutboundRemoteForm();
79          table.bind(form);
80      }
81  
82      @Test
83      void create() throws Exception {
84          crud.create(outboundRemoteAddress(STANDARD_SOCKETS, OUTBOUND_REMOTE_CREATE), table, form -> {
85              form.text(NAME, OUTBOUND_REMOTE_CREATE);
86              form.text(HOST, LOCALHOST);
87              form.number(PORT, OUTBOUND_REMOTE_PORT - 1);
88          });
89      }
90  
91      @Test
92      void update() throws Exception {
93          table.select(OUTBOUND_REMOTE_UPDATE);
94          crud.update(outboundRemoteAddress(STANDARD_SOCKETS, OUTBOUND_REMOTE_UPDATE), form, PORT, 1234);
95      }
96  
97      @Test
98      void updateInvalidPort() {
99          table.select(OUTBOUND_REMOTE_UPDATE);
100         crud.updateWithError(form, SOURCE_PORT, -1);
101     }
102 
103     @Test
104     void delete() throws Exception {
105         crud.delete(outboundRemoteAddress(STANDARD_SOCKETS, OUTBOUND_REMOTE_DELETE), table, OUTBOUND_REMOTE_DELETE);
106     }
107 }