Class TestUtils

java.lang.Object
io.openems.edge.common.test.TestUtils

public class TestUtils extends Object
  • Method Details

    • findRandomOpenPortOnAllLocalInterfaces

      public static int findRandomOpenPortOnAllLocalInterfaces() throws IOException
      Finds and returns an open port.

      Source https://stackoverflow.com/a/26644672

      Returns:
      an open port
      Throws:
      IOException - on error
    • activateNextProcessImage

      public static void activateNextProcessImage(OpenemsComponent component)
      Calls Channel.nextProcessImage() for every Channel of the OpenemsComponent.
      Parameters:
      component - the OpenemsComponent
    • withValue

      public static void withValue(OpenemsComponent component, ChannelId channelId, Object value)
      Sets the value on a Component Channel and activates the Process Image.

      This is useful to simulate a Channel value in a Unit test, as the value becomes directly available on the Channel.

      Parameters:
      component - the OpenemsComponent
      channelId - the ChannelId
      value - the new value
    • withValue

      public static void withValue(Channel<?> channel, Object value)
      Sets the value on a Channel and activates the Process Image.

      This is useful to simulate a Channel value in a Unit test, as the value becomes directly available on the Channel.

      Parameters:
      channel - the Channel
      value - the new value