15
15
16
16
import java .io .File ;
17
17
import java .net .URI ;
18
+ import java .util .UUID ;
18
19
import java .util .logging .Level ;
19
20
import java .util .logging .Logger ;
20
21
21
22
import org .eclipse .paho .client .mqttv3 .IMqttClient ;
22
- import org .eclipse .paho .client .mqttv3 .IMqttDeliveryToken ;
23
- import org .eclipse .paho .client .mqttv3 .MqttCallback ;
24
- import org .eclipse .paho .client .mqttv3 .MqttConnectOptions ;
25
- import org .eclipse .paho .client .mqttv3 .MqttException ;
26
- import org .eclipse .paho .client .mqttv3 .MqttMessage ;
27
23
import org .eclipse .paho .client .mqttv3 .MqttTopic ;
28
24
import org .eclipse .paho .client .mqttv3 .test .client .MqttClientFactoryPaho ;
29
25
import org .eclipse .paho .client .mqttv3 .test .logging .LoggingUtilities ;
@@ -51,6 +47,8 @@ public class BasicSSLTest {
51
47
private static MqttClientFactoryPaho clientFactory ;
52
48
private static File keystorePath ;
53
49
private static int messageSize = 100000 ;
50
+ private static String topicPrefix ;
51
+
54
52
55
53
/**
56
54
* @throws Exception
@@ -66,6 +64,8 @@ public static void setUpBeforeClass() throws Exception {
66
64
serverHost = serverURI .getHost ();
67
65
clientFactory = new MqttClientFactoryPaho ();
68
66
clientFactory .open ();
67
+ topicPrefix = "BasicSSLTest-" + UUID .randomUUID ().toString () + "-" ;
68
+
69
69
}
70
70
catch (Exception exception ) {
71
71
log .log (Level .SEVERE , "caught exception:" , exception );
@@ -97,7 +97,7 @@ public static void tearDownAfterClass() throws Exception {
97
97
* An ssl connection with server cert authentication, simple pub/sub
98
98
* @throws Exception
99
99
*/
100
- @ Test
100
+ @ Test ( timeout = 10000 )
101
101
public void testSSL () throws Exception {
102
102
URI serverURI = new URI ("ssl://" + serverHost + ":" + TestProperties .getServerSSLPort ());
103
103
String methodName = Utility .getMethodName ();
@@ -118,7 +118,7 @@ public void testSSL() throws Exception {
118
118
log .info ("Connecting...(serverURI:" + serverURI + ", ClientId:" + methodName );
119
119
mqttClient .connect ();
120
120
121
- String [] topicNames = new String []{methodName + "/Topic" };
121
+ String [] topicNames = new String []{topicPrefix + methodName + "/Topic" };
122
122
int [] topicQos = {2 };
123
123
log .info ("Subscribing to..." + topicNames [0 ]);
124
124
mqttClient .subscribe (topicNames , topicQos );
@@ -160,7 +160,7 @@ public void testSSL() throws Exception {
160
160
* An ssl connection with server cert authentication, small workload with multiple clients
161
161
* @throws Exception
162
162
*/
163
- @ Test
163
+ @ Test ( timeout = 60000 )
164
164
public void testSSLWorkload () throws Exception {
165
165
URI serverURI = new URI ("ssl://" + serverHost + ":" + TestProperties .getServerSSLPort ());
166
166
String methodName = Utility .getMethodName ();
@@ -170,7 +170,7 @@ public void testSSLWorkload() throws Exception {
170
170
IMqttClient [] mqttPublisher = new IMqttClient [4 ];
171
171
IMqttClient [] mqttSubscriber = new IMqttClient [20 ];
172
172
try {
173
- String [] topicNames = new String []{methodName + "/Topic" };
173
+ String [] topicNames = new String []{topicPrefix + methodName + "/Topic" };
174
174
int [] topicQos = {0 };
175
175
176
176
MqttTopic [] mqttTopic = new MqttTopic [mqttPublisher .length ];
@@ -256,7 +256,7 @@ public void testSSLWorkload() throws Exception {
256
256
* 'messageSize' defined at start of test, change it to meet your requirements
257
257
* @throws Exception
258
258
*/
259
- @ Test
259
+ @ Test ( timeout = 10000 )
260
260
public void testSSLLargeMessage () throws Exception {
261
261
URI serverURI = new URI ("ssl://" + serverHost + ":" + TestProperties .getServerSSLPort ());
262
262
String methodName = Utility .getMethodName ();
@@ -278,7 +278,7 @@ public void testSSLLargeMessage() throws Exception {
278
278
log .info ("Connecting...(serverURI:" + serverURI + ", ClientId:" + methodName );
279
279
mqttClient .connect ();
280
280
281
- String [] topicNames = new String []{methodName + "/Topic" };
281
+ String [] topicNames = new String []{topicPrefix + methodName + "/Topic" };
282
282
int [] topicQos = {2 };
283
283
log .info ("Subscribing to..." + topicNames [0 ]);
284
284
mqttClient .subscribe (topicNames , topicQos );
@@ -322,7 +322,7 @@ public void testSSLLargeMessage() throws Exception {
322
322
* A non ssl connection to an ssl channel
323
323
* @throws Exception
324
324
*/
325
- @ Test
325
+ @ Test ( timeout = 10000 )
326
326
public void testNonSSLtoSSLChannel () throws Exception {
327
327
String methodName = Utility .getMethodName ();
328
328
LoggingUtilities .banner (log , cclass , methodName );
0 commit comments