mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-25 05:23:51 +00:00
Helper method added, to clear the state of the SailingService.
This commit is contained in:
1 parent
32f2624ad8
commit
081e3add7f
1 file changed
+28
+28
@@ -3,6 +3,7 @@ package com.sap.sailing.selenium.test;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
@@ -40,6 +41,10 @@ import com.sap.sailing.selenium.core.WindowManager;
|
|||||||
*/
|
*/
|
||||||
@RunWith(Selenium.class)
|
@RunWith(Selenium.class)
|
||||||
public abstract class AbstractSeleniumTest {
|
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 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$
|
private static final String ATTACHMENT_FORMAT = "[[ATTACHMENT|%s]]"; //$NON-NLS-1$
|
||||||
@@ -49,6 +54,29 @@ public abstract class AbstractSeleniumTest {
|
|||||||
//
|
//
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p></p>
|
||||||
|
*
|
||||||
|
* @param contextRoot
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* <code>true</code> if the state was reseted successfully and <code>false</code> 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 {
|
private class ScreenShotRule extends TestWatchman {
|
||||||
@Override
|
@Override
|
||||||
public void failed(Throwable cause, FrameworkMethod method) {
|
public void failed(Throwable cause, FrameworkMethod method) {
|
||||||
|
|||||||
Reference in new issue
Block a user