Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update assertj+tests work with other locales #180

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions pom.xml
Expand Up @@ -335,7 +335,7 @@
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.0.0</version>
<version>3.2.0</version>
<inherited>false</inherited>
<configuration>
<descriptorRefs>
Expand Down Expand Up @@ -505,7 +505,7 @@
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>2.9.0</version>
<version>3.15.0</version>
</dependency>
<dependency>
<groupId>net.bytebuddy</groupId>
Expand Down
@@ -0,0 +1,16 @@
package org.xmlunit.assertj;

import java.util.Locale;

public class LocaleModifier {
private Locale locale;

public void setEnglish() {
locale = Locale.getDefault();
Locale.setDefault(new Locale("en"));
}

public void restore() {
Locale.setDefault(locale);
}
}
Expand Up @@ -13,6 +13,8 @@
*/
package org.xmlunit.assertj;

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
import org.mockito.Mockito;
Expand All @@ -34,6 +36,18 @@ public class ValueAssertTest {
@Rule
public ExpectedException thrown = none();

private static LocaleModifier locale = new LocaleModifier();

@BeforeClass
public static void overwriteLocale() {
locale.setEnglish();
}

@AfterClass
public static void restoreLocale() {
locale.restore();
}

@Test
public void testAsInt_shouldPass() {

Expand Down
Expand Up @@ -13,6 +13,8 @@
*/
package org.xmlunit.assertj;

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
import org.xmlunit.validation.Languages;
Expand All @@ -31,6 +33,18 @@ public class XmlAssertValidationTest {
@Rule
public ExpectedException thrown = none();

private static LocaleModifier locale = new LocaleModifier();

@BeforeClass
public static void overwriteLocale() {
locale.setEnglish();
}

@AfterClass
public static void restoreLocale() {
locale.restore();
}

@Test
public void testIsValidAgainst_shouldPass() {
StreamSource xml = new StreamSource(new File("../test-resources/BookXsdGenerated.xml"));
Expand Down Expand Up @@ -89,7 +103,8 @@ public void testIsValidAgainst_withEmptySourcesArray_shouldPass() {
StreamSource xml = new StreamSource(new File("../test-resources/BookXsdGenerated.xml"));

assertThat(xml).isValidAgainst();
assertThat(xml).isValidAgainst(new Object[0]);
final Object[] emptyArray = new Object[0];
assertThat(xml).isValidAgainst(emptyArray);
}

@Test
Expand Down
Expand Up @@ -13,6 +13,8 @@
*/
package org.xmlunit.assertj;

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;

Expand All @@ -25,6 +27,18 @@ public class XmlAssertValueByXPathTest {
@Rule
public ExpectedException thrown = none();

private static LocaleModifier locale = new LocaleModifier();

@BeforeClass
public static void overwriteLocale() {
locale.setEnglish();
}

@AfterClass
public static void restoreLocale() {
locale.restore();
}

@Test
public void testValueByXPath_withNull_shouldFailed() {

Expand Down