diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/test/AbstractSeleniumTest.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/test/AbstractSeleniumTest.java index 707a1640976..aa600224afd 100644 --- a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/test/AbstractSeleniumTest.java +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/test/AbstractSeleniumTest.java @@ -3,6 +3,7 @@ package com.sap.sailing.selenium.test; import java.io.File; import java.io.IOException; +import java.net.HttpURLConnection; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; @@ -40,6 +41,10 @@ import com.sap.sailing.selenium.core.WindowManager; */ @RunWith(Selenium.class) public abstract class AbstractSeleniumTest { + private static final String CLEAR_STATE_URL = "sailingserver/test-support/clearState"; //$NON-NLS-1$ + + private static final int CLEAR_STATE_SUCCESFUL_STATUS_CODE = 204; + private static final String NOT_SUPPORTED_IMAGE = "/com/sap/sailing/selenium/resources/not-supported.png"; //$NON-NLS-1$ private static final String ATTACHMENT_FORMAT = "[[ATTACHMENT|%s]]"; //$NON-NLS-1$ @@ -49,6 +54,29 @@ public abstract class AbstractSeleniumTest { // //} + /** + *
+ * + * @param contextRoot + * + * @return + *true if the state was reseted successfully and false otherwise.
+ */
+ protected static void clearState(String contextRoot) {
+ try {
+ URL url = new URL(contextRoot + CLEAR_STATE_URL);
+ HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+ connection.setRequestMethod("POST");
+ connection.connect();
+
+ if(connection.getResponseCode() != CLEAR_STATE_SUCCESFUL_STATUS_CODE) {
+ throw new RuntimeException(connection.getResponseMessage());
+ }
+ } catch(IOException exception) {
+ throw new RuntimeException(exception);
+ }
+ }
+
private class ScreenShotRule extends TestWatchman {
@Override
public void failed(Throwable cause, FrameworkMethod method) {