Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ public class WebSocketSampler extends AbstractSampler implements TestStateListen

private static Map<String, ServiceSocket> connectionList;

private static ExecutorService executor = Executors.newCachedThreadPool();

private static ExecutorService executor;
public WebSocketSampler() {
super();
setName("WebSocket sampler");
Expand All @@ -70,14 +70,20 @@ private ServiceSocket getConnectionSocket() throws URISyntaxException, Exception
String connectionId = getThreadName() + getConnectionId();

if (isStreamingConnection() && connectionList.containsKey(connectionId)) {
ServiceSocket socket = connectionList.get(connectionId);
socket.initialize();
return socket;
ServiceSocket socket = connectionList.get(connectionId);
if (!isResetStreamingConnection()) {
socket.initialize();
return socket;
} else {
connectionList.remove(connectionId);
socket.close();
}
}

//Create WebSocket client
SslContextFactory sslContexFactory = new SslContextFactory();
sslContexFactory.setTrustAll(isIgnoreSslErrors());
// WebSocketClient webSocketClient = new WebSocketClient(sslContexFactory, executor);
WebSocketClient webSocketClient = new WebSocketClient(sslContexFactory, executor);

ServiceSocket socket = new ServiceSocket(this, webSocketClient);
Expand Down Expand Up @@ -354,10 +360,18 @@ public Boolean isIgnoreSslErrors() {
public void setStreamingConnection(Boolean streamingConnection) {
setProperty("streamingConnection", streamingConnection);
}

public Boolean isStreamingConnection() {
return getPropertyAsBoolean("streamingConnection");
}

public void setResetStreamingConnection(Boolean resetStreamingConnection) {
setProperty("resetStreamingConnection", resetStreamingConnection);
}

public Boolean isResetStreamingConnection() {
return getPropertyAsBoolean("resetStreamingConnection");
}

public void setConnectionId(String connectionId) {
setProperty("connectionId", connectionId);
Expand Down Expand Up @@ -486,6 +500,7 @@ public void testStarted() {
@Override
public void testStarted(String host) {
connectionList = new ConcurrentHashMap<String, ServiceSocket>();
executor = Executors.newCachedThreadPool();
}

@Override
Expand All @@ -498,6 +513,7 @@ public void testEnded(String host) {
for (ServiceSocket socket : connectionList.values()) {
socket.close();
}
executor.shutdown();
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public void configure(TestElement element) {
webSocketSamplerPanel.setConnectionTimeout(webSocketSamplerTestElement.getConnectionTimeout());
webSocketSamplerPanel.setIgnoreSslErrors(webSocketSamplerTestElement.isIgnoreSslErrors());
webSocketSamplerPanel.setStreamingConnection(webSocketSamplerTestElement.isStreamingConnection());
webSocketSamplerPanel.setResetStreamingConnection(webSocketSamplerTestElement.isResetStreamingConnection());
webSocketSamplerPanel.setConnectionId(webSocketSamplerTestElement.getConnectionId());
webSocketSamplerPanel.setResponsePattern(webSocketSamplerTestElement.getResponsePattern());
webSocketSamplerPanel.setCloseConncectionPattern(webSocketSamplerTestElement.getCloseConncectionPattern());
Expand Down Expand Up @@ -98,6 +99,7 @@ public void modifyTestElement(TestElement te) {
webSocketSamplerTestElement.setResponseTimeout(webSocketSamplerPanel.getResponseTimeout());
webSocketSamplerTestElement.setIgnoreSslErrors(webSocketSamplerPanel.isIgnoreSslErrors());
webSocketSamplerTestElement.setStreamingConnection(webSocketSamplerPanel.isStreamingConnection());
webSocketSamplerTestElement.setResetStreamingConnection(webSocketSamplerPanel.isResetStreamingConnection());
webSocketSamplerTestElement.setConnectionId(webSocketSamplerPanel.getConnectionId());
webSocketSamplerTestElement.setResponsePattern(webSocketSamplerPanel.getResponsePattern());
webSocketSamplerTestElement.setCloseConncectionPattern(webSocketSamplerPanel.getCloseConncectionPattern());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,8 @@
<Component id="ignoreSslErrorsCheckBox" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="streamingConnectionCheckBox" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="resetStreamingConnectionCheckBox" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
Expand Down Expand Up @@ -244,6 +246,7 @@
<Group type="103" groupAlignment="3" attributes="0">
<Component id="ignoreSslErrorsCheckBox" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="streamingConnectionCheckBox" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="resetStreamingConnectionCheckBox" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="querystringAttributesPanel" pref="102" max="32767" attributes="0"/>
Expand Down Expand Up @@ -332,6 +335,11 @@
<Property name="text" type="java.lang.String" value="Streaming connection"/>
</Properties>
</Component>
<Component class="javax.swing.JCheckBox" name="resetStreamingConnectionCheckBox">
<Properties>
<Property name="text" type="java.lang.String" value="Reset streaming connection"/>
</Properties>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="jPanel5">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ private void initComponents() {
jLabel15 = new javax.swing.JLabel();
implementationComboBox = new javax.swing.JComboBox();
streamingConnectionCheckBox = new javax.swing.JCheckBox();
resetStreamingConnectionCheckBox = new javax.swing.JCheckBox();
jPanel5 = new javax.swing.JPanel();
jLabel7 = new javax.swing.JLabel();
responsePatternTextField = new javax.swing.JTextField();
Expand Down Expand Up @@ -172,6 +173,8 @@ private void initComponents() {
implementationComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "RFC6455 (v13)" }));

streamingConnectionCheckBox.setText("Streaming connection");

resetStreamingConnectionCheckBox.setText("Reset streaming connection");

javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
jPanel3.setLayout(jPanel3Layout);
Expand Down Expand Up @@ -204,7 +207,9 @@ private void initComponents() {
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(ignoreSslErrorsCheckBox)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(streamingConnectionCheckBox)))
.addComponent(streamingConnectionCheckBox)
.addComponent(resetStreamingConnectionCheckBox)
))
.addGap(0, 0, Short.MAX_VALUE))
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(jLabel5)
Expand Down Expand Up @@ -232,7 +237,8 @@ private void initComponents() {
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(ignoreSslErrorsCheckBox)
.addComponent(streamingConnectionCheckBox))
.addComponent(streamingConnectionCheckBox)
.addComponent(resetStreamingConnectionCheckBox))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(querystringAttributesPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 102, Short.MAX_VALUE)
.addGap(8, 8, 8)
Expand Down Expand Up @@ -425,6 +431,7 @@ private void initComponents() {
private javax.swing.JTextField serverAddressTextField;
private javax.swing.JTextField serverPortTextField;
private javax.swing.JCheckBox streamingConnectionCheckBox;
private javax.swing.JCheckBox resetStreamingConnectionCheckBox;
// End of variables declaration//GEN-END:variables

public void initFields() {
Expand Down Expand Up @@ -549,15 +556,23 @@ public void setRequestPayload(String requestPayload) {
public String getRequestPayload() {
return requestPayloadEditorPane.getText();
}

public void setStreamingConnection(Boolean streamingConnection) {
streamingConnectionCheckBox.setSelected(streamingConnection);
}

public Boolean isStreamingConnection() {
return streamingConnectionCheckBox.isSelected();
}

public void setResetStreamingConnection(Boolean resetStreamingConnection) {
resetStreamingConnectionCheckBox.setSelected(resetStreamingConnection);
}

public Boolean isResetStreamingConnection() {
return resetStreamingConnectionCheckBox.isSelected();
}

public void setIgnoreSslErrors(Boolean ignoreSslErrors) {
ignoreSslErrorsCheckBox.setSelected(ignoreSslErrors);
}
Expand Down