1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package dev.aherscu.qa.jgiven.rabbitmq;
18
19 import org.testng.annotations.*;
20
21 import com.rabbitmq.client.*;
22
23 import dev.aherscu.qa.jgiven.commons.utils.*;
24 import dev.aherscu.qa.jgiven.rabbitmq.model.*;
25 import dev.aherscu.qa.jgiven.rabbitmq.steps.*;
26 import dev.aherscu.qa.jgiven.rabbitmq.utils.*;
27 import lombok.*;
28
29 public abstract class AbstractRabbitMqTest<K, V> extends
30 ConfigurableScenarioTest<TestConfiguration, RabbitMqScenarioType, RabbitMqFixtures<K, V, ?>, RabbitMqActions<K, V, ?>, RabbitMqVerifications<K, V, ?>> {
31 protected QueueHandler<K, V> queueHandler;
32 protected Connection connection;
33
34 public AbstractRabbitMqTest(Class<TestConfiguration> configurationType) {
35 super(configurationType);
36 }
37
38 @BeforeClass
39 @SneakyThrows
40 protected final void beforeClassOpenConnection() {
41 connection = configuration().connectionFactory().newConnection();
42 }
43
44 @BeforeMethod
45 protected abstract void beforeMethodInitiateQueueHandler();
46
47 @AfterMethod(alwaysRun = true)
48 @SneakyThrows
49 protected final void afterMethodCloseQueueHandler() {
50 queueHandler.close();
51 }
52
53 @AfterClass(alwaysRun = true)
54 @SneakyThrows
55 protected final void afterClassCloseConnection() {
56 connection.close();
57 }
58 }