1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.jboss.hal.testsuite.test.configuration.transaction;
17
18 import java.io.IOException;
19
20 import org.jboss.arquillian.core.api.annotation.Inject;
21 import org.jboss.arquillian.graphene.page.Page;
22 import org.jboss.hal.resources.Ids;
23 import org.jboss.hal.testsuite.Console;
24 import org.jboss.hal.testsuite.CrudOperations;
25 import org.jboss.hal.testsuite.Random;
26 import org.jboss.hal.testsuite.command.AddLocalSocketBinding;
27 import org.jboss.hal.testsuite.container.WildFlyContainer;
28 import org.jboss.hal.testsuite.fixtures.TransactionFixtures;
29 import org.jboss.hal.testsuite.page.configuration.TransactionPage;
30 import org.jboss.hal.testsuite.test.Manatoko;
31 import org.junit.jupiter.api.BeforeAll;
32 import org.junit.jupiter.api.BeforeEach;
33 import org.junit.jupiter.api.Test;
34 import org.openqa.selenium.TimeoutException;
35 import org.testcontainers.junit.jupiter.Container;
36 import org.testcontainers.junit.jupiter.Testcontainers;
37 import org.wildfly.extras.creaper.core.online.operations.Batch;
38 import org.wildfly.extras.creaper.core.online.operations.Operations;
39
40 import static org.jboss.hal.testsuite.container.WildFlyConfiguration.DEFAULT;
41 import static org.junit.jupiter.api.Assertions.fail;
42
43 @Manatoko
44 @Testcontainers
45 class ProcessTest {
46
47 @Container static WildFlyContainer wildFly = WildFlyContainer.standalone(DEFAULT);
48 private static Operations operations;
49
50 @BeforeAll
51 static void setupModel() throws Exception {
52 operations = new Operations(wildFly.managementClient());
53 wildFly.managementClient().apply(new AddLocalSocketBinding(TransactionFixtures.PROCESS_SOCKET_BINDING_CREATE));
54 wildFly.managementClient()
55 .apply(new AddLocalSocketBinding(TransactionFixtures.PROCESS_SOCKET_BINDING_WITH_PROCESS_ID_UUID));
56 }
57
58 @Inject Console console;
59 @Inject CrudOperations crudOperations;
60 @Page TransactionPage page;
61
62 @BeforeEach
63 void prepare() {
64 page.navigate();
65 console.verticalNavigation()
66 .selectPrimary(Ids.build("tx", "process", "item"));
67 }
68
69 @Test
70 void toggleProcessIDUUID() throws Exception {
71 boolean processIDUUID = operations
72 .readAttribute(TransactionFixtures.TRANSACTIONS_ADDRESS, TransactionFixtures.PROCESS_ID_UUID)
73 .booleanValue();
74 crudOperations.update(TransactionFixtures.TRANSACTIONS_ADDRESS, page.getProcessForm(), formFragment -> {
75 formFragment.flip(TransactionFixtures.PROCESS_ID_UUID, !processIDUUID);
76 if (processIDUUID) {
77 formFragment.text(TransactionFixtures.PROCESS_ID_SOCKET_BINDING,
78 TransactionFixtures.PROCESS_SOCKET_BINDING_WITH_PROCESS_ID_UUID);
79 } else {
80 formFragment.text(TransactionFixtures.PROCESS_ID_SOCKET_BINDING, "");
81 }
82 },
83 resourceVerifier -> resourceVerifier.verifyAttribute(TransactionFixtures.PROCESS_ID_UUID,
84 !processIDUUID));
85 }
86
87 @Test
88 void editProcessIdSocketBinding() throws Exception {
89 boolean processIDUUID = operations
90 .readAttribute(TransactionFixtures.TRANSACTIONS_ADDRESS, TransactionFixtures.PROCESS_ID_UUID)
91 .booleanValue();
92 crudOperations.update(TransactionFixtures.TRANSACTIONS_ADDRESS, page.getProcessForm(), formFragment -> {
93 if (processIDUUID) {
94 formFragment.flip(TransactionFixtures.PROCESS_ID_UUID, false);
95 }
96 formFragment.text(TransactionFixtures.PROCESS_ID_SOCKET_BINDING,
97 TransactionFixtures.PROCESS_SOCKET_BINDING_CREATE);
98 },
99 resourceVerifier -> resourceVerifier.verifyAttribute(TransactionFixtures.PROCESS_ID_SOCKET_BINDING,
100 TransactionFixtures.PROCESS_SOCKET_BINDING_CREATE));
101 }
102
103 @Test
104 void editProcessIDSocketMaxPorts() throws Exception {
105 prepareProcessID();
106 try {
107 crudOperations.update(TransactionFixtures.TRANSACTIONS_ADDRESS, page.getProcessForm(),
108 TransactionFixtures.PROCESS_ID_SOCKET_MAX_PORTS, Random.number());
109 } catch (TimeoutException e) {
110 fail("HAL-1454");
111 }
112 }
113
114 private void prepareProcessID() throws IOException {
115 Batch batch = new Batch().undefineAttribute(TransactionFixtures.TRANSACTIONS_ADDRESS,
116 TransactionFixtures.PROCESS_ID_UUID)
117 .writeAttribute(TransactionFixtures.TRANSACTIONS_ADDRESS, TransactionFixtures.PROCESS_ID_SOCKET_BINDING,
118 TransactionFixtures.PROCESS_SOCKET_BINDING_CREATE);
119 operations.batch(batch);
120 }
121 }