Search in sources :

Example 1 with ByteOrder

use of org.apache.plc4x.java.spi.generation.ByteOrder 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)1 PlcConnection (org.apache.plc4x.java.api.PlcConnection)1 ByteOrder (org.apache.plc4x.java.spi.generation.ByteOrder)1 DriverTestsuiteException (org.apache.plc4x.test.driver.exceptions.DriverTestsuiteException)1