|
| 1 | +// Jest Snapshot v1, https://goo.gl/fbAQLP |
| 2 | + |
| 3 | +exports[`InitConnector component (integration with AsyncAPI document) renders with TimedConnection when queryParamsArray is empty array 1`] = ` |
| 4 | +"@PostConstruct |
| 5 | + void openAndSendMessagesWithDelay() { |
| 6 | + new Thread(() -> { |
| 7 | + try { |
| 8 | + Log.info(\\"Starting WebSocket connection attempt...\\"); |
| 9 | + WebSocketClientConnection connection = connector.connectAndAwait(); |
| 10 | +
|
| 11 | + // Wait 2 seconds before first message |
| 12 | + Thread.sleep(2000); |
| 13 | +
|
| 14 | + // Send 5 messages |
| 15 | + for (int i = 1; i <= 5; i++) { |
| 16 | + // Send a message to any available operation by including its operation ID (i.e. \\"sendMessage\\") |
| 17 | + String msg = \\"Message #\\" + i + \\" from Quarkus for sendMessage\\"; |
| 18 | + connection.sendTextAndAwait(msg); |
| 19 | + Log.info(\\"Sent: \\" + msg); |
| 20 | + Thread.sleep(5000); // Wait 5 seconds between messages |
| 21 | + } |
| 22 | +
|
| 23 | + // Wait 10 seconds after final message |
| 24 | + Log.info(\\"All messages sent. Waiting 10 seconds before closing...\\"); |
| 25 | + Thread.sleep(10000); |
| 26 | +
|
| 27 | +
|
| 28 | + // Calling to close the WebSocket connection |
| 29 | + |
| 30 | +
|
| 31 | + connection.closeAndAwait(); |
| 32 | + Log.info(\\"Connection closed gracefully.\\"); |
| 33 | + Thread.sleep(1000); // Wait for a second before exiting |
| 34 | + System.exit(0); |
| 35 | + } catch (Exception e) { |
| 36 | + Log.error(\\"Error during WebSocket communication\\", e); |
| 37 | + System.exit(1); |
| 38 | + } |
| 39 | + }).start(); |
| 40 | + } |
| 41 | +}" |
| 42 | +`; |
| 43 | + |
| 44 | +exports[`InitConnector component (integration with AsyncAPI document) renders with TimedConnection when queryParamsArray is null 1`] = ` |
| 45 | +"@PostConstruct |
| 46 | + void openAndSendMessagesWithDelay() { |
| 47 | + new Thread(() -> { |
| 48 | + try { |
| 49 | + Log.info(\\"Starting WebSocket connection attempt...\\"); |
| 50 | + WebSocketClientConnection connection = connector.connectAndAwait(); |
| 51 | +
|
| 52 | + // Wait 2 seconds before first message |
| 53 | + Thread.sleep(2000); |
| 54 | +
|
| 55 | + // Send 5 messages |
| 56 | + for (int i = 1; i <= 5; i++) { |
| 57 | + // Send a message to any available operation by including its operation ID (i.e. \\"sendMessage\\") |
| 58 | + String msg = \\"Message #\\" + i + \\" from Quarkus for sendMessage\\"; |
| 59 | + connection.sendTextAndAwait(msg); |
| 60 | + Log.info(\\"Sent: \\" + msg); |
| 61 | + Thread.sleep(5000); // Wait 5 seconds between messages |
| 62 | + } |
| 63 | +
|
| 64 | + // Wait 10 seconds after final message |
| 65 | + Log.info(\\"All messages sent. Waiting 10 seconds before closing...\\"); |
| 66 | + Thread.sleep(10000); |
| 67 | +
|
| 68 | +
|
| 69 | + // Calling to close the WebSocket connection |
| 70 | + |
| 71 | +
|
| 72 | + connection.closeAndAwait(); |
| 73 | + Log.info(\\"Connection closed gracefully.\\"); |
| 74 | + Thread.sleep(1000); // Wait for a second before exiting |
| 75 | + System.exit(0); |
| 76 | + } catch (Exception e) { |
| 77 | + Log.error(\\"Error during WebSocket communication\\", e); |
| 78 | + System.exit(1); |
| 79 | + } |
| 80 | + }).start(); |
| 81 | + } |
| 82 | +}" |
| 83 | +`; |
| 84 | + |
| 85 | +exports[`InitConnector component (integration with AsyncAPI document) renders with TimedConnection when queryParamsArray is undefined 1`] = ` |
| 86 | +"@PostConstruct |
| 87 | + void openAndSendMessagesWithDelay() { |
| 88 | + new Thread(() -> { |
| 89 | + try { |
| 90 | + Log.info(\\"Starting WebSocket connection attempt...\\"); |
| 91 | + WebSocketClientConnection connection = connector.connectAndAwait(); |
| 92 | +
|
| 93 | + // Wait 2 seconds before first message |
| 94 | + Thread.sleep(2000); |
| 95 | +
|
| 96 | + // Send 5 messages |
| 97 | + for (int i = 1; i <= 5; i++) { |
| 98 | + // Send a message to any available operation by including its operation ID (i.e. \\"sendMessage\\") |
| 99 | + String msg = \\"Message #\\" + i + \\" from Quarkus for sendMessage\\"; |
| 100 | + connection.sendTextAndAwait(msg); |
| 101 | + Log.info(\\"Sent: \\" + msg); |
| 102 | + Thread.sleep(5000); // Wait 5 seconds between messages |
| 103 | + } |
| 104 | +
|
| 105 | + // Wait 10 seconds after final message |
| 106 | + Log.info(\\"All messages sent. Waiting 10 seconds before closing...\\"); |
| 107 | + Thread.sleep(10000); |
| 108 | +
|
| 109 | +
|
| 110 | + // Calling to close the WebSocket connection |
| 111 | + |
| 112 | +
|
| 113 | + connection.closeAndAwait(); |
| 114 | + Log.info(\\"Connection closed gracefully.\\"); |
| 115 | + Thread.sleep(1000); // Wait for a second before exiting |
| 116 | + System.exit(0); |
| 117 | + } catch (Exception e) { |
| 118 | + Log.error(\\"Error during WebSocket communication\\", e); |
| 119 | + System.exit(1); |
| 120 | + } |
| 121 | + }).start(); |
| 122 | + } |
| 123 | +}" |
| 124 | +`; |
| 125 | + |
| 126 | +exports[`InitConnector component (integration with AsyncAPI document) renders without TimedConnection when queryParamsArray has data from fixture 1`] = ` |
| 127 | +"@PostConstruct |
| 128 | + void openAndSendMessagesWithDelay() { |
| 129 | + new Thread(() -> { |
| 130 | + try { |
| 131 | + Log.info(\\"Starting WebSocket connection attempt...\\"); |
| 132 | + // URI parameters |
| 133 | + String query = \\"\\"; |
| 134 | + |
| 135 | + String heartbeat = System.getenv(\\"HEARTBEAT\\"); |
| 136 | + if(heartbeat == null || heartbeat.isEmpty()){ |
| 137 | + throw new IllegalArgumentException(\\"Required environment variable HEARTBEAT is missing or empty\\"); |
| 138 | + } |
| 139 | + query += \\"heartbeat=\\" + URLEncoder.encode(heartbeat, StandardCharsets.UTF_8); |
| 140 | +
|
| 141 | + String bids = System.getenv(\\"BIDS\\"); |
| 142 | + if(bids == null || bids.isEmpty()){ |
| 143 | + throw new IllegalArgumentException(\\"Required environment variable BIDS is missing or empty\\"); |
| 144 | + } |
| 145 | + query += \\"&bids=\\" + URLEncoder.encode(bids, StandardCharsets.UTF_8); |
| 146 | +
|
| 147 | + String sessionId = System.getenv(\\"SESSIONID\\"); |
| 148 | + if(sessionId == null || sessionId.isEmpty()){ |
| 149 | + throw new IllegalArgumentException(\\"Required environment variable SESSIONID is missing or empty\\"); |
| 150 | + } |
| 151 | + query += \\"&sessionId=\\" + URLEncoder.encode(sessionId, StandardCharsets.UTF_8); |
| 152 | +
|
| 153 | +
|
| 154 | + String queryUri = baseURI + \\"/link\\" + \\"?\\" + query; |
| 155 | + WebSocketClientConnection connection = connector.baseUri(queryUri).connectAndAwait(); |
| 156 | + Thread.sleep(120000); // Keep the connection open for 2 minutes |
| 157 | + |
| 158 | +
|
| 159 | + // Calling to close the WebSocket connection |
| 160 | + |
| 161 | +
|
| 162 | + connection.closeAndAwait(); |
| 163 | + Log.info(\\"Connection closed gracefully.\\"); |
| 164 | + Thread.sleep(1000); // Wait for a second before exiting |
| 165 | + System.exit(0); |
| 166 | + } catch (Exception e) { |
| 167 | + Log.error(\\"Error during WebSocket communication\\", e); |
| 168 | + System.exit(1); |
| 169 | + } |
| 170 | + }).start(); |
| 171 | + } |
| 172 | +}" |
| 173 | +`; |
0 commit comments