Skip to content

Commit 6685d7b

Browse files
committed
add try and catch with finally to handle switching the locale default
1 parent b7b05d2 commit 6685d7b

File tree

7 files changed

+64
-46
lines changed

7 files changed

+64
-46
lines changed

.idea/kotlinc.xml

Lines changed: 0 additions & 7 deletions
This file was deleted.

.idea/misc.xml

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

java/test/org/openqa/selenium/chrome/ChromeDriverFunctionalTest.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -205,14 +205,19 @@ void canExecuteCdpCommands() {
205205
@Test
206206
@NoDriverBeforeTest
207207
void shouldLaunchSuccessfullyWithArabicDate() {
208-
Locale arabicLocale = new Locale("ar", "EG");
209-
Locale.setDefault(arabicLocale);
208+
try {
209+
Locale arabicLocale = new Locale("ar", "EG");
210+
Locale.setDefault(arabicLocale);
210211

211-
int port = PortProber.findFreePort();
212-
ChromeDriverService.Builder builder = new ChromeDriverService.Builder();
213-
builder.usingPort(port);
214-
builder.build();
212+
int port = PortProber.findFreePort();
213+
ChromeDriverService.Builder builder = new ChromeDriverService.Builder();
214+
builder.usingPort(port);
215+
builder.build();
215216

216-
Locale.setDefault(Locale.US);
217+
} catch (Exception e) {
218+
throw e;
219+
} finally {
220+
Locale.setDefault(Locale.US);
221+
}
217222
}
218223
}

java/test/org/openqa/selenium/edge/EdgeDriverFunctionalTest.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -199,14 +199,19 @@ void canExecuteCdpCommands() {
199199
@Test
200200
@NoDriverBeforeTest
201201
void shouldLaunchSuccessfullyWithArabicDate() {
202-
Locale arabicLocale = new Locale("ar", "EG");
203-
Locale.setDefault(arabicLocale);
202+
try {
203+
Locale arabicLocale = new Locale("ar", "EG");
204+
Locale.setDefault(arabicLocale);
204205

205-
int port = PortProber.findFreePort();
206-
EdgeDriverService.Builder builder = new EdgeDriverService.Builder();
207-
builder.usingPort(port);
208-
builder.build();
206+
int port = PortProber.findFreePort();
207+
EdgeDriverService.Builder builder = new EdgeDriverService.Builder();
208+
builder.usingPort(port);
209+
builder.build();
209210

210-
Locale.setDefault(Locale.US);
211+
} catch (Exception e) {
212+
throw e;
213+
} finally {
214+
Locale.setDefault(Locale.US);
215+
}
211216
}
212217
}

java/test/org/openqa/selenium/firefox/FirefoxDriverTest.java

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
package org.openqa.selenium.firefox;
1919

2020
import static org.assertj.core.api.Assertions.assertThat;
21-
import static org.assertj.core.api.AssertionsForClassTypes.assertThatExceptionOfType;
2221
import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy;
2322
import static org.junit.jupiter.api.Assertions.fail;
2423
import static org.junit.jupiter.api.Assumptions.assumeTrue;
@@ -274,15 +273,20 @@ void canSetContext() {
274273
@Test
275274
@NoDriverBeforeTest
276275
void shouldLaunchSuccessfullyWithArabicDate() {
277-
Locale arabicLocale = new Locale("ar", "EG");
278-
Locale.setDefault(arabicLocale);
276+
try {
277+
Locale arabicLocale = new Locale("ar", "EG");
278+
Locale.setDefault(arabicLocale);
279279

280-
int port = PortProber.findFreePort();
281-
GeckoDriverService.Builder builder = new GeckoDriverService.Builder();
282-
builder.usingPort(port);
283-
builder.build();
280+
int port = PortProber.findFreePort();
281+
GeckoDriverService.Builder builder = new GeckoDriverService.Builder();
282+
builder.usingPort(port);
283+
builder.build();
284284

285-
Locale.setDefault(Locale.US);
285+
} catch (Exception e) {
286+
throw e;
287+
} finally {
288+
Locale.setDefault(Locale.US);
289+
}
286290
}
287291

288292
private static class CustomFirefoxProfile extends FirefoxProfile {}

java/test/org/openqa/selenium/ie/InternetExplorerDriverTest.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -148,15 +148,20 @@ void testPersistentHoverCanBeTurnedOff() throws Exception {
148148
@Test
149149
@NoDriverBeforeTest
150150
void shouldLaunchSuccessfullyWithArabicDate() {
151-
Locale arabicLocale = new Locale("ar", "EG");
152-
Locale.setDefault(arabicLocale);
151+
try {
152+
Locale arabicLocale = new Locale("ar", "EG");
153+
Locale.setDefault(arabicLocale);
153154

154-
int port = PortProber.findFreePort();
155-
InternetExplorerDriverService.Builder builder = new InternetExplorerDriverService.Builder();
156-
builder.usingPort(port);
157-
builder.build();
155+
int port = PortProber.findFreePort();
156+
InternetExplorerDriverService.Builder builder = new InternetExplorerDriverService.Builder();
157+
builder.usingPort(port);
158+
builder.build();
158159

159-
Locale.setDefault(Locale.US);
160+
} catch (Exception e) {
161+
throw e;
162+
} finally {
163+
Locale.setDefault(Locale.US);
164+
}
160165
}
161166

162167
private WebDriver newIeDriver() {

java/test/org/openqa/selenium/safari/SafariDriverTest.java

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -138,14 +138,19 @@ public void canAttachDebugger() {
138138
@Test
139139
@NoDriverBeforeTest
140140
void shouldLaunchSuccessfullyWithArabicDate() {
141-
Locale arabicLocale = new Locale("ar", "EG");
142-
Locale.setDefault(arabicLocale);
143-
144-
int port = PortProber.findFreePort();
145-
SafariDriverService.Builder builder = new SafariDriverService.Builder();
146-
builder.usingPort(port);
147-
builder.build();
148-
149-
Locale.setDefault(Locale.US);
141+
try {
142+
Locale arabicLocale = new Locale("ar", "EG");
143+
Locale.setDefault(arabicLocale);
144+
145+
int port = PortProber.findFreePort();
146+
SafariDriverService.Builder builder = new SafariDriverService.Builder();
147+
builder.usingPort(port);
148+
builder.build();
149+
150+
} catch (Exception e) {
151+
throw e;
152+
} finally {
153+
Locale.setDefault(Locale.US);
154+
}
150155
}
151156
}

0 commit comments

Comments
 (0)