34
34
import org .testcontainers .utility .MountableFile ;
35
35
36
36
import java .io .ByteArrayInputStream ;
37
- import java .io .IOException ;
38
- import java .nio .file .Files ;
39
- import java .nio .file .Path ;
40
37
import java .util .List ;
41
38
import java .util .concurrent .TimeoutException ;
42
39
import java .util .stream .Collectors ;
@@ -74,7 +71,7 @@ void tearDown() {
74
71
}
75
72
76
73
@ Test
77
- void threeNodesFormCluster () throws IOException , TimeoutException {
74
+ void threeNodesFormCluster () throws TimeoutException {
78
75
final WaitingConsumer consumer1 = new WaitingConsumer ();
79
76
final WaitingConsumer consumer2 = new WaitingConsumer ();
80
77
final WaitingConsumer consumer3 = new WaitingConsumer ();
@@ -95,7 +92,7 @@ void threeNodesFormCluster() throws IOException, TimeoutException {
95
92
}
96
93
97
94
@ Test
98
- void twoNodesInCluster_oneNodeStarted_threeNodesInCluster () throws IOException , TimeoutException {
95
+ void twoNodesInCluster_oneNodeStarted_threeNodesInCluster () throws TimeoutException {
99
96
final WaitingConsumer consumer1 = new WaitingConsumer ();
100
97
final WaitingConsumer consumer2 = new WaitingConsumer ();
101
98
final WaitingConsumer consumer3 = new WaitingConsumer ();
@@ -118,7 +115,7 @@ void twoNodesInCluster_oneNodeStarted_threeNodesInCluster() throws IOException,
118
115
}
119
116
120
117
@ Test
121
- void twoNodesInCluster_oneNodeCannotReachAzure_nodeFileDeleted () throws IOException , TimeoutException {
118
+ void twoNodesInCluster_oneNodeCannotReachAzure_nodeFileDeleted () throws TimeoutException {
122
119
final ToxiproxyContainer toxiproxy = new ToxiproxyContainer (OciImages .getImageName ("shopify/toxiproxy" )) //
123
120
.withNetwork (network ).withNetworkAliases (TOXIPROXY_NETWORK_ALIAS );
124
121
try (toxiproxy ) {
@@ -153,7 +150,7 @@ void twoNodesInCluster_oneNodeCannotReachAzure_nodeFileDeleted() throws IOExcept
153
150
}
154
151
155
152
@ Test
156
- void threeNodesInCluster_oneNodeStopped_twoNodesInCluster () throws IOException , TimeoutException {
153
+ void threeNodesInCluster_oneNodeStopped_twoNodesInCluster () throws TimeoutException {
157
154
final WaitingConsumer consumer1 = new WaitingConsumer ();
158
155
final WaitingConsumer consumer2 = new WaitingConsumer ();
159
156
final WaitingConsumer consumer3 = new WaitingConsumer ();
@@ -187,7 +184,7 @@ void threeNodesInCluster_oneNodeStopped_twoNodesInCluster() throws IOException,
187
184
}
188
185
189
186
@ Test
190
- void wrongConnectionString_reloadRightConnectionString_clusterCreated () throws IOException , TimeoutException {
187
+ void wrongConnectionString_reloadRightConnectionString_clusterCreated () throws TimeoutException {
191
188
final String wrongConnectionString = "DefaultEndpointsProtocol=http;" + //
192
189
"AccountName=devstoreaccount1;" +
193
190
"AccountKey=XXX8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;" +
@@ -211,7 +208,7 @@ void wrongConnectionString_reloadRightConnectionString_clusterCreated() throws I
211
208
}
212
209
213
210
@ Test
214
- void containerNotExisting_nodeStarted_containerCreated () throws IOException {
211
+ void containerNotExisting_nodeStarted_containerCreated () {
215
212
final BlobContainerClient blobContainerClient = new BlobContainerClientBuilder ().connectionString (createHostAzuriteConnectionString ())
216
213
.containerName (BLOB_CONTAINER_NAME )
217
214
.buildClient ();
@@ -228,7 +225,7 @@ void containerNotExisting_nodeStarted_containerCreated() throws IOException {
228
225
}
229
226
230
227
@ Test
231
- void containerExisting_nodeStarted_containerUsed () throws IOException {
228
+ void containerExisting_nodeStarted_containerUsed () {
232
229
final BlobContainerClient blobContainerClient = new BlobContainerClientBuilder ().connectionString (createHostAzuriteConnectionString ())
233
230
.containerName (BLOB_CONTAINER_NAME )
234
231
.buildClient ();
@@ -271,20 +268,16 @@ void containerExisting_nodeStarted_containerUsed() throws IOException {
271
268
return createAzuriteConnectionString ("127.0.0.1" , azureriteContainer .getMappedPort (AZURITE_PORT ));
272
269
}
273
270
274
- private @ NotNull HiveMQContainer createHiveMQNode (final @ NotNull String connectionString ) throws IOException {
275
-
276
- final Path configFile = Files .createTempDirectory ("az-extension-test" ).resolve ("azDiscovery.properties" );
277
- Files .writeString (configFile , createConfig (connectionString ));
278
-
279
- return new HiveMQContainer (OciImages .getImageName ("hivemq/hivemq4" )) //
271
+ private @ NotNull HiveMQContainer createHiveMQNode (final @ NotNull String connectionString ) {
272
+ return new HiveMQContainer (OciImages .getImageName ("hivemq/extensions/hivemq-azure-cluster-discovery-extension" )
273
+ .asCompatibleSubstituteFor ("hivemq/hivemq4" )) //
280
274
.withHiveMQConfig (MountableFile .forClasspathResource ("config.xml" ))
281
- .withExtension (MountableFile .forClasspathResource ("hivemq-azure-cluster-discovery-extension" ))
282
- .withFileInExtensionHomeFolder (MountableFile .forHostPath (configFile ),
283
- "hivemq-azure-cluster-discovery-extension" )
275
+ .withCopyToContainer (Transferable .of (createConfig (connectionString )),
276
+ "/opt/hivemq/extensions/hivemq-azure-cluster-discovery-extension/azDiscovery.properties" )
284
277
.withNetwork (network );
285
278
}
286
279
287
- private @ NotNull HiveMQContainer createHiveMQNode () throws IOException {
280
+ private @ NotNull HiveMQContainer createHiveMQNode () {
288
281
return createHiveMQNode (createDockerAzuriteConnectionString ());
289
282
}
290
283
}
0 commit comments