public final class TestSupport extends Object
| Modifier and Type | Method and Description |
|---|---|
static <T> Collection<T> |
assertCollectionSize(Collection<T> list,
int expectedSize)
Asserts that a given collection has a given size.
|
static <T> Collection<T> |
assertCollectionSize(String brokenAssertionMessagePrefix,
Collection<T> list,
int expectedSize)
Asserts that a given collection has a given size.
|
static void |
assertDirectoryEquals(String expected,
String actual)
Asserts that two given directories are equal.
|
static void |
assertDirectoryEquals(String message,
String expected,
String actual)
Asserts that two given directories are equal.
|
static void |
assertDirectoryExists(String filename)
Asserts that a given directory is found in the file system.
|
static void |
assertEndpointUri(org.apache.camel.Endpoint endpoint,
String expectedUri)
Asserts that a given endpoint has an expected uri.
|
static Object |
assertExpression(org.apache.camel.Expression expression,
org.apache.camel.Exchange exchange,
Object expectedAnswer)
Asserts that the given expression when evaluated returns the given answer.
|
static void |
assertFileExists(String filename)
Asserts that a given file is found in the file system.
|
static void |
assertFileNotExists(String filename)
Asserts that a given file is not found in the file system.
|
static void |
assertInMessageBodyEquals(org.apache.camel.Exchange exchange,
Object expectedBody)
Asserts that the given exchange has a given expectedBody on the IN message.
|
static Object |
assertInMessageHeader(org.apache.camel.Exchange exchange,
String headerName,
Object expectedValue)
Asserts that the In message on the exchange contains an header with a given name and expected value.
|
static <T> T |
assertIsInstanceOf(Class<T> expectedType,
Object value)
Asserts that a given value is of an expected type.
|
static <T> List<T> |
assertListSize(List<T> list,
int expectedSize)
Asserts that a given list has a given expected size.
|
static <T> List<T> |
assertListSize(String brokenAssertionMessagePrefix,
List<T> list,
int expectedSize)
Asserts that a list is of the given size.
|
static void |
assertMessageBodyEquals(org.apache.camel.Exchange exchange,
Object expectedBody)
Asserts that the given exchange has a given expectedBody on the message.
|
static Object |
assertMessageHeader(org.apache.camel.Message message,
String headerName,
Object expectedValue)
Asserts that a given message contains an header with a given name and expected value.
|
static <T> T |
assertOneElement(List<T> list)
Asserts that a given list has a single element.
|
static Object |
assertOutMessageHeader(org.apache.camel.Exchange exchange,
String headerName,
Object expectedValue)
Asserts that the message on the exchange contains an header with a given name and expected value.
|
static boolean |
assertPredicate(org.apache.camel.Predicate predicate,
org.apache.camel.Exchange exchange,
boolean expectedValue)
Asserts that the predicate returns the expected value on the exchange.
|
static void |
assertPredicateDoesNotMatch(org.apache.camel.Predicate predicate,
org.apache.camel.Exchange exchange)
Asserts that a given predicate returns
false on a given exchange. |
static void |
assertPredicateMatches(org.apache.camel.Predicate predicate,
org.apache.camel.Exchange exchange)
Asserts that a given predicate returns
true on a given exchange. |
static void |
assertStringContains(String text,
String containedText)
Asserts that the text contains the given string.
|
static org.apache.camel.builder.ValueBuilder |
body()
Returns a predicate and value builder for the inbound body on an exchange.
|
static <T> org.apache.camel.builder.ValueBuilder |
bodyAs(Class<T> type)
Returns a predicate and value builder for the inbound message body as a specific type.
|
static void |
createDirectory(String file)
Creates a given directory.
|
static org.apache.camel.Exchange |
createExchangeWithBody(org.apache.camel.CamelContext camelContext,
Object body)
Creates an exchange with the given body.
|
static boolean |
deleteDirectory(File file)
Recursively delete a directory, useful to zapping test data.
|
static boolean |
deleteDirectory(String file)
Recursively delete a directory, useful to zapping test data.
|
static org.apache.camel.builder.ValueBuilder |
exchangeProperty(String name)
Returns a value builder for the given exchange property.
|
static int |
getJavaMajorVersion()
Returns the current major Java version e.g 8.
|
static List<org.apache.camel.Route> |
getRouteList(org.apache.camel.builder.RouteBuilder builder)
A helper method to create a list of Route objects for a given route builder.
|
static org.apache.camel.builder.ValueBuilder |
header(String name)
Returns a value builder for the given header.
|
static boolean |
isJava18_261_later()
Tells whether the current Java version is 1.8 and build_no 261 and later.
|
static boolean |
isJava18()
Tells whether the current Java version is 1.8.
|
static boolean |
isJava19()
Tells whether the current Java version is 1.9.
|
static boolean |
isJavaVendor(String expectedVendor)
Tells whether the current Java Virtual Machine has been issued by a given expected vendor.
|
static boolean |
isPlatform(String expectedPlatform)
Tells whether the current Operating System is the given expected platform.
|
static void |
recursivelyDeleteDirectory(File file)
Recursively delete a directory.
|
static org.apache.camel.Endpoint |
resolveMandatoryEndpoint(org.apache.camel.CamelContext context,
String endpointUri)
Resolves an endpoint and asserts that it is found.
|
static <T extends org.apache.camel.Endpoint> |
resolveMandatoryEndpoint(org.apache.camel.CamelContext context,
String endpointUri,
Class<T> endpointType)
Resolves an endpoint and asserts that it is found.
|
static org.apache.camel.builder.ValueBuilder |
systemProperty(String name)
Returns a value builder for the given system property.
|
static org.apache.camel.builder.ValueBuilder |
systemProperty(String name,
String defaultValue)
Returns a value builder for the given system property.
|
public static org.apache.camel.builder.ValueBuilder header(String name)
public static org.apache.camel.builder.ValueBuilder exchangeProperty(String name)
public static org.apache.camel.builder.ValueBuilder body()
public static <T> org.apache.camel.builder.ValueBuilder bodyAs(Class<T> type)
public static org.apache.camel.builder.ValueBuilder systemProperty(String name)
public static org.apache.camel.builder.ValueBuilder systemProperty(String name, String defaultValue)
public static <T> T assertIsInstanceOf(Class<T> expectedType, Object value)
public static void assertEndpointUri(org.apache.camel.Endpoint endpoint,
String expectedUri)
public static Object assertInMessageHeader(org.apache.camel.Exchange exchange, String headerName, Object expectedValue)
public static Object assertOutMessageHeader(org.apache.camel.Exchange exchange, String headerName, Object expectedValue)
public static void assertInMessageBodyEquals(org.apache.camel.Exchange exchange,
Object expectedBody)
throws org.apache.camel.InvalidPayloadException
org.apache.camel.InvalidPayloadExceptionpublic static void assertMessageBodyEquals(org.apache.camel.Exchange exchange,
Object expectedBody)
throws org.apache.camel.InvalidPayloadException
org.apache.camel.InvalidPayloadExceptionpublic static Object assertMessageHeader(org.apache.camel.Message message, String headerName, Object expectedValue)
public static Object assertExpression(org.apache.camel.Expression expression, org.apache.camel.Exchange exchange, Object expectedAnswer)
public static void assertPredicateMatches(org.apache.camel.Predicate predicate,
org.apache.camel.Exchange exchange)
true on a given exchange.public static void assertPredicateDoesNotMatch(org.apache.camel.Predicate predicate,
org.apache.camel.Exchange exchange)
false on a given exchange.public static boolean assertPredicate(org.apache.camel.Predicate predicate,
org.apache.camel.Exchange exchange,
boolean expectedValue)
public static <T> T assertOneElement(List<T> list)
public static <T> List<T> assertListSize(List<T> list, int expectedSize)
public static <T> List<T> assertListSize(String brokenAssertionMessagePrefix, List<T> list, int expectedSize)
public static <T> Collection<T> assertCollectionSize(Collection<T> list, int expectedSize)
public static <T> Collection<T> assertCollectionSize(String brokenAssertionMessagePrefix, Collection<T> list, int expectedSize)
public static void assertStringContains(String text, String containedText)
text - the text to comparecontainedText - the text which must be contained inside the other text parameterpublic static void assertDirectoryEquals(String expected, String actual)
public static void assertDirectoryEquals(String message, String expected, String actual)
public static void assertDirectoryExists(String filename)
public static void assertFileExists(String filename)
public static void assertFileNotExists(String filename)
public static org.apache.camel.Endpoint resolveMandatoryEndpoint(org.apache.camel.CamelContext context,
String endpointUri)
public static <T extends org.apache.camel.Endpoint> T resolveMandatoryEndpoint(org.apache.camel.CamelContext context,
String endpointUri,
Class<T> endpointType)
public static org.apache.camel.Exchange createExchangeWithBody(org.apache.camel.CamelContext camelContext,
Object body)
public static List<org.apache.camel.Route> getRouteList(org.apache.camel.builder.RouteBuilder builder) throws Exception
Exceptionpublic static boolean deleteDirectory(String file)
file - the directory to be deletedpublic static boolean deleteDirectory(File file)
file - the directory to be deletedpublic static void recursivelyDeleteDirectory(File file)
file - the directory to be deletedpublic static void createDirectory(String file)
file - the directory to be createdpublic static boolean isPlatform(String expectedPlatform)
expectedPlatform - such as Windowspublic static boolean isJavaVendor(String expectedVendor)
expectedVendor - such as IBMpublic static boolean isJava18()
public static boolean isJava18_261_later()
public static boolean isJava19()
public static int getJavaMajorVersion()
Apache Camel