use of org.apache.sling.testing.tools.retry.RetryLoop.Condition in project sling by apache.
the class EventsCounterUtil method waitForEvent.
public static void waitForEvent(final HttpTestBase b, final String topic, int timeoutSeconds, final int previousCount) {
final Condition c = new Condition() {
public String getDescription() {
return "Wait for OSGi event on topic " + topic;
}
public boolean isTrue() throws Exception {
return getEventsCount(b, topic) > previousCount;
}
};
new RetryLoop(c, timeoutSeconds, 500);
}
use of org.apache.sling.testing.tools.retry.RetryLoop.Condition in project sling by apache.
the class HtmlDefaultServletTest method tearDown.
@Override
protected void tearDown() throws Exception {
// disable the HtmlDefaultServlet after testing
Map<String, String> properties = new HashMap<String, String>();
properties.put("apply", "true");
properties.put("delete", "true");
assertEquals(200, testClient.post(CONFIG_SERVLET, properties));
// Verify that our test servlet is gone
final String url = testNodeNORT.nodeUrl + ".html";
final Condition c = new Condition() {
public String getDescription() {
return url + " is not served by a test servlet";
}
public boolean isTrue() throws Exception {
assertNotTestServlet(getContent(url, CONTENT_TYPE_HTML));
return true;
}
};
new RetryLoop(c, 10, 100);
// forces an async reregistration of the resource resolver factory
try {
Thread.sleep(3000);
} catch (final InterruptedException ie) {
// ignore
}
super.tearDown();
}
use of org.apache.sling.testing.tools.retry.RetryLoop.Condition in project sling by apache.
the class HtmlDefaultServletTest method testHtmlExtension.
public void testHtmlExtension() throws IOException {
final String url = testNodeNORT.nodeUrl + ".html";
final Condition c = new Condition() {
public String getDescription() {
return url + " returns plain text";
}
public boolean isTrue() throws Exception {
assertServlet(getContent(url, CONTENT_TYPE_PLAIN), HTML_DEFAULT_SERVLET_SUFFIX);
return true;
}
};
new RetryLoop(c, 10, 100);
}
use of org.apache.sling.testing.tools.retry.RetryLoop.Condition in project sling by apache.
the class HtmlDefaultServletTest method testJsonExtension.
public void testJsonExtension() throws IOException {
final String url = testNodeNORT.nodeUrl + ".json";
final Condition c = new Condition() {
public String getDescription() {
return url + " returns JSON";
}
public boolean isTrue() throws Exception {
assertNotTestServlet(getContent(url, CONTENT_TYPE_DONTCARE));
return true;
}
};
new RetryLoop(c, 10, 100);
}
use of org.apache.sling.testing.tools.retry.RetryLoop.Condition in project sling by apache.
the class JspScriptingTest method testChangingJsp.
/* Verify that overwriting a JSP script changes the output within a reasonable time
* (might not be immediate as there's some observation and caching involved) */
@Test
public void testChangingJsp() throws Exception {
String toDelete = null;
try {
final String[] scripts = { "jsp1.jsp", "jsp2.jsp" };
for (String script : scripts) {
toDelete = H.uploadTestScript(unstructuredNode.scriptPath, script, "html.jsp");
final String expected = "text from " + script + ":" + unstructuredNode.testText;
final Condition c = new Condition() {
public String getDescription() {
return "Expecting " + expected;
}
public boolean isTrue() throws Exception {
final String content = H.getContent(unstructuredNode.nodeUrl + ".html", HttpTest.CONTENT_TYPE_HTML);
return content.contains(expected);
}
};
new RetryLoop(c, CHECK_CONTENT_TIMEOUT_SECONDS, CHECK_CONTENT_INTERVAL_MSEC);
}
} finally {
if (toDelete != null) {
H.getTestClient().delete(toDelete);
}
}
}