Class TestUtils

java.lang.Object
org.springframework.amqp.utils.test.TestUtils

public final class TestUtils extends Object
Testing utilities.
Since:
1.2
Author:
Mark Fisher, Iwein Fuld, Oleg Zhurakousky, Gary Russell, Ngoc Nhan, Artem Bilan
  • Method Details

    • getPropertyValue

      public static <T> @Nullable T getPropertyValue(Object root, String propertyPath)
      Uses nested DirectFieldAccessors to obtain a property using dotted notation to traverse fields; e.g. "foo.bar.baz" will obtain a reference to the baz field of the bar field of foo. Adopted from Spring Integration.
      Type Parameters:
      T - the expected type of the value.
      Parameters:
      root - The object.
      propertyPath - The path.
      Returns:
      The field.
    • getPropertyValue

      @Deprecated(since="4.1", forRemoval=true) public static <T> @Nullable T getPropertyValue(Object root, String propertyPath, Class<T> type)
      Deprecated, for removal: This API element is subject to removal in a future version.
      since 4.1, use getPropertyValue(Object, String) instead: there is no need in extra type check in tests.
      Uses nested DirectFieldAccessors to get a property using dotted notation to traverse fields; e.g. prop.subProp.subSubProp will get a reference to the subSubProp field of the subProp field of prop prop from the root.
      Type Parameters:
      T - the expected type of the value.
      Parameters:
      root - the object to get the property from.
      propertyPath - the path to the property. Can be a dotted notation for a nested property.
      type - the value expected type.
      Returns:
      the property value.