Skip to content

Commit 9d1e8c1

Browse files
committed
Move to own packages
1 parent 91acc97 commit 9d1e8c1

File tree

6 files changed

+49
-46
lines changed

6 files changed

+49
-46
lines changed

documentation/src/test/java/example/DefaultLocaleTimezoneExtensionDemo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ void test_with_language_and_country() {
5050
@DefaultLocale(language = "ja", country = "JP", variant = "japanese")
5151
void test_with_language_and_country_and_vairant() {
5252
assertThat(Locale.getDefault()).isEqualTo(
53-
new Locale.Builder().setLanguage("ja").setRegion("JP").setVariant("japanese").build());
53+
new Locale.Builder().setLanguage("ja").setRegion("JP").setVariant("japanese").build());
5454
}
5555
// end::default_locale_language_alternatives[]
5656

junit-jupiter-api/src/main/java/org/junit/jupiter/api/locale/DefaultLocaleExtension.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,17 +69,18 @@ else if (!annotation.language().isEmpty()) {
6969
}
7070

7171
private static Locale createFromLanguageTag(DefaultLocale annotation) {
72-
if (!annotation.language().isEmpty() || !annotation.country().isEmpty() || !annotation.variant().isEmpty() || annotation.localeProvider() != NullLocaleProvider.class) {
72+
if (!annotation.language().isEmpty() || !annotation.country().isEmpty() || !annotation.variant().isEmpty()
73+
|| annotation.localeProvider() != NullLocaleProvider.class) {
7374
throw new ExtensionConfigurationException(
74-
"@DefaultLocale can only be used with language tag if language, country, variant and provider are not set");
75+
"@DefaultLocale can only be used with language tag if language, country, variant and provider are not set");
7576
}
7677
return Locale.forLanguageTag(annotation.value());
7778
}
7879

7980
private static Locale createFromParts(DefaultLocale annotation) {
8081
if (annotation.localeProvider() != NullLocaleProvider.class)
8182
throw new ExtensionConfigurationException(
82-
"@DefaultLocale can only be used with language tag if provider is not set");
83+
"@DefaultLocale can only be used with language tag if provider is not set");
8384
String language = annotation.language();
8485
String country = annotation.country();
8586
String variant = annotation.variant();
@@ -94,22 +95,23 @@ else if (!language.isEmpty() && variant.isEmpty()) {
9495
}
9596
else {
9697
throw new ExtensionConfigurationException(
97-
"@DefaultLocale not configured correctly. When not using a language tag, specify either" + " language, or language and country, or language and country and variant.");
98+
"@DefaultLocale not configured correctly. When not using a language tag, specify either"
99+
+ " language, or language and country, or language and country and variant.");
98100
}
99101
}
100102

101103
private static Locale getFromProvider(DefaultLocale annotation) {
102104
if (!annotation.country().isEmpty() || !annotation.variant().isEmpty())
103105
throw new ExtensionConfigurationException(
104-
"@DefaultLocale can only be used with a provider if value, language, country and variant are not set.");
106+
"@DefaultLocale can only be used with a provider if value, language, country and variant are not set.");
105107
var providerClass = annotation.localeProvider();
106108
LocaleProvider provider;
107109
try {
108110
provider = ReflectionSupport.newInstance(providerClass);
109111
}
110112
catch (Exception exception) {
111113
throw new ExtensionConfigurationException(
112-
"LocaleProvider instance could not be constructed because of an exception", exception);
114+
"LocaleProvider instance could not be constructed because of an exception", exception);
113115
}
114116
return invoke(provider);
115117
}

junit-jupiter-api/src/main/java/org/junit/jupiter/api/timezone/DefaultTimeZoneExtension.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ private static void validateCorrectConfiguration(DefaultTimeZone annotation) {
6969
boolean noProvider = annotation.timeZoneProvider() == NullTimeZoneProvider.class;
7070
if (noValue == noProvider) {
7171
throw new ExtensionConfigurationException(
72-
"Either a valid time zone id or a TimeZoneProvider must be provided to " + DefaultTimeZone.class.getSimpleName());
72+
"Either a valid time zone id or a TimeZoneProvider must be provided to "
73+
+ DefaultTimeZone.class.getSimpleName());
7374
}
7475
}
7576

@@ -93,7 +94,7 @@ private static TimeZone createTimeZoneFromProvider(Class<? extends TimeZoneProvi
9394
}
9495
catch (Exception exception) {
9596
throw new ExtensionConfigurationException("Could not instantiate TimeZoneProvider because of exception",
96-
exception);
97+
exception);
9798
}
9899
}
99100

junit-jupiter-api/src/main/java/org/junit/jupiter/api/timezone/package-info.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
@NullMarked
66
package org.junit.jupiter.api.timezone;
77

8-
import org.jspecify.annotations.NullMarked;
8+
import org.jspecify.annotations.NullMarked;

jupiter-tests/src/test/java/org/junit/jupiter/api/locale/DefaultLocaleTests.java

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -224,60 +224,60 @@ class MethodLevel {
224224
@DisplayName("should fail when nothing is configured")
225225
void shouldFailWhenNothingIsConfigured() {
226226
ExecutionResults results = executeTestMethod(MethodLevelInitializationFailureTestCases.class,
227-
"shouldFailMissingConfiguration");
227+
"shouldFailMissingConfiguration");
228228

229229
results.testEvents().assertThatEvents().haveAtMost(1,
230-
finishedWithFailure(instanceOf(ExtensionConfigurationException.class)));
230+
finishedWithFailure(instanceOf(ExtensionConfigurationException.class)));
231231
}
232232

233233
@Test
234234
@DisplayName("should fail when variant is set but country is not")
235235
void shouldFailWhenVariantIsSetButCountryIsNot() {
236236
ExecutionResults results = executeTestMethod(MethodLevelInitializationFailureTestCases.class,
237-
"shouldFailMissingCountry");
237+
"shouldFailMissingCountry");
238238

239239
results.testEvents().assertThatEvents().haveAtMost(1,
240-
finishedWithFailure(instanceOf(ExtensionConfigurationException.class)));
240+
finishedWithFailure(instanceOf(ExtensionConfigurationException.class)));
241241
}
242242

243243
@Test
244244
@DisplayName("should fail when languageTag and language is set")
245245
void shouldFailWhenLanguageTagAndLanguageIsSet() {
246246
ExecutionResults results = executeTestMethod(MethodLevelInitializationFailureTestCases.class,
247-
"shouldFailLanguageTagAndLanguage");
247+
"shouldFailLanguageTagAndLanguage");
248248

249249
results.testEvents().assertThatEvents().haveAtMost(1,
250-
finishedWithFailure(instanceOf(ExtensionConfigurationException.class)));
250+
finishedWithFailure(instanceOf(ExtensionConfigurationException.class)));
251251
}
252252

253253
@Test
254254
@DisplayName("should fail when languageTag and country is set")
255255
void shouldFailWhenLanguageTagAndCountryIsSet() {
256256
ExecutionResults results = executeTestMethod(MethodLevelInitializationFailureTestCases.class,
257-
"shouldFailLanguageTagAndCountry");
257+
"shouldFailLanguageTagAndCountry");
258258

259259
results.testEvents().assertThatEvents().haveAtMost(1,
260-
finishedWithFailure(instanceOf(ExtensionConfigurationException.class)));
260+
finishedWithFailure(instanceOf(ExtensionConfigurationException.class)));
261261
}
262262

263263
@Test
264264
@DisplayName("should fail when languageTag and variant is set")
265265
void shouldFailWhenLanguageTagAndVariantIsSet() {
266266
ExecutionResults results = executeTestMethod(MethodLevelInitializationFailureTestCases.class,
267-
"shouldFailLanguageTagAndVariant");
267+
"shouldFailLanguageTagAndVariant");
268268

269269
results.testEvents().assertThatEvents().haveAtMost(1,
270-
finishedWithFailure(instanceOf(ExtensionConfigurationException.class)));
270+
finishedWithFailure(instanceOf(ExtensionConfigurationException.class)));
271271
}
272272

273273
@Test
274274
@DisplayName("should fail when invalid BCP 47 variant is set")
275275
void shouldFailIfNoValidBCP47VariantIsSet() {
276276
ExecutionResults results = executeTestMethod(MethodLevelInitializationFailureTestCases.class,
277-
"shouldFailNoValidBCP47Variant");
277+
"shouldFailNoValidBCP47Variant");
278278

279279
results.testEvents().assertThatEvents().haveAtMost(1,
280-
finishedWithFailure(instanceOf(ExtensionConfigurationException.class)));
280+
finishedWithFailure(instanceOf(ExtensionConfigurationException.class)));
281281
}
282282

283283
}
@@ -292,7 +292,7 @@ void shouldFailWhenVariantIsSetButCountryIsNot() {
292292
ExecutionResults results = executeTestClass(ClassLevelInitializationFailureTestCases.class);
293293

294294
results.testEvents().assertThatEvents().haveAtMost(1,
295-
finishedWithFailure(instanceOf(ExtensionConfigurationException.class)));
295+
finishedWithFailure(instanceOf(ExtensionConfigurationException.class)));
296296
}
297297

298298
}
@@ -377,8 +377,8 @@ void providerReturnsNull() {
377377
ExecutionResults results = executeTestMethod(BadProviderTestCases.class, "returnsNull");
378378

379379
results.testEvents().assertThatEvents().haveAtMost(1,
380-
finishedWithFailure(instanceOf(NullPointerException.class),
381-
message(it -> it.contains("LocaleProvider instance returned with null"))));
380+
finishedWithFailure(instanceOf(NullPointerException.class),
381+
message(it -> it.contains("LocaleProvider instance returned with null"))));
382382
}
383383

384384
@Test
@@ -388,8 +388,8 @@ void mutuallyExclusiveWithValue() {
388388
ExecutionResults results = executeTestMethod(BadProviderTestCases.class, "mutuallyExclusiveWithValue");
389389

390390
results.testEvents().assertThatEvents().haveAtMost(1,
391-
finishedWithFailure(instanceOf(ExtensionConfigurationException.class), message(it -> it.contains(
392-
"can only be used with a provider if value, language, country and variant are not set."))));
391+
finishedWithFailure(instanceOf(ExtensionConfigurationException.class), message(it -> it.contains(
392+
"can only be used with a provider if value, language, country and variant are not set."))));
393393
}
394394

395395
@Test
@@ -399,8 +399,8 @@ void mutuallyExclusiveWithLanguage() {
399399
ExecutionResults results = executeTestMethod(BadProviderTestCases.class, "mutuallyExclusiveWithLanguage");
400400

401401
results.testEvents().assertThatEvents().haveAtMost(1,
402-
finishedWithFailure(instanceOf(ExtensionConfigurationException.class),
403-
message(it -> it.contains("can only be used with language tag if provider is not set."))));
402+
finishedWithFailure(instanceOf(ExtensionConfigurationException.class),
403+
message(it -> it.contains("can only be used with language tag if provider is not set."))));
404404
}
405405

406406
@Test
@@ -410,8 +410,8 @@ void mutuallyExclusiveWithCountry() {
410410
ExecutionResults results = executeTestMethod(BadProviderTestCases.class, "mutuallyExclusiveWithCountry");
411411

412412
results.testEvents().assertThatEvents().haveAtMost(1,
413-
finishedWithFailure(instanceOf(ExtensionConfigurationException.class), message(it -> it.contains(
414-
"can only be used with a provider if value, language, country and variant are not set."))));
413+
finishedWithFailure(instanceOf(ExtensionConfigurationException.class), message(it -> it.contains(
414+
"can only be used with a provider if value, language, country and variant are not set."))));
415415
}
416416

417417
@Test
@@ -421,8 +421,8 @@ void mutuallyExclusiveWithVariant() {
421421
ExecutionResults results = executeTestMethod(BadProviderTestCases.class, "mutuallyExclusiveWithVariant");
422422

423423
results.testEvents().assertThatEvents().haveAtMost(1,
424-
finishedWithFailure(instanceOf(ExtensionConfigurationException.class), message(it -> it.contains(
425-
"can only be used with a provider if value, language, country and variant are not set."))));
424+
finishedWithFailure(instanceOf(ExtensionConfigurationException.class), message(it -> it.contains(
425+
"can only be used with a provider if value, language, country and variant are not set."))));
426426
}
427427

428428
@Test
@@ -432,8 +432,8 @@ void badConstructor() {
432432
ExecutionResults results = executeTestMethod(BadProviderTestCases.class, "badConstructor");
433433

434434
results.testEvents().assertThatEvents().haveAtMost(1,
435-
finishedWithFailure(instanceOf(ExtensionConfigurationException.class),
436-
message(it -> it.contains("could not be constructed because of an exception"))));
435+
finishedWithFailure(instanceOf(ExtensionConfigurationException.class),
436+
message(it -> it.contains("could not be constructed because of an exception"))));
437437
}
438438

439439
}

jupiter-tests/src/test/java/org/junit/jupiter/api/timezone/DefaultTimeZoneTests.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -206,10 +206,10 @@ class ConfigurationTests {
206206
@DisplayName("on method level, throws exception")
207207
void throwsWhenConfigurationIsBad() {
208208
ExecutionResults results = executeTestMethod(BadMethodLevelConfigurationTestCases.class,
209-
"badConfiguration");
209+
"badConfiguration");
210210
results.testEvents().assertThatEvents().haveAtMost(1,
211-
finishedWithFailure(instanceOf(ExtensionConfigurationException.class),
212-
message(it -> it.contains("@DefaultTimeZone not configured correctly."))));
211+
finishedWithFailure(instanceOf(ExtensionConfigurationException.class),
212+
message(it -> it.contains("@DefaultTimeZone not configured correctly."))));
213213
}
214214

215215
@Test
@@ -219,8 +219,8 @@ void shouldThrowWithBadConfiguration() {
219219
ExecutionResults results = executeTestClass(BadClassLevelConfigurationTestCases.class);
220220

221221
results.testEvents().assertThatEvents().haveAtMost(1,
222-
finishedWithFailure(instanceOf(ExtensionConfigurationException.class),
223-
message(it -> it.contains("@DefaultTimeZone not configured correctly."))));
222+
finishedWithFailure(instanceOf(ExtensionConfigurationException.class),
223+
message(it -> it.contains("@DefaultTimeZone not configured correctly."))));
224224
}
225225

226226
@AfterEach
@@ -290,8 +290,8 @@ void throwsForMutuallyExclusiveOptions() {
290290
ExecutionResults results = executeTestMethod(BadTimeZoneProviderTestCases.class, "notExclusive");
291291

292292
results.testEvents().assertThatEvents().haveAtMost(1,
293-
finishedWithFailure(instanceOf(ExtensionConfigurationException.class), message(it -> it.contains(
294-
"Either a valid time zone id or a TimeZoneProvider must be provided"))));
293+
finishedWithFailure(instanceOf(ExtensionConfigurationException.class),
294+
message(it -> it.contains("Either a valid time zone id or a TimeZoneProvider must be provided"))));
295295
}
296296

297297
@Test
@@ -301,8 +301,8 @@ void throwsForEmptyOptions() {
301301
ExecutionResults results = executeTestMethod(BadTimeZoneProviderTestCases.class, "empty");
302302

303303
results.testEvents().assertThatEvents().haveAtMost(1,
304-
finishedWithFailure(instanceOf(ExtensionConfigurationException.class), message(it -> it.contains(
305-
"Either a valid time zone id or a TimeZoneProvider must be provided"))));
304+
finishedWithFailure(instanceOf(ExtensionConfigurationException.class),
305+
message(it -> it.contains("Either a valid time zone id or a TimeZoneProvider must be provided"))));
306306
}
307307

308308
@Test
@@ -312,8 +312,8 @@ void throwsForBadConstructor() {
312312
ExecutionResults results = executeTestMethod(BadTimeZoneProviderTestCases.class, "noConstructor");
313313

314314
results.testEvents().assertThatEvents().haveAtMost(1,
315-
finishedWithFailure(instanceOf(ExtensionConfigurationException.class),
316-
message(it -> it.contains("Could not instantiate TimeZoneProvider because of exception"))));
315+
finishedWithFailure(instanceOf(ExtensionConfigurationException.class),
316+
message(it -> it.contains("Could not instantiate TimeZoneProvider because of exception"))));
317317
}
318318

319319
}

0 commit comments

Comments
 (0)