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
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<dependency>
<groupId>com.github.blazemeter</groupId>
<artifactId>xtn5250</artifactId>
<version>3.2.4</version>
<version>3.2.5-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.github.blazemeter</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ default TerminalType getDefaultTerminalType() {
void connect(String server, int port, SSLType sslType, TerminalType terminalType,
long timeoutMillis) throws RteIOException, InterruptedException, TimeoutException;

void connect(String server, int port, SSLType sslType, TerminalType terminalType,
long timeoutMillis, String devName) throws RteIOException,
InterruptedException, TimeoutException;

void await(List<WaitCondition> waitConditions)
throws InterruptedException, TimeoutException, RteIOException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,44 @@ public void onConnectionClosed() {
exceptionHandler.throwAnyPendingError();
}

@Override
public void connect(String server, int port, SSLType sslType, TerminalType terminalType,
long timeoutMillis, String devName)
throws RteIOException, InterruptedException, TimeoutException {
stableTimeoutExecutor = Executors.newSingleThreadScheduledExecutor(NAMED_THREAD_FACTORY);
Tn3270TerminalType termType = (Tn3270TerminalType) terminalType;
client = new TerminalClient(termType.getModel(), termType.getScreenDimensions());
client.setUsesExtended3270(termType.isExtended());
client.setConnectionTimeoutMillis((int) timeoutMillis);
client.setSocketFactory(getSocketFactory(sslType, server));
ConnectionEndWaiter connectionEndWaiter = new ConnectionEndWaiter(timeoutMillis);
exceptionHandler = new ExceptionHandler(server);
addConnectionListener(new com.bytezone.dm3270.ConnectionListener() {

@Override
public void onConnection() {
connectionEndWaiter.stop();
}

@Override
public void onException(Exception e) {
exceptionHandler.setPendingError(e);
connectionEndWaiter.stop();
}

@Override
public void onConnectionClosed() {
handleServerDisconnection();
}
});
for (TerminalStateListener listener : listenersProxies.keySet()) {
addListener(listener);
}
client.connect(server, port);
connectionEndWaiter.await();
exceptionHandler.throwAnyPendingError();
}

private void addListener(TerminalStateListener listener) {
Tn3270TerminalStateListenerProxy listenerProxy = listenersProxies.get(listener);
client.addScreenChangeListener(listenerProxy);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,53 @@ public List<TerminalType> getSupportedTerminalTypes() {
return TERMINAL_TYPES;
}

@Override
public void connect(String server, int port, SSLType sslType, TerminalType terminalType,
long timeoutMillis, String devName)
throws RteIOException, InterruptedException, TimeoutException {
stableTimeoutExecutor = Executors.newSingleThreadScheduledExecutor(NAMED_THREAD_FACTORY);
/*
we need create terminalClient instance on connect instead of
constructor to avoid leaving keyboard thread running when
instance of this class is created for getting supported terminal types in JMeter
*/
client = new TerminalClient();
client.setConnectionTimeoutMillis((int) timeoutMillis);
client.setTerminalType(terminalType.getId());
client.setSocketFactory(getSocketFactory(sslType, server));
//if (("".equals(devName))) {
client.setTelnetEnv("\u0003DEVNAME\u0001" + devName);
//}
exceptionHandler = new ExceptionHandler(server);
ConnectionEndWaiter connectionEndWaiter = new ConnectionEndWaiter(timeoutMillis);
client.setExceptionHandler(new net.infordata.em.ExceptionHandler() {

@Override
public void onException(Throwable e) {
exceptionHandler.setPendingError(e);
connectionEndWaiter.stop();
}

@Override
public void onConnectionClosed() {
handleServerDisconnection();
}
});
for (TerminalStateListener listener : listenersProxies.keySet()) {
addListener(listener);
}
ConnectionEndTerminalListener connectionEndListener = new ConnectionEndTerminalListener(
connectionEndWaiter);
client.addEmulatorListener(connectionEndListener);
try {
client.connect(server, port);
connectionEndWaiter.await();
exceptionHandler.throwAnyPendingError();
} finally {
client.removeEmulatorListener(connectionEndListener);
}
}

@Override
public void connect(String server, int port, SSLType sslType, TerminalType terminalType,
long timeoutMillis) throws RteIOException, TimeoutException, InterruptedException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,51 @@ public void onConnection() {
exceptionHandler.throwAnyPendingError();
}

@Override
public void connect(String server, int port, SSLType sslType, TerminalType terminalType,
long timeoutMillis, String devName)
throws RteIOException, InterruptedException, TimeoutException {
client = new TerminalClient(terminalType.getScreenSize(), terminalType.getId());
stableTimeoutExecutor = Executors.newSingleThreadScheduledExecutor(NAMED_THREAD_FACTORY);
exceptionHandler = new ExceptionHandler(server);
client.setSocketFactory(getSocketFactory(sslType, server));
ConnectionEndWaiter connectionEndWaiter = new ConnectionEndWaiter(timeoutMillis);
client.addConnectionListener(new ConnectionListener() {
@Override
public void onException(Throwable throwable) {
exceptionHandler.setPendingError(throwable);
}

@Override
public void onConnectionClosed() {
handleServerDisconnection();
}

@Override
public void onConnection() {
connectionEndWaiter.stop();
}
});
listeners.forEach((stateListener, listenerProxy) -> client
.addScreenChangeListener(listeners.get(stateListener)));

try {
client.connect(server, port, (int) timeoutMillis);
connectionEndWaiter.await();
} catch (ConnectionException e) {
LOG.error("Connection error: ", e);
throw new RteIOException(new Throwable("Connection error"), server);
} catch (InterruptedException e) {
exceptionHandler.setPendingError(e);
LOG.error("Connection to {} interrupted cause: ", server, e);
} catch (TimeoutException e) {
exceptionHandler.setPendingError(e);
LOG.error("Timeout connection exceeded ", e);
}

exceptionHandler.throwAnyPendingError();
}

@Override
public void addTerminalStateListener(TerminalStateListener terminalStateListener) {
Vt420TerminalStateListenerProxy listenerProxy = new Vt420TerminalStateListenerProxy(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,14 @@ public void setServer(String server) {
setProperty(RTESampler.CONFIG_SERVER, server);
}

public String getDevName() {
return getPropertyAsString(RTESampler.CONFIG_DEVNAME);
}

public void setDevName(String devName) {
setProperty(RTESampler.CONFIG_DEVNAME, devName);
}

public int getPort() {
return getPropertyAsInt(RTESampler.CONFIG_PORT, RTESampler.DEFAULT_PORT);
}
Expand Down Expand Up @@ -233,7 +241,8 @@ threads connecting (on start, stop and start)
try {
synchronized (this) {
terminalClient
.connect(getServer(), getPort(), getSSLType(), terminalType, getConnectionTimeout());
.connect(getServer(), getPort(), getSSLType(), terminalType,
getConnectionTimeout(), getDevName());
resultBuilder.withConnectEndNow();
initTerminalEmulatorSupplier();
initTerminalEmulator(terminalType);
Expand Down Expand Up @@ -278,6 +287,7 @@ private ConfigTestElement buildRteConfigElement() {
configTestElement.setProperty(TestElement.GUI_CLASS, RTEConfigGui.class.getName());
configTestElement.setProperty(RTESampler.CONFIG_PORT, String.valueOf(getPort()));
configTestElement.setProperty(RTESampler.CONFIG_SERVER, getServer());
configTestElement.setProperty(RTESampler.CONFIG_DEVNAME, getDevName());
configTestElement.setProperty(RTESampler.CONFIG_PROTOCOL,
getProtocol().name());
configTestElement.setProperty(RTESampler.CONFIG_TERMINAL_TYPE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public void modifyTestElement(TestElement te) {
recorder = (RTERecorder) te;
recorder.setRecordingStateListener(recordingPanel);
recorder.setServer(recordingPanel.getServer());
recorder.setDevName(recordingPanel.getDevName());
recorder.setPort(recordingPanel.getPort());
recorder.setProtocol(recordingPanel.getProtocol());
recorder.setTerminalType(recordingPanel.getTerminalType());
Expand All @@ -108,6 +109,7 @@ public void configure(TestElement element) {
if (element instanceof RTERecorder) {
RTERecorder recorder = (RTERecorder) element;
recordingPanel.setServer(recorder.getServer());
recordingPanel.setDevName(recorder.getDevName());
recordingPanel.setPort(String.valueOf(recorder.getPort()));
recordingPanel.setProtocol(recorder.getProtocol());
recordingPanel.setTerminalType(recorder.getTerminalType());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,18 @@ public String getServer() {
return configPanel.getServer();
}

public String getDevName() {
return configPanel.getDevName();
}

public void setServer(String server) {
configPanel.setServer(server);
}

public void setDevName(String devName) {
configPanel.setDevName(devName);
}

public String getPort() {
return configPanel.getPort();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public class RTESampler extends AbstractSampler implements ThreadListener,

public static final String CONFIG_PORT = "RTEConnectionConfig.port";
public static final String CONFIG_SERVER = "RTEConnectionConfig.server";
public static final String CONFIG_DEVNAME = "RTEConnectionConfig.devName";
public static final String CONFIG_PROTOCOL = "RTEConnectionConfig.protocol";
public static final String CONFIG_SSL_TYPE = "RTEConnectionConfig.sslType";
public static final String CONFIG_CONNECTION_TIMEOUT = "RTEConnectionConfig.connectTimeout";
Expand Down Expand Up @@ -160,6 +161,10 @@ private String getServer() {
return getPropertyAsString(CONFIG_SERVER);
}

private String getDevName() {
return getPropertyAsString(CONFIG_DEVNAME);
}

private int getPort() {
return getIntProperty(CONFIG_PORT, DEFAULT_PORT);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public void configure(TestElement element) {
ConfigTestElement configTestElement = (ConfigTestElement) element;
rteConfigPanelConfigPanel
.setServer(configTestElement.getPropertyAsString(RTESampler.CONFIG_SERVER));
rteConfigPanelConfigPanel
.setDevName(configTestElement.getPropertyAsString(RTESampler.CONFIG_DEVNAME));
rteConfigPanelConfigPanel.setPort(
configTestElement.getPropertyAsString(RTESampler.CONFIG_PORT,
String.valueOf(RTESampler.DEFAULT_PORT)));
Expand Down Expand Up @@ -82,6 +84,8 @@ public void modifyTestElement(TestElement te) {
ConfigTestElement configTestElement = (ConfigTestElement) te;
configTestElement
.setProperty(RTESampler.CONFIG_SERVER, rteConfigPanelConfigPanel.getServer());
configTestElement
.setProperty(RTESampler.CONFIG_DEVNAME, rteConfigPanelConfigPanel.getDevName());
configTestElement.setProperty(RTESampler.CONFIG_PORT, rteConfigPanelConfigPanel.getPort());
configTestElement
.setProperty(RTESampler.CONFIG_PROTOCOL, rteConfigPanelConfigPanel.getProtocol().name());
Expand Down
Loading