mirror of
https://github.com/mapstruct/mapstruct.git
synced 2025-07-12 00:00:08 +08:00
#2446 Use DefaultLocale and DefaultTimeZone from JUnit Pioneer
Configure the JUnit Platform to run the processor tests in parallel by running different test classes in concurrent threads
This commit is contained in:
parent
9ce9d4fb3a
commit
08016d9ef2
@ -29,6 +29,7 @@
|
|||||||
<org.eclipse.tycho.compiler-jdt.version>1.6.0</org.eclipse.tycho.compiler-jdt.version>
|
<org.eclipse.tycho.compiler-jdt.version>1.6.0</org.eclipse.tycho.compiler-jdt.version>
|
||||||
<com.puppycrawl.tools.checkstyle.version>8.36.1</com.puppycrawl.tools.checkstyle.version>
|
<com.puppycrawl.tools.checkstyle.version>8.36.1</com.puppycrawl.tools.checkstyle.version>
|
||||||
<org.junit.jupiter.version>5.8.0-M1</org.junit.jupiter.version>
|
<org.junit.jupiter.version>5.8.0-M1</org.junit.jupiter.version>
|
||||||
|
<junit-pioneer.version>1.4.2</junit-pioneer.version>
|
||||||
<add.release.arguments />
|
<add.release.arguments />
|
||||||
<forkCount>1</forkCount>
|
<forkCount>1</forkCount>
|
||||||
<assertj.version>3.17.2</assertj.version>
|
<assertj.version>3.17.2</assertj.version>
|
||||||
@ -141,6 +142,11 @@
|
|||||||
<type>pom</type>
|
<type>pom</type>
|
||||||
<scope>import</scope>
|
<scope>import</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.junit-pioneer</groupId>
|
||||||
|
<artifactId>junit-pioneer</artifactId>
|
||||||
|
<version>${junit-pioneer.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- CDI, Weld, Arquillian -->
|
<!-- CDI, Weld, Arquillian -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -115,6 +115,12 @@
|
|||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.junit-pioneer</groupId>
|
||||||
|
<artifactId>junit-pioneer</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- There is no compile dependency to Joda-Time; It's only required for testing the Joda conversions -->
|
<!-- There is no compile dependency to Joda-Time; It's only required for testing the Joda conversions -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>joda-time</groupId>
|
<groupId>joda-time</groupId>
|
||||||
|
@ -9,30 +9,15 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
import org.junit.jupiter.api.AfterEach;
|
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.junitpioneer.jupiter.DefaultLocale;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Filip Hrisafov
|
* @author Filip Hrisafov
|
||||||
*/
|
*/
|
||||||
public class StringsTest {
|
public class StringsTest {
|
||||||
|
|
||||||
private static final Locale TURKEY_LOCALE = getTurkeyLocale();
|
|
||||||
private Locale defaultLocale;
|
|
||||||
|
|
||||||
@BeforeEach
|
|
||||||
public void before() {
|
|
||||||
defaultLocale = Locale.getDefault();
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterEach
|
|
||||||
public void after() {
|
|
||||||
Locale.setDefault( defaultLocale );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCapitalize() {
|
public void testCapitalize() {
|
||||||
assertThat( Strings.capitalize( null ) ).isNull();
|
assertThat( Strings.capitalize( null ) ).isNull();
|
||||||
@ -137,40 +122,31 @@ public class StringsTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@DefaultLocale("en")
|
||||||
public void capitalizeEnglish() {
|
public void capitalizeEnglish() {
|
||||||
Locale.setDefault( Locale.ENGLISH );
|
|
||||||
String international = Strings.capitalize( "international" );
|
String international = Strings.capitalize( "international" );
|
||||||
assertThat( international ).isEqualTo( "International" );
|
assertThat( international ).isEqualTo( "International" );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@DefaultLocale("en")
|
||||||
public void decapitalizeEnglish() {
|
public void decapitalizeEnglish() {
|
||||||
Locale.setDefault( Locale.ENGLISH );
|
|
||||||
String international = Strings.decapitalize( "International" );
|
String international = Strings.decapitalize( "International" );
|
||||||
assertThat( international ).isEqualTo( "international" );
|
assertThat( international ).isEqualTo( "international" );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@DefaultLocale("tr")
|
||||||
public void capitalizeTurkish() {
|
public void capitalizeTurkish() {
|
||||||
Locale.setDefault( TURKEY_LOCALE );
|
|
||||||
String international = Strings.capitalize( "international" );
|
String international = Strings.capitalize( "international" );
|
||||||
assertThat( international ).isEqualTo( "International" );
|
assertThat( international ).isEqualTo( "International" );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@DefaultLocale("tr")
|
||||||
public void decapitalizeTurkish() {
|
public void decapitalizeTurkish() {
|
||||||
Locale.setDefault( TURKEY_LOCALE );
|
|
||||||
String international = Strings.decapitalize( "International" );
|
String international = Strings.decapitalize( "International" );
|
||||||
assertThat( international ).isEqualTo( "international" );
|
assertThat( international ).isEqualTo( "international" );
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Locale getTurkeyLocale() {
|
|
||||||
Locale turkeyLocale = Locale.forLanguageTag( "tr" );
|
|
||||||
|
|
||||||
if ( turkeyLocale == null ) {
|
|
||||||
throw new IllegalStateException( "Can't find Turkey locale." );
|
|
||||||
}
|
|
||||||
|
|
||||||
return turkeyLocale;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -9,8 +9,7 @@ import java.time.ZonedDateTime;
|
|||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
|
||||||
import org.junit.jupiter.api.AfterAll;
|
import org.junitpioneer.jupiter.DefaultTimeZone;
|
||||||
import org.junit.jupiter.api.BeforeAll;
|
|
||||||
import org.mapstruct.ap.testutil.IssueKey;
|
import org.mapstruct.ap.testutil.IssueKey;
|
||||||
import org.mapstruct.ap.testutil.ProcessorTest;
|
import org.mapstruct.ap.testutil.ProcessorTest;
|
||||||
import org.mapstruct.ap.testutil.WithClasses;
|
import org.mapstruct.ap.testutil.WithClasses;
|
||||||
@ -31,23 +30,11 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||||||
Target.class
|
Target.class
|
||||||
})
|
})
|
||||||
@IssueKey("1523")
|
@IssueKey("1523")
|
||||||
public class Issue1523Test {
|
|
||||||
|
|
||||||
private static final TimeZone DEFAULT_TIMEZONE = TimeZone.getDefault();
|
|
||||||
|
|
||||||
@BeforeAll
|
|
||||||
public static void before() {
|
|
||||||
// we want to test that the timezone will correctly be used in mapped XMLGregorianCalendar and not the
|
// we want to test that the timezone will correctly be used in mapped XMLGregorianCalendar and not the
|
||||||
// default one, so we must ensure that we use a different timezone than the default one -> set the default
|
// default one, so we must ensure that we use a different timezone than the default one -> set the default
|
||||||
// one explicitly to UTC
|
// one explicitly to UTC
|
||||||
TimeZone.setDefault( TimeZone.getTimeZone( "UTC" ) );
|
@DefaultTimeZone("UTC")
|
||||||
}
|
public class Issue1523Test {
|
||||||
|
|
||||||
@AfterAll
|
|
||||||
public static void after() {
|
|
||||||
// revert the changed default TZ
|
|
||||||
TimeZone.setDefault( DEFAULT_TIMEZONE );
|
|
||||||
}
|
|
||||||
|
|
||||||
@ProcessorTest
|
@ProcessorTest
|
||||||
public void testThatCorrectTimeZoneWillBeUsedInTarget() {
|
public void testThatCorrectTimeZoneWillBeUsedInTarget() {
|
||||||
|
@ -17,15 +17,13 @@ import java.util.Date;
|
|||||||
import java.util.GregorianCalendar;
|
import java.util.GregorianCalendar;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.TimeZone;
|
|
||||||
import javax.xml.bind.JAXBElement;
|
import javax.xml.bind.JAXBElement;
|
||||||
import javax.xml.datatype.DatatypeConfigurationException;
|
import javax.xml.datatype.DatatypeConfigurationException;
|
||||||
import javax.xml.datatype.DatatypeFactory;
|
import javax.xml.datatype.DatatypeFactory;
|
||||||
import javax.xml.datatype.XMLGregorianCalendar;
|
import javax.xml.datatype.XMLGregorianCalendar;
|
||||||
import javax.xml.namespace.QName;
|
import javax.xml.namespace.QName;
|
||||||
|
|
||||||
import org.junit.jupiter.api.AfterAll;
|
import org.junitpioneer.jupiter.DefaultTimeZone;
|
||||||
import org.junit.jupiter.api.BeforeAll;
|
|
||||||
import org.mapstruct.ap.test.builtin._target.IterableTarget;
|
import org.mapstruct.ap.test.builtin._target.IterableTarget;
|
||||||
import org.mapstruct.ap.test.builtin._target.MapTarget;
|
import org.mapstruct.ap.test.builtin._target.MapTarget;
|
||||||
import org.mapstruct.ap.test.builtin.bean.BigDecimalProperty;
|
import org.mapstruct.ap.test.builtin.bean.BigDecimalProperty;
|
||||||
@ -85,21 +83,9 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||||||
IterableSource.class,
|
IterableSource.class,
|
||||||
MapSource.class
|
MapSource.class
|
||||||
})
|
})
|
||||||
|
@DefaultTimeZone("Europe/Berlin")
|
||||||
public class BuiltInTest {
|
public class BuiltInTest {
|
||||||
|
|
||||||
private static TimeZone originalTimeZone;
|
|
||||||
|
|
||||||
@BeforeAll
|
|
||||||
public static void setDefaultTimeZoneToCet() {
|
|
||||||
originalTimeZone = TimeZone.getDefault();
|
|
||||||
TimeZone.setDefault( TimeZone.getTimeZone( "Europe/Berlin" ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterAll
|
|
||||||
public static void restoreOriginalTimeZone() {
|
|
||||||
TimeZone.setDefault( originalTimeZone );
|
|
||||||
}
|
|
||||||
|
|
||||||
@ProcessorTest
|
@ProcessorTest
|
||||||
@WithClasses( JaxbMapper.class )
|
@WithClasses( JaxbMapper.class )
|
||||||
public void shouldApplyBuiltInOnJAXBElement() {
|
public void shouldApplyBuiltInOnJAXBElement() {
|
||||||
|
@ -10,10 +10,8 @@ import java.text.SimpleDateFormat;
|
|||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.GregorianCalendar;
|
import java.util.GregorianCalendar;
|
||||||
import java.util.TimeZone;
|
|
||||||
|
|
||||||
import org.junit.jupiter.api.AfterEach;
|
import org.junitpioneer.jupiter.DefaultTimeZone;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
|
||||||
import org.mapstruct.ap.test.builtin.bean.CalendarProperty;
|
import org.mapstruct.ap.test.builtin.bean.CalendarProperty;
|
||||||
import org.mapstruct.ap.test.builtin.bean.DatatypeFactory;
|
import org.mapstruct.ap.test.builtin.bean.DatatypeFactory;
|
||||||
import org.mapstruct.ap.test.builtin.bean.DateProperty;
|
import org.mapstruct.ap.test.builtin.bean.DateProperty;
|
||||||
@ -32,21 +30,9 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||||||
DateProperty.class
|
DateProperty.class
|
||||||
|
|
||||||
} )
|
} )
|
||||||
|
@DefaultTimeZone("Europe/Berlin")
|
||||||
public class DatatypeFactoryTest {
|
public class DatatypeFactoryTest {
|
||||||
|
|
||||||
private TimeZone originalTimeZone;
|
|
||||||
|
|
||||||
@BeforeEach
|
|
||||||
public void setUp() {
|
|
||||||
originalTimeZone = TimeZone.getDefault();
|
|
||||||
TimeZone.setDefault( TimeZone.getTimeZone( "Europe/Berlin" ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterEach
|
|
||||||
public void tearDown() {
|
|
||||||
TimeZone.setDefault( originalTimeZone );
|
|
||||||
}
|
|
||||||
|
|
||||||
@ProcessorTest
|
@ProcessorTest
|
||||||
public void testNoConflictsWithOwnDatatypeFactory() throws ParseException {
|
public void testNoConflictsWithOwnDatatypeFactory() throws ParseException {
|
||||||
|
|
||||||
|
@ -12,13 +12,11 @@ import java.util.Calendar;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.GregorianCalendar;
|
import java.util.GregorianCalendar;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
import org.junit.jupiter.api.AfterEach;
|
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
|
||||||
import org.junit.jupiter.api.condition.EnabledForJreRange;
|
import org.junit.jupiter.api.condition.EnabledForJreRange;
|
||||||
import org.junit.jupiter.api.condition.EnabledOnJre;
|
import org.junit.jupiter.api.condition.EnabledOnJre;
|
||||||
import org.junit.jupiter.api.condition.JRE;
|
import org.junit.jupiter.api.condition.JRE;
|
||||||
|
import org.junitpioneer.jupiter.DefaultLocale;
|
||||||
import org.mapstruct.ap.testutil.IssueKey;
|
import org.mapstruct.ap.testutil.IssueKey;
|
||||||
import org.mapstruct.ap.testutil.ProcessorTest;
|
import org.mapstruct.ap.testutil.ProcessorTest;
|
||||||
import org.mapstruct.ap.testutil.WithClasses;
|
import org.mapstruct.ap.testutil.WithClasses;
|
||||||
@ -36,21 +34,9 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||||||
SourceTargetMapper.class
|
SourceTargetMapper.class
|
||||||
})
|
})
|
||||||
@IssueKey("43")
|
@IssueKey("43")
|
||||||
|
@DefaultLocale("de")
|
||||||
public class DateConversionTest {
|
public class DateConversionTest {
|
||||||
|
|
||||||
private Locale originalLocale;
|
|
||||||
|
|
||||||
@BeforeEach
|
|
||||||
public void setDefaultLocale() {
|
|
||||||
originalLocale = Locale.getDefault();
|
|
||||||
Locale.setDefault( Locale.GERMAN );
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterEach
|
|
||||||
public void tearDown() {
|
|
||||||
Locale.setDefault( originalLocale );
|
|
||||||
}
|
|
||||||
|
|
||||||
@ProcessorTest
|
@ProcessorTest
|
||||||
@EnabledOnJre( JRE.JAVA_8 )
|
@EnabledOnJre( JRE.JAVA_8 )
|
||||||
// See https://bugs.openjdk.java.net/browse/JDK-8211262, there is a difference in the default formats on Java 9+
|
// See https://bugs.openjdk.java.net/browse/JDK-8211262, there is a difference in the default formats on Java 9+
|
||||||
|
@ -17,8 +17,7 @@ import java.util.Calendar;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
|
||||||
import org.junit.jupiter.api.AfterEach;
|
import org.junitpioneer.jupiter.DefaultTimeZone;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
|
||||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||||
import org.mapstruct.ap.testutil.IssueKey;
|
import org.mapstruct.ap.testutil.IssueKey;
|
||||||
import org.mapstruct.ap.testutil.ProcessorTest;
|
import org.mapstruct.ap.testutil.ProcessorTest;
|
||||||
@ -37,18 +36,6 @@ public class Java8TimeConversionTest {
|
|||||||
@RegisterExtension
|
@RegisterExtension
|
||||||
GeneratedSource generatedSource = new GeneratedSource().addComparisonToFixtureFor( SourceTargetMapper.class );
|
GeneratedSource generatedSource = new GeneratedSource().addComparisonToFixtureFor( SourceTargetMapper.class );
|
||||||
|
|
||||||
private TimeZone originalTimeZone;
|
|
||||||
|
|
||||||
@BeforeEach
|
|
||||||
public void setUp() {
|
|
||||||
originalTimeZone = TimeZone.getDefault();
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterEach
|
|
||||||
public void tearDown() {
|
|
||||||
TimeZone.setDefault( originalTimeZone );
|
|
||||||
}
|
|
||||||
|
|
||||||
@ProcessorTest
|
@ProcessorTest
|
||||||
public void testDateTimeToString() {
|
public void testDateTimeToString() {
|
||||||
Source src = new Source();
|
Source src = new Source();
|
||||||
@ -226,8 +213,8 @@ public class Java8TimeConversionTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@ProcessorTest
|
@ProcessorTest
|
||||||
|
@DefaultTimeZone("UTC")
|
||||||
public void testZonedDateTimeToDateMapping() {
|
public void testZonedDateTimeToDateMapping() {
|
||||||
TimeZone.setDefault( TimeZone.getTimeZone( "UTC" ) );
|
|
||||||
Source source = new Source();
|
Source source = new Source();
|
||||||
ZonedDateTime dateTime = ZonedDateTime.of( LocalDateTime.of( 2014, 1, 1, 0, 0 ), ZoneId.of( "UTC" ) );
|
ZonedDateTime dateTime = ZonedDateTime.of( LocalDateTime.of( 2014, 1, 1, 0, 0 ), ZoneId.of( "UTC" ) );
|
||||||
source.setForDateConversionWithZonedDateTime(
|
source.setForDateConversionWithZonedDateTime(
|
||||||
@ -266,8 +253,8 @@ public class Java8TimeConversionTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@ProcessorTest
|
@ProcessorTest
|
||||||
|
@DefaultTimeZone("Australia/Melbourne")
|
||||||
public void testLocalDateTimeToDateMapping() {
|
public void testLocalDateTimeToDateMapping() {
|
||||||
TimeZone.setDefault( TimeZone.getTimeZone( "Australia/Melbourne" ) );
|
|
||||||
|
|
||||||
Source source = new Source();
|
Source source = new Source();
|
||||||
LocalDateTime dateTime = LocalDateTime.of( 2014, 1, 1, 0, 0 );
|
LocalDateTime dateTime = LocalDateTime.of( 2014, 1, 1, 0, 0 );
|
||||||
@ -292,8 +279,8 @@ public class Java8TimeConversionTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@ProcessorTest
|
@ProcessorTest
|
||||||
|
@DefaultTimeZone("Australia/Melbourne")
|
||||||
public void testLocalDateToDateMapping() {
|
public void testLocalDateToDateMapping() {
|
||||||
TimeZone.setDefault( TimeZone.getTimeZone( "Australia/Melbourne" ) );
|
|
||||||
|
|
||||||
Source source = new Source();
|
Source source = new Source();
|
||||||
LocalDate localDate = LocalDate.of( 2016, 3, 1 );
|
LocalDate localDate = LocalDate.of( 2016, 3, 1 );
|
||||||
@ -316,8 +303,8 @@ public class Java8TimeConversionTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@ProcessorTest
|
@ProcessorTest
|
||||||
|
@DefaultTimeZone("Australia/Melbourne")
|
||||||
public void testLocalDateToSqlDateMapping() {
|
public void testLocalDateToSqlDateMapping() {
|
||||||
TimeZone.setDefault( TimeZone.getTimeZone( "Australia/Melbourne" ) );
|
|
||||||
|
|
||||||
Source source = new Source();
|
Source source = new Source();
|
||||||
LocalDate localDate = LocalDate.of( 2016, 3, 1 );
|
LocalDate localDate = LocalDate.of( 2016, 3, 1 );
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
package org.mapstruct.ap.test.conversion.jodatime;
|
package org.mapstruct.ap.test.conversion.jodatime;
|
||||||
|
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
@ -14,11 +13,10 @@ import org.joda.time.DateTimeZone;
|
|||||||
import org.joda.time.LocalDate;
|
import org.joda.time.LocalDate;
|
||||||
import org.joda.time.LocalDateTime;
|
import org.joda.time.LocalDateTime;
|
||||||
import org.joda.time.LocalTime;
|
import org.joda.time.LocalTime;
|
||||||
import org.junit.jupiter.api.AfterEach;
|
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
|
||||||
import org.junit.jupiter.api.condition.EnabledForJreRange;
|
import org.junit.jupiter.api.condition.EnabledForJreRange;
|
||||||
import org.junit.jupiter.api.condition.EnabledOnJre;
|
import org.junit.jupiter.api.condition.EnabledOnJre;
|
||||||
import org.junit.jupiter.api.condition.JRE;
|
import org.junit.jupiter.api.condition.JRE;
|
||||||
|
import org.junitpioneer.jupiter.DefaultLocale;
|
||||||
import org.mapstruct.ap.testutil.IssueKey;
|
import org.mapstruct.ap.testutil.IssueKey;
|
||||||
import org.mapstruct.ap.testutil.ProcessorTest;
|
import org.mapstruct.ap.testutil.ProcessorTest;
|
||||||
import org.mapstruct.ap.testutil.WithClasses;
|
import org.mapstruct.ap.testutil.WithClasses;
|
||||||
@ -32,21 +30,9 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||||||
*/
|
*/
|
||||||
@WithClasses({ Source.class, Target.class, SourceTargetMapper.class })
|
@WithClasses({ Source.class, Target.class, SourceTargetMapper.class })
|
||||||
@IssueKey("75")
|
@IssueKey("75")
|
||||||
|
@DefaultLocale("de")
|
||||||
public class JodaConversionTest {
|
public class JodaConversionTest {
|
||||||
|
|
||||||
private Locale originalLocale;
|
|
||||||
|
|
||||||
@BeforeEach
|
|
||||||
public void setDefaultLocale() {
|
|
||||||
originalLocale = Locale.getDefault();
|
|
||||||
Locale.setDefault( Locale.GERMAN );
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterEach
|
|
||||||
public void tearDown() {
|
|
||||||
Locale.setDefault( originalLocale );
|
|
||||||
}
|
|
||||||
|
|
||||||
@ProcessorTest
|
@ProcessorTest
|
||||||
public void testDateTimeToString() {
|
public void testDateTimeToString() {
|
||||||
Source src = new Source();
|
Source src = new Source();
|
||||||
|
@ -10,11 +10,9 @@ import java.math.BigInteger;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.junit.jupiter.api.AfterEach;
|
import org.junitpioneer.jupiter.DefaultLocale;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
|
||||||
import org.mapstruct.ap.testutil.ProcessorTest;
|
import org.mapstruct.ap.testutil.ProcessorTest;
|
||||||
import org.mapstruct.ap.testutil.WithClasses;
|
import org.mapstruct.ap.testutil.WithClasses;
|
||||||
|
|
||||||
@ -26,21 +24,9 @@ import static org.assertj.core.api.Assertions.entry;
|
|||||||
Target.class,
|
Target.class,
|
||||||
SourceTargetMapper.class
|
SourceTargetMapper.class
|
||||||
})
|
})
|
||||||
|
@DefaultLocale("en")
|
||||||
public class NumberFormatConversionTest {
|
public class NumberFormatConversionTest {
|
||||||
|
|
||||||
private Locale originalLocale;
|
|
||||||
|
|
||||||
@BeforeEach
|
|
||||||
public void setDefaultLocale() {
|
|
||||||
originalLocale = Locale.getDefault();
|
|
||||||
Locale.setDefault( Locale.ENGLISH );
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterEach
|
|
||||||
public void tearDown() {
|
|
||||||
Locale.setDefault( originalLocale );
|
|
||||||
}
|
|
||||||
|
|
||||||
@ProcessorTest
|
@ProcessorTest
|
||||||
public void shouldApplyStringConversions() {
|
public void shouldApplyStringConversions() {
|
||||||
Source source = new Source();
|
Source source = new Source();
|
||||||
|
@ -8,13 +8,11 @@ package org.mapstruct.ap.test.injectionstrategy.spring.compileoptionconstructor;
|
|||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.TimeZone;
|
|
||||||
|
|
||||||
import org.junit.jupiter.api.AfterAll;
|
|
||||||
import org.junit.jupiter.api.AfterEach;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.jupiter.api.BeforeAll;
|
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||||
|
import org.junitpioneer.jupiter.DefaultTimeZone;
|
||||||
import org.mapstruct.ap.test.injectionstrategy.shared.CustomerDto;
|
import org.mapstruct.ap.test.injectionstrategy.shared.CustomerDto;
|
||||||
import org.mapstruct.ap.test.injectionstrategy.shared.CustomerEntity;
|
import org.mapstruct.ap.test.injectionstrategy.shared.CustomerEntity;
|
||||||
import org.mapstruct.ap.test.injectionstrategy.shared.CustomerRecordDto;
|
import org.mapstruct.ap.test.injectionstrategy.shared.CustomerRecordDto;
|
||||||
@ -54,10 +52,9 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||||||
@ProcessorOption( name = "mapstruct.defaultInjectionStrategy", value = "constructor")
|
@ProcessorOption( name = "mapstruct.defaultInjectionStrategy", value = "constructor")
|
||||||
@ComponentScan(basePackageClasses = CustomerSpringCompileOptionConstructorMapper.class)
|
@ComponentScan(basePackageClasses = CustomerSpringCompileOptionConstructorMapper.class)
|
||||||
@Configuration
|
@Configuration
|
||||||
|
@DefaultTimeZone("Europe/Berlin")
|
||||||
public class SpringCompileOptionConstructorMapperTest {
|
public class SpringCompileOptionConstructorMapperTest {
|
||||||
|
|
||||||
private static TimeZone originalTimeZone;
|
|
||||||
|
|
||||||
@RegisterExtension
|
@RegisterExtension
|
||||||
final GeneratedSource generatedSource = new GeneratedSource();
|
final GeneratedSource generatedSource = new GeneratedSource();
|
||||||
|
|
||||||
@ -65,17 +62,6 @@ public class SpringCompileOptionConstructorMapperTest {
|
|||||||
private CustomerRecordSpringCompileOptionConstructorMapper customerRecordMapper;
|
private CustomerRecordSpringCompileOptionConstructorMapper customerRecordMapper;
|
||||||
private ConfigurableApplicationContext context;
|
private ConfigurableApplicationContext context;
|
||||||
|
|
||||||
@BeforeAll
|
|
||||||
public static void setDefaultTimeZoneToCet() {
|
|
||||||
originalTimeZone = TimeZone.getDefault();
|
|
||||||
TimeZone.setDefault( TimeZone.getTimeZone( "Europe/Berlin" ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterAll
|
|
||||||
public static void restoreOriginalTimeZone() {
|
|
||||||
TimeZone.setDefault( originalTimeZone );
|
|
||||||
}
|
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
public void springUp() {
|
public void springUp() {
|
||||||
context = new AnnotationConfigApplicationContext( getClass() );
|
context = new AnnotationConfigApplicationContext( getClass() );
|
||||||
|
@ -10,11 +10,10 @@ import java.text.SimpleDateFormat;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
|
||||||
import org.junit.jupiter.api.AfterAll;
|
|
||||||
import org.junit.jupiter.api.AfterEach;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.jupiter.api.BeforeAll;
|
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||||
|
import org.junitpioneer.jupiter.DefaultTimeZone;
|
||||||
import org.mapstruct.ap.test.injectionstrategy.shared.CustomerDto;
|
import org.mapstruct.ap.test.injectionstrategy.shared.CustomerDto;
|
||||||
import org.mapstruct.ap.test.injectionstrategy.shared.CustomerEntity;
|
import org.mapstruct.ap.test.injectionstrategy.shared.CustomerEntity;
|
||||||
import org.mapstruct.ap.test.injectionstrategy.shared.CustomerRecordDto;
|
import org.mapstruct.ap.test.injectionstrategy.shared.CustomerRecordDto;
|
||||||
@ -54,6 +53,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||||||
@IssueKey( "571" )
|
@IssueKey( "571" )
|
||||||
@ComponentScan(basePackageClasses = CustomerSpringConstructorMapper.class)
|
@ComponentScan(basePackageClasses = CustomerSpringConstructorMapper.class)
|
||||||
@Configuration
|
@Configuration
|
||||||
|
@DefaultTimeZone("Europe/Berlin")
|
||||||
public class SpringConstructorMapperTest {
|
public class SpringConstructorMapperTest {
|
||||||
|
|
||||||
private static TimeZone originalTimeZone;
|
private static TimeZone originalTimeZone;
|
||||||
@ -65,17 +65,6 @@ public class SpringConstructorMapperTest {
|
|||||||
private CustomerRecordSpringConstructorMapper customerRecordMapper;
|
private CustomerRecordSpringConstructorMapper customerRecordMapper;
|
||||||
private ConfigurableApplicationContext context;
|
private ConfigurableApplicationContext context;
|
||||||
|
|
||||||
@BeforeAll
|
|
||||||
public static void setDefaultTimeZoneToCet() {
|
|
||||||
originalTimeZone = TimeZone.getDefault();
|
|
||||||
TimeZone.setDefault( TimeZone.getTimeZone( "Europe/Berlin" ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterAll
|
|
||||||
public static void restoreOriginalTimeZone() {
|
|
||||||
TimeZone.setDefault( originalTimeZone );
|
|
||||||
}
|
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
public void springUp() {
|
public void springUp() {
|
||||||
context = new AnnotationConfigApplicationContext( getClass() );
|
context = new AnnotationConfigApplicationContext( getClass() );
|
||||||
|
@ -9,7 +9,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.GregorianCalendar;
|
import java.util.GregorianCalendar;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
|
||||||
import javax.xml.bind.JAXBElement;
|
import javax.xml.bind.JAXBElement;
|
||||||
import javax.xml.datatype.DatatypeConfigurationException;
|
import javax.xml.datatype.DatatypeConfigurationException;
|
||||||
import javax.xml.datatype.DatatypeConstants;
|
import javax.xml.datatype.DatatypeConstants;
|
||||||
@ -17,8 +16,7 @@ import javax.xml.datatype.DatatypeFactory;
|
|||||||
import javax.xml.datatype.XMLGregorianCalendar;
|
import javax.xml.datatype.XMLGregorianCalendar;
|
||||||
import javax.xml.namespace.QName;
|
import javax.xml.namespace.QName;
|
||||||
|
|
||||||
import org.junit.jupiter.api.AfterEach;
|
import org.junitpioneer.jupiter.DefaultLocale;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
|
||||||
import org.mapstruct.ap.testutil.IssueKey;
|
import org.mapstruct.ap.testutil.IssueKey;
|
||||||
import org.mapstruct.ap.testutil.ProcessorTest;
|
import org.mapstruct.ap.testutil.ProcessorTest;
|
||||||
import org.mapstruct.ap.testutil.WithClasses;
|
import org.mapstruct.ap.testutil.WithClasses;
|
||||||
@ -31,23 +29,11 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||||||
* @author Sjaak Derksen
|
* @author Sjaak Derksen
|
||||||
*/
|
*/
|
||||||
@IssueKey("134")
|
@IssueKey("134")
|
||||||
|
@DefaultLocale("de")
|
||||||
public class NestedMappingMethodInvocationTest {
|
public class NestedMappingMethodInvocationTest {
|
||||||
|
|
||||||
public static final QName QNAME = new QName( "dont-care" );
|
public static final QName QNAME = new QName( "dont-care" );
|
||||||
|
|
||||||
private Locale originalLocale;
|
|
||||||
|
|
||||||
@BeforeEach
|
|
||||||
public void setDefaultLocale() {
|
|
||||||
originalLocale = Locale.getDefault();
|
|
||||||
Locale.setDefault( Locale.GERMAN );
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterEach
|
|
||||||
public void tearDown() {
|
|
||||||
Locale.setDefault( originalLocale );
|
|
||||||
}
|
|
||||||
|
|
||||||
@ProcessorTest
|
@ProcessorTest
|
||||||
@WithClasses( {
|
@WithClasses( {
|
||||||
OrderTypeToOrderDtoMapper.class,
|
OrderTypeToOrderDtoMapper.class,
|
||||||
|
3
processor/src/test/resources/junit-platform.properties
Normal file
3
processor/src/test/resources/junit-platform.properties
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
junit.jupiter.execution.parallel.enabled=true
|
||||||
|
junit.jupiter.execution.parallel.mode.default = same_thread
|
||||||
|
junit.jupiter.execution.parallel.mode.classes.default = concurrent
|
Loading…
x
Reference in New Issue
Block a user