You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by rf...@apache.org on 2018/09/01 18:24:11 UTC

[maven-changes-plugin] branch builds-fix created (now 7bd9576)

This is an automated email from the ASF dual-hosted git repository.

rfscholte pushed a change to branch builds-fix
in repository https://gitbox.apache.org/repos/asf/maven-changes-plugin.git.


      at 7bd9576  Adjust unittest due to JEP 252: Use CLDR Locale Data by Default

This branch includes the following new commits:

     new 7bd9576  Adjust unittest due to JEP 252: Use CLDR Locale Data by Default

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[maven-changes-plugin] 01/01: Adjust unittest due to JEP 252: Use CLDR Locale Data by Default

Posted by rf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rfscholte pushed a commit to branch builds-fix
in repository https://gitbox.apache.org/repos/asf/maven-changes-plugin.git

commit 7bd95767fb5e62341a21223ccc27ee1ad463193c
Author: rfscholte <rf...@apache.org>
AuthorDate: Sat Sep 1 20:24:07 2018 +0200

    Adjust unittest due to JEP 252: Use CLDR Locale Data by Default
---
 pom.xml                                            |  4 +-
 .../plugins/changes/ChangesCheckMojoTestCase.java  | 63 ++++++++++++++++++----
 2 files changed, 54 insertions(+), 13 deletions(-)

diff --git a/pom.xml b/pom.xml
index 2cdf00e..c3f8f7d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -26,7 +26,7 @@ under the License.
     <artifactId>maven-plugins</artifactId>
     <groupId>org.apache.maven.plugins</groupId>
     <version>32</version>
-    <relativePath>../../pom/maven/maven-plugins/pom.xml</relativePath>
+    <relativePath/>
   </parent>
 
   <artifactId>maven-changes-plugin</artifactId>
@@ -383,7 +383,7 @@ under the License.
     <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
-      <version>3.8.2</version>
+      <version>4.12</version>
       <scope>test</scope>
     </dependency>
     <dependency>
diff --git a/src/test/java/org/apache/maven/plugins/changes/ChangesCheckMojoTestCase.java b/src/test/java/org/apache/maven/plugins/changes/ChangesCheckMojoTestCase.java
index 204a5c8..3d83784 100644
--- a/src/test/java/org/apache/maven/plugins/changes/ChangesCheckMojoTestCase.java
+++ b/src/test/java/org/apache/maven/plugins/changes/ChangesCheckMojoTestCase.java
@@ -1,7 +1,5 @@
 package org.apache.maven.plugins.changes;
 
-import org.apache.maven.plugins.changes.ChangesCheckMojo;
-
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -21,7 +19,14 @@ import org.apache.maven.plugins.changes.ChangesCheckMojo;
  * under the License.
  */
 
-import junit.framework.TestCase;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assume.assumeThat;
+import static org.hamcrest.CoreMatchers.startsWith;
+
+import org.apache.maven.plugins.changes.ChangesCheckMojo;
+import org.junit.Test;
 
 /**
  * @author Dennis Lundberg
@@ -29,8 +34,8 @@ import junit.framework.TestCase;
  * @since 2.4
  */
 public class ChangesCheckMojoTestCase
-    extends TestCase
 {
+    @Test
     public void testIsValidDate()
         throws Exception
     {
@@ -59,6 +64,7 @@ public class ChangesCheckMojoTestCase
         assertFalse( ChangesCheckMojo.isValidDate( "pending", pattern ) );
     }
 
+    @Test
     public void testIsValidateWithLocale()
         throws Exception
     {
@@ -98,13 +104,6 @@ public class ChangesCheckMojoTestCase
         // pattern with months as text
         pattern = "dd MMM yyyy";
 
-        // Czech locale
-        locale = "cs_CZ";
-        assertFalse( ChangesCheckMojo.isValidDate( null, pattern, locale ) );
-        assertFalse( ChangesCheckMojo.isValidDate( "", pattern, locale ) );
-        assertTrue( ChangesCheckMojo.isValidDate( "06 XII 2010", pattern, locale ) );
-        assertFalse( ChangesCheckMojo.isValidDate( "pending", pattern, locale ) );
-
         // English locale
         locale = "en_US";
         assertFalse( ChangesCheckMojo.isValidDate( null, pattern, locale ) );
@@ -112,4 +111,46 @@ public class ChangesCheckMojoTestCase
         assertTrue( ChangesCheckMojo.isValidDate( "06 Dec 2010", pattern, locale ) );
         assertFalse( ChangesCheckMojo.isValidDate( "pending", pattern, locale ) );
     }
+    
+    // In JDK 9, the Unicode Consortium's Common Locale Data Repository (CLDR) data is enabled as the default locale data, 
+    //   so that you can use standard locale data without any further action.
+    // In JDK 8, although CLDR locale data is bundled with the JRE, it isn’t enabled by default.
+    // source: https://docs.oracle.com/javase/9/migrate/toc.htm#JSMIG-GUID-A20F2989-BFA9-482D-8618-6CBB4BAAE310
+    @Test
+    public void testCompat()
+    {
+        // @TODO fix for Java 9+
+        // System.setProperty( "java.locale.providers", "COMPAT,CLDR" ) is not picked up...
+        assumeThat( System.getProperty( "java.version" ), startsWith( "1." ) );
+        
+        // pattern with months as text
+        String pattern = "dd MMM yyyy";
+
+        String originalJavaLocaleProviders = null;
+        if ( !System.getProperty( "java.version" ).startsWith( "1." ) )
+        {
+            originalJavaLocaleProviders = System.setProperty( "java.locale.providers", "COMPAT,CLDR" );
+        }
+        try
+        {
+            // Czech locale
+            String locale = "cs_CZ";
+            assertFalse( ChangesCheckMojo.isValidDate( null, pattern, locale ) );
+            assertFalse( ChangesCheckMojo.isValidDate( "", pattern, locale ) );
+            assertTrue( ChangesCheckMojo.isValidDate( "06 XII 2010", pattern, locale ) );
+            assertFalse( ChangesCheckMojo.isValidDate( "pending", pattern, locale ) );
+        }
+        finally
+        {
+            if ( originalJavaLocaleProviders != null )
+            {
+                System.setProperty( "java.locale.providers", originalJavaLocaleProviders );
+            }
+            else
+            {
+                System.clearProperty( "java.locale.providers" );
+            }
+        }
+    }
+    
 }