From a520a937a4594eaad5d99734c91a23ef88e5cec4 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Gibello Date: Mon, 18 Feb 2019 15:12:21 +0100 Subject: [PATCH] Fixed tests for compatibility with both java 8 and java 10+ --- pom.xml | 22 +++++++++++++++++++ .../portal/service/i18n/I18nServiceTest.java | 12 +++++----- ...stractMessageFormatTemplateMethodTest.java | 8 +++++-- 3 files changed, 35 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index 9c00f26823..c53877b596 100644 --- a/pom.xml +++ b/pom.xml @@ -336,6 +336,28 @@ library-jmx-api 1.0.0 + + + + javax.xml.bind + jaxb-api + 2.3.0 + + + com.sun.xml.bind + jaxb-core + 2.3.0 + + + com.sun.xml.bind + jaxb-impl + 2.3.0 + + + javax.activation + activation + 1.1.1 + diff --git a/src/test/java/fr/paris/lutece/portal/service/i18n/I18nServiceTest.java b/src/test/java/fr/paris/lutece/portal/service/i18n/I18nServiceTest.java index 739bae7b1b..4c6e9708d6 100644 --- a/src/test/java/fr/paris/lutece/portal/service/i18n/I18nServiceTest.java +++ b/src/test/java/fr/paris/lutece/portal/service/i18n/I18nServiceTest.java @@ -101,9 +101,10 @@ public void testGetLocalizedDate( ) Locale locale = Locale.FRENCH; int nDateFormat = DateFormat.SHORT; - String expResult = "01/01/70"; - String result = fr.paris.lutece.portal.service.i18n.I18nService.getLocalizedDate( date, locale, nDateFormat ); - assertEquals( expResult, result ); + String expResultJava8 = "01/01/70"; + String expResultJava10 = "01/01/1970"; + String result = fr.paris.lutece.portal.service.i18n.I18nService.getLocalizedDate( date, locale, nDateFormat ); + assertTrue(expResultJava8.equals(result) || expResultJava10.equals(result)); } /** @@ -118,9 +119,10 @@ public void testGetLocalizedDateTime( ) int nDateFormat = DateFormat.SHORT; int nTimeFormat = DateFormat.SHORT; - String expResult = "01/01/70 01:00"; + String expResultJava8 = "01/01/70 01:00"; + String expResultJava10 = "01/01/1970 01:00"; String result = fr.paris.lutece.portal.service.i18n.I18nService.getLocalizedDateTime( date, locale, nDateFormat, nTimeFormat ); - assertEquals( expResult, result ); + assertTrue(expResultJava8.equals(result) || expResultJava10.equals(result)); } /** diff --git a/src/test/java/fr/paris/lutece/portal/service/template/AbstractMessageFormatTemplateMethodTest.java b/src/test/java/fr/paris/lutece/portal/service/template/AbstractMessageFormatTemplateMethodTest.java index 90c1ba3d50..6eb1b93852 100644 --- a/src/test/java/fr/paris/lutece/portal/service/template/AbstractMessageFormatTemplateMethodTest.java +++ b/src/test/java/fr/paris/lutece/portal/service/template/AbstractMessageFormatTemplateMethodTest.java @@ -96,12 +96,16 @@ public void testExec( ) model.put( "arg", new Date( 123456789 ) ); res = FreeMarkerTemplateService.getInstance( ).loadTemplate( template, Locale.FRANCE, model ); assertNotNull( res ); - assertEquals( "test with quote and arg 02/01/70 11:17", res.getHtml( ) ); + String expResultJava8 = "test with quote and arg 02/01/70 11:17"; + String expResultJava10 = "test with quote and arg 02/01/1970 11:17"; + assertTrue(expResultJava8.equals(res.getHtml()) || expResultJava10.equals(res.getHtml())); model.put( "arg", new Date( 123456789 ) ); res = FreeMarkerTemplateService.getInstance( ).loadTemplate( template, Locale.US, model ); assertNotNull( res ); - assertEquals( "test with quote and arg 1/2/70 11:17 AM", res.getHtml( ) ); + expResultJava8 = "test with quote and arg 1/2/70 11:17 AM"; + expResultJava10 = "test with quote and arg 1/2/70, 11:17 AM"; + assertTrue(expResultJava8.equals(res.getHtml()) || expResultJava10.equals(res.getHtml())); } }