1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.jboss.hal.testsuite.test.configuration.mail;
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.TableFragment;
26 import org.jboss.hal.testsuite.page.configuration.MailPage;
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.MethodOrderer;
31 import org.junit.jupiter.api.Test;
32 import org.junit.jupiter.api.TestMethodOrder;
33 import org.testcontainers.junit.jupiter.Container;
34 import org.testcontainers.junit.jupiter.Testcontainers;
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.IMAP;
40 import static org.jboss.hal.dmr.ModelDescriptionConstants.JNDI_NAME;
41 import static org.jboss.hal.dmr.ModelDescriptionConstants.NAME;
42 import static org.jboss.hal.dmr.ModelDescriptionConstants.OUTBOUND_SOCKET_BINDING_REF;
43 import static org.jboss.hal.dmr.ModelDescriptionConstants.POP3;
44 import static org.jboss.hal.dmr.ModelDescriptionConstants.SMTP;
45 import static org.jboss.hal.testsuite.container.WildFlyConfiguration.DEFAULT;
46 import static org.jboss.hal.testsuite.fixtures.MailFixtures.MAIL_SMTP;
47 import static org.jboss.hal.testsuite.fixtures.MailFixtures.SESSION_CREATE;
48 import static org.jboss.hal.testsuite.fixtures.MailFixtures.serverAddress;
49 import static org.jboss.hal.testsuite.fixtures.MailFixtures.sessionAddress;
50
51 @Manatoko
52 @Testcontainers
53 @TestMethodOrder(MethodOrderer.MethodName.class)
54 class MailServerCreateTest {
55
56 @Container static WildFlyContainer wildFly = WildFlyContainer.standalone(DEFAULT);
57
58 @BeforeAll
59 static void setupModel() throws Exception {
60 OnlineManagementClient client = wildFly.managementClient();
61 Operations operations = new Operations(client);
62 operations.add(sessionAddress(SESSION_CREATE), Values.of(JNDI_NAME, Random.jndiName(SESSION_CREATE)));
63 }
64
65 @Inject Console console;
66 @Inject CrudOperations crud;
67 @Page MailPage page;
68 TableFragment table;
69
70 @BeforeEach
71 void prepare() {
72 page.navigate(NAME, SESSION_CREATE);
73 console.verticalNavigation().selectPrimary(Ids.MAIL_SERVER_ITEM);
74 table = page.getMailServerTable();
75 }
76
77 @Test
78 void createIMAP() throws Exception {
79 createServer(IMAP);
80 }
81
82 @Test
83 void createPOP3() throws Exception {
84 createServer(POP3);
85 }
86
87 @Test
88 void createSMTP() throws Exception {
89 createServer(SMTP);
90 }
91
92 private void createServer(String type) throws Exception {
93 crud.create(serverAddress(SESSION_CREATE, type), table,
94 form -> form.text(OUTBOUND_SOCKET_BINDING_REF, MAIL_SMTP));
95 }
96 }