mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-14 16:20:57 +00:00
avoid warnings in Selenium bundle; removed hard-coded file system path for Firefox executable for Selenium tests
This commit is contained in:
1 parent
cc96577372
commit
01f2edb2ae
4 files changed
+192
-210
No files matched your search
@@ -38,12 +38,12 @@
|
||||
<name>webdriver.chrome.driver</name>
|
||||
<value>C:\apps\ChromeSeleniumDriver\chromedriver.exe</value>
|
||||
</system-property>
|
||||
|
||||
<!--
|
||||
<system-property>
|
||||
<name>webdriver.firefox.bin</name>
|
||||
<value>D:/Internet/Firefox/firefox.exe</value>
|
||||
</system-property>
|
||||
|
||||
-->
|
||||
<system-property>
|
||||
<name>webdriver.firefox.profile</name>
|
||||
<value>Selenium</value>
|
||||
|
||||
@@ -38,12 +38,12 @@
|
||||
<name>webdriver.chrome.driver</name>
|
||||
<value>C:\apps\ChromeSeleniumDriver\chromedriver.exe</value>
|
||||
</system-property>
|
||||
|
||||
<!--
|
||||
<system-property>
|
||||
<name>webdriver.firefox.bin</name>
|
||||
<value>D:/Internet/Firefox/firefox.exe</value>
|
||||
</system-property>
|
||||
|
||||
-->
|
||||
<system-property>
|
||||
<name>webdriver.firefox.profile</name>
|
||||
<value>Selenium</value>
|
||||
|
||||
+3
-23
@@ -1,42 +1,24 @@
|
||||
package com.sap.sailing.selenium.test.leaderboard;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.openqa.selenium.support.ui.FluentWait;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
||||
import com.sap.sailing.selenium.core.WebDriverWindow;
|
||||
import com.sap.sailing.selenium.core.WindowManager;
|
||||
import com.sap.sailing.selenium.pages.adminconsole.AdminConsolePage;
|
||||
|
||||
import com.sap.sailing.selenium.pages.adminconsole.leaderboard.FlexibleLeaderboardCreateDialog;
|
||||
import com.sap.sailing.selenium.pages.adminconsole.leaderboard.LeaderboardConfigurationPanel;
|
||||
|
||||
import com.sap.sailing.selenium.pages.adminconsole.regatta.RegattaCreateDialog;
|
||||
import com.sap.sailing.selenium.pages.adminconsole.regatta.RegattaDetails;
|
||||
import com.sap.sailing.selenium.pages.adminconsole.regatta.RegattaList;
|
||||
import com.sap.sailing.selenium.pages.adminconsole.regatta.RegattaList.RegattaDescriptor;
|
||||
import com.sap.sailing.selenium.pages.adminconsole.regatta.RegattaStructureManagementPanel;
|
||||
import com.sap.sailing.selenium.pages.adminconsole.regatta.SeriesEditDialog;
|
||||
|
||||
import com.sap.sailing.selenium.pages.adminconsole.tracking.TrackedRacesList;
|
||||
import com.sap.sailing.selenium.pages.adminconsole.tracking.TrackedRacesList.Status;
|
||||
import com.sap.sailing.selenium.pages.adminconsole.tracking.TrackedRacesManagementPanel;
|
||||
import com.sap.sailing.selenium.pages.adminconsole.tracking.TrackedRacesList.TrackedRaceDescriptor;
|
||||
import com.sap.sailing.selenium.pages.adminconsole.tracking.TrackedRacesManagementPanel;
|
||||
import com.sap.sailing.selenium.pages.adminconsole.tractrac.TracTracEventManagementPanel;
|
||||
import com.sap.sailing.selenium.pages.adminconsole.tractrac.TracTracEventManagementPanel.TrackableRaceDescriptor;
|
||||
import com.sap.sailing.selenium.pages.leaderboard.LeaderboardPage;
|
||||
|
||||
import com.sap.sailing.selenium.test.AbstractSeleniumTest;
|
||||
|
||||
/**
|
||||
@@ -51,8 +33,6 @@ public class TestLeaderboardConfiguration extends AbstractSeleniumTest {
|
||||
|
||||
private static final String REGATTA = "TestLeaderboardConfiguration Regatta"; //$NON-NLS-1$
|
||||
|
||||
private static final String LEADERBOARD = "TestLeaderboardConfiguration Leaderboard"; //$NON-NLS-1$
|
||||
|
||||
private static final String EVENT = "BMW Cup"; //$NON-NLS-1$
|
||||
private static final String RACE = "BMW Cup Race %d"; //$NON-NLS-1$
|
||||
private static final String BOAT_CLASS = "J80"; //$NON-NLS-1$
|
||||
@@ -111,7 +91,7 @@ public class TestLeaderboardConfiguration extends AbstractSeleniumTest {
|
||||
// seriesDialog.addRaces(5);
|
||||
// seriesDialog.pressOk();
|
||||
//
|
||||
LeaderboardConfigurationPanel leaderboardConfiguration = adminConsole.goToLeaderboardConfiguration();
|
||||
adminConsole.goToLeaderboardConfiguration();
|
||||
// leaderboardConfiguration.createRegattaLeaderboard(this.regatta);
|
||||
//
|
||||
// WebDriverWindow leaderboardWindow = manager.openNewWindow();
|
||||
@@ -158,7 +138,7 @@ public class TestLeaderboardConfiguration extends AbstractSeleniumTest {
|
||||
});
|
||||
|
||||
// TODO: Link the races and check the leaderboard
|
||||
leaderboardConfiguration = adminConsole.goToLeaderboardConfiguration();
|
||||
adminConsole.goToLeaderboardConfiguration();
|
||||
|
||||
}
|
||||
}
|
||||
+185
-183
@@ -34,205 +34,207 @@ import com.sap.sailing.server.gateway.expeditionimport.WindImportServlet.WindImp
|
||||
|
||||
public class WindImportServlet extends SailingServerHttpServlet {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
static class UploadRequest {
|
||||
public String boatId;
|
||||
public final List<FileItem> files = new ArrayList<FileItem>();
|
||||
public List<RegattaAndRaceIdentifier> races = new ArrayList<RegattaAndRaceIdentifier>();;
|
||||
}
|
||||
|
||||
static class WindImportResult {
|
||||
|
||||
private Date first;
|
||||
private Date last;
|
||||
public String error;
|
||||
|
||||
public final List<RaceEntry> raceEntries = new ArrayList<RaceEntry>();
|
||||
|
||||
public Date getFirst() {
|
||||
return first;
|
||||
}
|
||||
static class UploadRequest {
|
||||
public String boatId;
|
||||
public final List<FileItem> files = new ArrayList<FileItem>();
|
||||
public List<RegattaAndRaceIdentifier> races = new ArrayList<RegattaAndRaceIdentifier>();;
|
||||
}
|
||||
|
||||
public Date getLast() {
|
||||
return last;
|
||||
}
|
||||
|
||||
public void update(Wind newWind) {
|
||||
Date newDate = newWind.getTimePoint().asDate();
|
||||
if (this.first == null || newDate.before(this.first)) {
|
||||
this.first = newDate;
|
||||
}
|
||||
if (this.last == null || newDate.after(this.last)) {
|
||||
this.last = newDate;
|
||||
}
|
||||
}
|
||||
static class WindImportResult {
|
||||
|
||||
RaceEntry addRaceEntry(String regattaName, String raceName) {
|
||||
RaceEntry raceEntry = new RaceEntry(regattaName, raceName);
|
||||
raceEntries.add(raceEntry);
|
||||
return raceEntry;
|
||||
}
|
||||
|
||||
static class RaceEntry {
|
||||
private Date first;
|
||||
private Date last;
|
||||
public String error;
|
||||
|
||||
public final String regattaName;
|
||||
public final String raceName;
|
||||
private int count;
|
||||
private Date first;
|
||||
private Date last;
|
||||
|
||||
private RaceEntry(String regattaName, String raceName) {
|
||||
this.regattaName = regattaName;
|
||||
this.raceName = raceName;
|
||||
}
|
||||
public final List<RaceEntry> raceEntries = new ArrayList<RaceEntry>();
|
||||
|
||||
public void update(Wind newWind) {
|
||||
count++;
|
||||
Date newDate = newWind.getTimePoint().asDate();
|
||||
if (this.first == null || newDate.before(this.first)) {
|
||||
this.first = newDate;
|
||||
}
|
||||
if (this.last == null || newDate.after(this.last)) {
|
||||
this.last = newDate;
|
||||
}
|
||||
}
|
||||
public Date getFirst() {
|
||||
return first;
|
||||
}
|
||||
|
||||
public int getCount() {
|
||||
return count;
|
||||
}
|
||||
public Date getLast() {
|
||||
return last;
|
||||
}
|
||||
|
||||
public Date getFirst() {
|
||||
return first;
|
||||
}
|
||||
public void update(Wind newWind) {
|
||||
Date newDate = newWind.getTimePoint().asDate();
|
||||
if (this.first == null || newDate.before(this.first)) {
|
||||
this.first = newDate;
|
||||
}
|
||||
if (this.last == null || newDate.after(this.last)) {
|
||||
this.last = newDate;
|
||||
}
|
||||
}
|
||||
|
||||
public Date getLast() {
|
||||
return last;
|
||||
}
|
||||
RaceEntry addRaceEntry(String regattaName, String raceName) {
|
||||
RaceEntry raceEntry = new RaceEntry(regattaName, raceName);
|
||||
raceEntries.add(raceEntry);
|
||||
return raceEntry;
|
||||
}
|
||||
|
||||
private JSONObject json() {
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("regattaName", regattaName);
|
||||
result.put("raceName", raceName);
|
||||
result.put("count", getCount());
|
||||
if (getFirst() != null) {
|
||||
result.put("first", getFirst().getTime());
|
||||
}
|
||||
if (getLast() != null) {
|
||||
result.put("last", getLast().getTime());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
static class RaceEntry {
|
||||
|
||||
public JSONObject json() {
|
||||
JSONObject result = new JSONObject();
|
||||
public final String regattaName;
|
||||
public final String raceName;
|
||||
private int count;
|
||||
private Date first;
|
||||
private Date last;
|
||||
|
||||
if (getFirst() != null) {
|
||||
result.put("first", getFirst().getTime());
|
||||
}
|
||||
if (getLast() != null) {
|
||||
result.put("last", getLast().getTime());
|
||||
}
|
||||
result.put("error", error);
|
||||
|
||||
JSONArray raceEntriesJson = new JSONArray();
|
||||
for (RaceEntry raceEntry : raceEntries) {
|
||||
if (raceEntry.count > 0) {
|
||||
raceEntriesJson.add(raceEntry.json());
|
||||
}
|
||||
}
|
||||
result.put("raceEntries", raceEntriesJson);
|
||||
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
private RaceEntry(String regattaName, String raceName) {
|
||||
this.regattaName = regattaName;
|
||||
this.raceName = raceName;
|
||||
}
|
||||
|
||||
}
|
||||
public void update(Wind newWind) {
|
||||
count++;
|
||||
Date newDate = newWind.getTimePoint().asDate();
|
||||
if (this.first == null || newDate.before(this.first)) {
|
||||
this.first = newDate;
|
||||
}
|
||||
if (this.last == null || newDate.after(this.last)) {
|
||||
this.last = newDate;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
if (!ServletFileUpload.isMultipartContent(request)) {
|
||||
response.sendError(HttpServletResponse.SC_BAD_REQUEST);
|
||||
return;
|
||||
}
|
||||
public int getCount() {
|
||||
return count;
|
||||
}
|
||||
|
||||
WindImportResult windImportResult = new WindImportResult();
|
||||
|
||||
try {
|
||||
public Date getFirst() {
|
||||
return first;
|
||||
}
|
||||
|
||||
UploadRequest uploadRequest = readRequest(request);
|
||||
WindSource windSource;
|
||||
if (uploadRequest.boatId == null) {
|
||||
windSource = new WindSourceImpl(WindSourceType.EXPEDITION);
|
||||
} else {
|
||||
windSource = new WindSourceWithAdditionalID(WindSourceType.EXPEDITION, uploadRequest.boatId);
|
||||
}
|
||||
|
||||
List<DynamicTrackedRace> trackedRaces = new ArrayList<DynamicTrackedRace>();
|
||||
if (uploadRequest.races.size() > 0) {
|
||||
for (RegattaAndRaceIdentifier raceEntry : uploadRequest.races) {
|
||||
DynamicTrackedRace trackedRace = getService().getTrackedRace(raceEntry);
|
||||
if (trackedRace != null) {
|
||||
trackedRaces.add(trackedRace);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (Regatta regatta : getService().getAllRegattas()) {
|
||||
for (RaceDefinition raceDefinition : regatta.getAllRaces()) {
|
||||
trackedRaces.add(getService().getTrackedRegatta(regatta).getTrackedRace(raceDefinition));
|
||||
}
|
||||
}
|
||||
}
|
||||
public Date getLast() {
|
||||
return last;
|
||||
}
|
||||
|
||||
for (FileItem file : uploadRequest.files) {
|
||||
List<Wind> windFixes = WindLogParser.importWind(file.getInputStream());
|
||||
if (windFixes.size() > 0) {
|
||||
windImportResult.update(windFixes.get(0));
|
||||
windImportResult.update(windFixes.get(windFixes.size() - 1));
|
||||
for (DynamicTrackedRace trackedRace : trackedRaces) {
|
||||
RegattaAndRaceIdentifier raceIdentifier = trackedRace.getRaceIdentifier();
|
||||
RaceEntry raceEntry = windImportResult.addRaceEntry(raceIdentifier.getRegattaName(), raceIdentifier.getRaceName());
|
||||
for (Wind wind : windFixes) {
|
||||
if (trackedRace.recordWind(wind, windSource)) {
|
||||
raceEntry.update(wind);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private JSONObject json() {
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("regattaName", regattaName);
|
||||
result.put("raceName", raceName);
|
||||
result.put("count", getCount());
|
||||
if (getFirst() != null) {
|
||||
result.put("first", getFirst().getTime());
|
||||
}
|
||||
if (getLast() != null) {
|
||||
result.put("last", getLast().getTime());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
// Use text/html to prevent browsers from wrapping the response body,
|
||||
// see "Handling File Upload Responses in GWT" at http://www.artofsolving.com/node/50
|
||||
} catch (Exception e) {
|
||||
windImportResult.error = e.toString();
|
||||
}
|
||||
response.setContentType("text/html;charset=UTF-8");
|
||||
response.getWriter().append(windImportResult.json().toJSONString());
|
||||
}
|
||||
public JSONObject json() {
|
||||
JSONObject result = new JSONObject();
|
||||
|
||||
private UploadRequest readRequest(HttpServletRequest req) throws FileUploadException, ParseException {
|
||||
UploadRequest result = new UploadRequest();
|
||||
// http://commons.apache.org/fileupload/using.html
|
||||
FileItemFactory factory = new DiskFileItemFactory();
|
||||
ServletFileUpload upload = new ServletFileUpload(factory);
|
||||
@SuppressWarnings("unchecked")
|
||||
List<FileItem> items = upload.parseRequest(req);
|
||||
for (FileItem item : items) {
|
||||
if (item.isFormField() && (item.getString() != null) && (item.getString().trim().length() > 0)) {
|
||||
if ("boatId".equals(item.getFieldName())) {
|
||||
result.boatId = item.getString().trim();
|
||||
} else if ("races".equals(item.getFieldName())) {
|
||||
JSONArray races = (JSONArray) new JSONParser().parse(item.getString().trim());
|
||||
for (Object raceEntry : races) {
|
||||
result.races.add(new RegattaNameAndRaceName((String) ((JSONObject) raceEntry).get("regatta"), (String) ((JSONObject ) raceEntry).get("race")));
|
||||
}
|
||||
}
|
||||
} else if (item.getSize() > 0) {
|
||||
result.files.add(item);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
if (getFirst() != null) {
|
||||
result.put("first", getFirst().getTime());
|
||||
}
|
||||
if (getLast() != null) {
|
||||
result.put("last", getLast().getTime());
|
||||
}
|
||||
result.put("error", error);
|
||||
|
||||
JSONArray raceEntriesJson = new JSONArray();
|
||||
for (RaceEntry raceEntry : raceEntries) {
|
||||
if (raceEntry.count > 0) {
|
||||
raceEntriesJson.add(raceEntry.json());
|
||||
}
|
||||
}
|
||||
result.put("raceEntries", raceEntriesJson);
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException,
|
||||
IOException {
|
||||
if (!ServletFileUpload.isMultipartContent(request)) {
|
||||
response.sendError(HttpServletResponse.SC_BAD_REQUEST);
|
||||
return;
|
||||
}
|
||||
|
||||
WindImportResult windImportResult = new WindImportResult();
|
||||
|
||||
try {
|
||||
|
||||
UploadRequest uploadRequest = readRequest(request);
|
||||
WindSource windSource;
|
||||
if (uploadRequest.boatId == null) {
|
||||
windSource = new WindSourceImpl(WindSourceType.EXPEDITION);
|
||||
} else {
|
||||
windSource = new WindSourceWithAdditionalID(WindSourceType.EXPEDITION, uploadRequest.boatId);
|
||||
}
|
||||
|
||||
List<DynamicTrackedRace> trackedRaces = new ArrayList<DynamicTrackedRace>();
|
||||
if (uploadRequest.races.size() > 0) {
|
||||
for (RegattaAndRaceIdentifier raceEntry : uploadRequest.races) {
|
||||
DynamicTrackedRace trackedRace = getService().getTrackedRace(raceEntry);
|
||||
if (trackedRace != null) {
|
||||
trackedRaces.add(trackedRace);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (Regatta regatta : getService().getAllRegattas()) {
|
||||
for (RaceDefinition raceDefinition : regatta.getAllRaces()) {
|
||||
trackedRaces.add(getService().getTrackedRegatta(regatta).getTrackedRace(raceDefinition));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (FileItem file : uploadRequest.files) {
|
||||
List<Wind> windFixes = WindLogParser.importWind(file.getInputStream());
|
||||
if (windFixes.size() > 0) {
|
||||
windImportResult.update(windFixes.get(0));
|
||||
windImportResult.update(windFixes.get(windFixes.size() - 1));
|
||||
for (DynamicTrackedRace trackedRace : trackedRaces) {
|
||||
RegattaAndRaceIdentifier raceIdentifier = trackedRace.getRaceIdentifier();
|
||||
RaceEntry raceEntry = windImportResult.addRaceEntry(raceIdentifier.getRegattaName(),
|
||||
raceIdentifier.getRaceName());
|
||||
for (Wind wind : windFixes) {
|
||||
if (trackedRace.recordWind(wind, windSource)) {
|
||||
raceEntry.update(wind);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Use text/html to prevent browsers from wrapping the response body,
|
||||
// see "Handling File Upload Responses in GWT" at http://www.artofsolving.com/node/50
|
||||
} catch (Exception e) {
|
||||
windImportResult.error = e.toString();
|
||||
}
|
||||
response.setContentType("text/html;charset=UTF-8");
|
||||
response.getWriter().append(windImportResult.json().toJSONString());
|
||||
}
|
||||
|
||||
private UploadRequest readRequest(HttpServletRequest req) throws FileUploadException, ParseException {
|
||||
UploadRequest result = new UploadRequest();
|
||||
// http://commons.apache.org/fileupload/using.html
|
||||
FileItemFactory factory = new DiskFileItemFactory();
|
||||
ServletFileUpload upload = new ServletFileUpload(factory);
|
||||
@SuppressWarnings("unchecked")
|
||||
List<FileItem> items = upload.parseRequest(req);
|
||||
for (FileItem item : items) {
|
||||
if (item.isFormField() && (item.getString() != null) && (item.getString().trim().length() > 0)) {
|
||||
if ("boatId".equals(item.getFieldName())) {
|
||||
result.boatId = item.getString().trim();
|
||||
} else if ("races".equals(item.getFieldName())) {
|
||||
JSONArray races = (JSONArray) new JSONParser().parse(item.getString().trim());
|
||||
for (Object raceEntry : races) {
|
||||
result.races.add(new RegattaNameAndRaceName((String) ((JSONObject) raceEntry).get("regatta"),
|
||||
(String) ((JSONObject) raceEntry).get("race")));
|
||||
}
|
||||
}
|
||||
} else if (item.getSize() > 0) {
|
||||
result.files.add(item);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user