Search in sources :

Example 1 with DefaultLocale

use of org.junitpioneer.jupiter.DefaultLocale in project checkstyle by checkstyle.

the class DefaultLoggerTest method testCleatBundleCache.

@DefaultLocale("fr")
@Test
public void testCleatBundleCache() throws Exception {
    final Constructor<?> cons = getConstructor();
    cons.setAccessible(true);
    final Object messageClass = cons.newInstance(DefaultLogger.ADD_EXCEPTION_MESSAGE, null);
    final Method message = messageClass.getClass().getDeclaredMethod("getMessage");
    message.setAccessible(true);
    final Map<String, ResourceBundle> bundleCache = TestUtil.getInternalStaticState(message.getDeclaringClass(), "BUNDLE_CACHE");
    assertWithMessage("Invalid message").that(message.invoke(messageClass)).isEqualTo("Une erreur est survenue {0}");
    assertWithMessage("Invalid bundle cache size").that(bundleCache).hasSize(1);
}
Also used : ResourceBundle(java.util.ResourceBundle) Method(java.lang.reflect.Method) DefaultLocale(org.junitpioneer.jupiter.DefaultLocale) Test(org.junit.jupiter.api.Test)

Example 2 with DefaultLocale

use of org.junitpioneer.jupiter.DefaultLocale in project mapstruct by mapstruct.

the class Issue2544Test method shouldConvertEn.

// Parsing numbers is sensitive to locale settings (e.g. decimal point)
@ProcessorTest
@DefaultLocale("en")
public void shouldConvertEn() {
    Issue2544Mapper.Target target = Issue2544Mapper.INSTANCE.map("123.45679E6");
    assertThat(target).isNotNull();
    assertThat(target.getBigNumber()).isEqualTo(new BigDecimal("1.2345679E+8"));
}
Also used : BigDecimal(java.math.BigDecimal) DefaultLocale(org.junitpioneer.jupiter.DefaultLocale) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest)

Example 3 with DefaultLocale

use of org.junitpioneer.jupiter.DefaultLocale in project mapstruct by mapstruct.

the class Issue2544Test method shouldConvertDe.

@ProcessorTest
@DefaultLocale("de")
public void shouldConvertDe() {
    Issue2544Mapper.Target target = Issue2544Mapper.INSTANCE.map("123,45679E6");
    assertThat(target).isNotNull();
    assertThat(target.getBigNumber()).isEqualTo(new BigDecimal("1.2345679E+8"));
}
Also used : BigDecimal(java.math.BigDecimal) DefaultLocale(org.junitpioneer.jupiter.DefaultLocale) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest)

Aggregations

DefaultLocale (org.junitpioneer.jupiter.DefaultLocale)3 BigDecimal (java.math.BigDecimal)2 ProcessorTest (org.mapstruct.ap.testutil.ProcessorTest)2 Method (java.lang.reflect.Method)1 ResourceBundle (java.util.ResourceBundle)1 Test (org.junit.jupiter.api.Test)1