Add a parent class for locale aware tests
This commit is contained in:
parent
3d296c30a5
commit
00d903dc6b
|
@ -0,0 +1,23 @@
|
|||
package org.baeldung.javaxval;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
|
||||
public abstract class LocaleAwareUnitTest {
|
||||
private static Locale previousDefault;
|
||||
|
||||
@BeforeClass
|
||||
public static void setupLocale() {
|
||||
previousDefault = Locale.getDefault();
|
||||
|
||||
Locale.setDefault(Locale.US);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void resetLocale() {
|
||||
Locale.setDefault(previousDefault);
|
||||
}
|
||||
|
||||
}
|
|
@ -3,24 +3,22 @@ package org.baeldung.javaxval.bigdecimal;
|
|||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.validation.ConstraintViolation;
|
||||
import javax.validation.Validation;
|
||||
import javax.validation.Validator;
|
||||
|
||||
import org.baeldung.javaxval.LocaleAwareUnitTest;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
public class InvoiceUnitTest {
|
||||
public class InvoiceUnitTest extends LocaleAwareUnitTest {
|
||||
|
||||
private static Validator validator;
|
||||
|
||||
@BeforeClass
|
||||
public static void setupValidatorInstance() {
|
||||
Locale.setDefault(Locale.US);
|
||||
|
||||
validator = Validation.buildDefaultValidatorFactory()
|
||||
.getValidator();
|
||||
}
|
||||
|
|
|
@ -11,9 +11,6 @@ import javax.validation.Validation;
|
|||
import javax.validation.Validator;
|
||||
import javax.validation.ValidatorFactory;
|
||||
|
||||
import org.baeldung.javaxval.container.validation.Customer;
|
||||
import org.baeldung.javaxval.container.validation.CustomerMap;
|
||||
import org.baeldung.javaxval.container.validation.Profile;
|
||||
import org.baeldung.javaxval.container.validation.valueextractors.ProfileValueExtractor;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
|
|
@ -2,23 +2,21 @@ package org.baeldung.javaxval.validationgroup;
|
|||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.validation.ConstraintViolation;
|
||||
import javax.validation.Validation;
|
||||
import javax.validation.Validator;
|
||||
|
||||
import org.baeldung.javaxval.LocaleAwareUnitTest;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
public class RegistrationFormUnitTest {
|
||||
public class RegistrationFormUnitTest extends LocaleAwareUnitTest {
|
||||
private static Validator validator;
|
||||
|
||||
@BeforeClass
|
||||
public static void setupValidatorInstance() {
|
||||
Locale.setDefault(Locale.US);
|
||||
|
||||
validator = Validation.buildDefaultValidatorFactory()
|
||||
.getValidator();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue