Search in sources :

Example 1 with Plc4xEmbeddedChannel

use of io.netty.channel.embedded.Plc4xEmbeddedChannel in project plc4x by apache.

the class ConnectionManager method getEmbeddedChannel.

public Plc4xEmbeddedChannel getEmbeddedChannel(PlcConnection plcConnection) {
    if (!(plcConnection instanceof ChannelExposingConnection)) {
        throw new PlcRuntimeException("Expecting ChannelExposingConnection");
    }
    ChannelExposingConnection connection = (ChannelExposingConnection) plcConnection;
    Channel channel = connection.getChannel();
    if (!(channel instanceof Plc4xEmbeddedChannel)) {
        throw new PlcRuntimeException("Expecting EmbeddedChannel");
    }
    return (Plc4xEmbeddedChannel) channel;
}
Also used : PlcRuntimeException(org.apache.plc4x.java.api.exceptions.PlcRuntimeException) ChannelExposingConnection(org.apache.plc4x.java.spi.connection.ChannelExposingConnection) Channel(io.netty.channel.Channel) Plc4xEmbeddedChannel(io.netty.channel.embedded.Plc4xEmbeddedChannel) Plc4xEmbeddedChannel(io.netty.channel.embedded.Plc4xEmbeddedChannel)

Example 2 with Plc4xEmbeddedChannel

use of io.netty.channel.embedded.Plc4xEmbeddedChannel in project plc4x by apache.

the class Testcase method run.

public void run() throws DriverTestsuiteException {
    assert driverTestsuite != null;
    LOGGER.info("Starting testcase: {}", name);
    final PlcConnection plcConnection = connectionManager.getConnection(driverTestsuite.getDriverTestsuiteConfiguration().getDriverName(), driverTestsuite.getDriverTestsuiteConfiguration().getDriverParameters());
    final Plc4xEmbeddedChannel embeddedChannel = connectionManager.getEmbeddedChannel(plcConnection);
    final ByteOrder byteOrder = driverTestsuite.getDriverTestsuiteConfiguration().getByteOrder();
    // Be sure this is reset, just in case a previous testcase failed.
    synchronizer.responseFuture = null;
    if (!driverTestsuite.getSetupSteps().isEmpty()) {
        LOGGER.info("Running setup steps");
        for (TestStep setupStep : driverTestsuite.getSetupSteps()) {
            setupStep.execute(plcConnection, embeddedChannel, byteOrder);
        }
        LOGGER.info("Finished setup steps");
    }
    LOGGER.info("Running test steps");
    for (TestStep step : steps) {
        step.execute(plcConnection, embeddedChannel, byteOrder);
    }
    LOGGER.info("Finished test steps");
    if (!driverTestsuite.getTeardownSteps().isEmpty()) {
        LOGGER.info("Running teardown steps");
        for (TestStep teardownStep : driverTestsuite.getTeardownSteps()) {
            teardownStep.execute(plcConnection, embeddedChannel, byteOrder);
        }
        LOGGER.info("Finished teardown steps");
    }
    try {
        plcConnection.close();
    } catch (Exception e) {
        LOGGER.warn("Error closing connection", e);
    }
    LOGGER.info("Finished testcase: {}", driverTestsuite.getName());
}
Also used : ByteOrder(org.apache.plc4x.java.spi.generation.ByteOrder) PlcConnection(org.apache.plc4x.java.api.PlcConnection) Plc4xEmbeddedChannel(io.netty.channel.embedded.Plc4xEmbeddedChannel) DriverTestsuiteException(org.apache.plc4x.test.driver.exceptions.DriverTestsuiteException)

Aggregations

Plc4xEmbeddedChannel (io.netty.channel.embedded.Plc4xEmbeddedChannel)2 Channel (io.netty.channel.Channel)1 PlcConnection (org.apache.plc4x.java.api.PlcConnection)1 PlcRuntimeException (org.apache.plc4x.java.api.exceptions.PlcRuntimeException)1 ChannelExposingConnection (org.apache.plc4x.java.spi.connection.ChannelExposingConnection)1 ByteOrder (org.apache.plc4x.java.spi.generation.ByteOrder)1 DriverTestsuiteException (org.apache.plc4x.test.driver.exceptions.DriverTestsuiteException)1