Brooklyn

brooklyn.test
[Groovy] Class TestUtils

java.lang.Object
  brooklyn.test.TestUtils

class TestUtils

Helper functions for tests of Tomcat, JBoss and others.


Nested Class Summary
static class TestUtils.BooleanWithMessage

 
Method Summary
static void assertAttributeContinually(Entity entity, AttributeSensor attribute, java.lang.Object expected)

static void assertAttributeEventually(Entity entity, AttributeSensor attribute, java.lang.Object expected)

static void assertContinually(java.util.Map flags = [:], Supplier supplier, Predicate predicate)

static void assertContinually(java.util.Map flags = [:], Supplier supplier, Predicate predicate, java.lang.String errMsg, long durationMs)

static void assertEventually(java.util.Map flags = [:], Supplier supplier, Predicate predicate)

static void assertEventually(java.util.Map flags = [:], Supplier supplier, Predicate predicate, java.lang.String errMsg)

static void assertEventually(java.util.Map flags = [:], java.util.concurrent.Callable c)

static void assertEventually(java.util.Map flags = [:], java.lang.Runnable c)

static void assertFails(java.lang.Runnable c)

static void assertFailsWith(java.lang.Runnable c, groovy.lang.Closure exceptionChecker)

static void assertFailsWith(java.lang.Runnable c, java.lang.Class validException, java.lang.Class... otherValidExceptions)

static void assertFailsWith(java.lang.Runnable c, Predicate exceptionChecker)

static void assertSucceedsContinually(java.util.Map flags = [:], java.lang.Runnable job)

static void assertSucceedsContinually(java.util.Map flags = [:], java.util.concurrent.Callable job)

static void assertUrlHasText(java.util.Map flags = [:], java.lang.String url, java.lang.String... phrases)

@deprecated since 0.4.0 use HttpTestUtils.assertUrlEventuallyHasText or HttpTestUtils.assertUrlHasText (NB: this method has "eventually" logic, with default timeout of 30s, despite the absence of that in the name)

static void assertUrlStatusCodeEventually(java.lang.String url, int expected)

static java.net.URLConnection connectToURL(java.lang.String url)

Connects to the given url and returns the connection.

static void executeUntilSucceeds(java.util.Map flags = [:], groovy.lang.Closure c)

static void executeUntilSucceeds(java.util.Map flags = [:], java.util.concurrent.Callable c)

static void executeUntilSucceeds(java.util.Map flags = [:], java.lang.Runnable r)

static void executeUntilSucceedsElseShutdown(java.util.Map flags = [:], Entity entity, groovy.lang.Closure c)

static void executeUntilSucceedsWithFinallyBlock(java.util.Map flags = [:], groovy.lang.Closure c, groovy.lang.Closure finallyBlock = {})

static void executeUntilSucceedsWithFinallyBlock(java.util.Map flags = [:], java.util.concurrent.Callable c, groovy.lang.Closure finallyBlock = {})

Convenience method for cases where we need to test until something is true.

static void executeUntilSucceedsWithShutdown(java.util.Map flags = [:], Entity entity, groovy.lang.Closure c)

convenience for entities to ensure they shutdown afterwards

static java.io.File getResource(java.lang.String path, java.lang.ClassLoader loader)

static boolean isPortInUse(int port, long retryAfterMillis = 0)

True if two attempts to connect to the port succeed.

static groovy.time.TimeDuration toTimeDuration(java.lang.Object duration)

static java.lang.Throwable unwrapThrowable(java.lang.Throwable t)

static int urlRespondsStatusCode(java.lang.String url)

Connects to the given HTTP URL and asserts that the response had status code 200.

static boolean urlRespondsWithStatusCode200(java.lang.String url)

Connects to the given HTTP URL and asserts that the response had status code 200.

 
Methods inherited from class java.lang.Object
java.lang.Object#wait(), java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()
 

Method Detail

assertAttributeContinually

static void assertAttributeContinually(Entity entity, AttributeSensor attribute, java.lang.Object expected)


assertAttributeEventually

static void assertAttributeEventually(Entity entity, AttributeSensor attribute, java.lang.Object expected)


assertContinually

static void assertContinually(java.util.Map flags = [:], Supplier supplier, Predicate predicate)


assertContinually

static void assertContinually(java.util.Map flags = [:], Supplier supplier, Predicate predicate, java.lang.String errMsg, long durationMs)


assertEventually

static void assertEventually(java.util.Map flags = [:], Supplier supplier, Predicate predicate)


assertEventually

static void assertEventually(java.util.Map flags = [:], Supplier supplier, Predicate predicate, java.lang.String errMsg)


assertEventually

static void assertEventually(java.util.Map flags = [:], java.util.concurrent.Callable c)


assertEventually

static void assertEventually(java.util.Map flags = [:], java.lang.Runnable c)


assertFails

static void assertFails(java.lang.Runnable c)


assertFailsWith

static void assertFailsWith(java.lang.Runnable c, groovy.lang.Closure exceptionChecker)


assertFailsWith

static void assertFailsWith(java.lang.Runnable c, java.lang.Class validException, java.lang.Class... otherValidExceptions)


assertFailsWith

static void assertFailsWith(java.lang.Runnable c, Predicate exceptionChecker)


assertSucceedsContinually

static void assertSucceedsContinually(java.util.Map flags = [:], java.lang.Runnable job)


assertSucceedsContinually

static void assertSucceedsContinually(java.util.Map flags = [:], java.util.concurrent.Callable job)


assertUrlHasText

@Deprecated
static void assertUrlHasText(java.util.Map flags = [:], java.lang.String url, java.lang.String... phrases)
deprecated:
since 0.4.0 use HttpTestUtils.assertUrlEventuallyHasText or HttpTestUtils.assertUrlHasText (NB: this method has "eventually" logic, with default timeout of 30s, despite the absence of that in the name)


assertUrlStatusCodeEventually

static void assertUrlStatusCodeEventually(java.lang.String url, int expected)


connectToURL

@Deprecated
static java.net.URLConnection connectToURL(java.lang.String url)
Connects to the given url and returns the connection.
deprecated:
Use HttpTestUtils.connectToUrl(url)


executeUntilSucceeds

static void executeUntilSucceeds(java.util.Map flags = [:], groovy.lang.Closure c)


executeUntilSucceeds

static void executeUntilSucceeds(java.util.Map flags = [:], java.util.concurrent.Callable c)


executeUntilSucceeds

static void executeUntilSucceeds(java.util.Map flags = [:], java.lang.Runnable r)


executeUntilSucceedsElseShutdown

static void executeUntilSucceedsElseShutdown(java.util.Map flags = [:], Entity entity, groovy.lang.Closure c)


executeUntilSucceedsWithFinallyBlock

static void executeUntilSucceedsWithFinallyBlock(java.util.Map flags = [:], groovy.lang.Closure c, groovy.lang.Closure finallyBlock = {})


executeUntilSucceedsWithFinallyBlock

static void executeUntilSucceedsWithFinallyBlock(java.util.Map flags = [:], java.util.concurrent.Callable c, groovy.lang.Closure finallyBlock = {})
Convenience method for cases where we need to test until something is true. The runnable will be invoked periodically until it succesfully concludes. Additionally, a finally block can be supplied.

The following flags are supported:

Parameters:
flags, - accepts the flags listed above
r
finallyBlock


executeUntilSucceedsWithShutdown

static void executeUntilSucceedsWithShutdown(java.util.Map flags = [:], Entity entity, groovy.lang.Closure c)
convenience for entities to ensure they shutdown afterwards


getResource

static java.io.File getResource(java.lang.String path, java.lang.ClassLoader loader)


isPortInUse

static boolean isPortInUse(int port, long retryAfterMillis = 0)
True if two attempts to connect to the port succeed.


toTimeDuration

static groovy.time.TimeDuration toTimeDuration(java.lang.Object duration)


unwrapThrowable

static java.lang.Throwable unwrapThrowable(java.lang.Throwable t)


urlRespondsStatusCode

@Deprecated
static int urlRespondsStatusCode(java.lang.String url)
Connects to the given HTTP URL and asserts that the response had status code 200.
deprecated:
Use HttpTestUtils.getHttpStatusCode(url)


urlRespondsWithStatusCode200

@Deprecated
static boolean urlRespondsWithStatusCode200(java.lang.String url)
Connects to the given HTTP URL and asserts that the response had status code 200.
deprecated:
Use HttpTestUtils.getHttpStatusCode(url) == 200


 

Brooklyn Multi-Cloud Application Management Platform
brooklyncentral.github.com. Apache License. © 2012.