You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by GitBox <gi...@apache.org> on 2022/04/20 09:34:28 UTC

[GitHub] [maven-war-plugin] slawekjaranowski commented on a diff in pull request #22: [MWAR-450] ISO-8859-1 properties files get changed into UTF-8 when fi…

slawekjaranowski commented on code in PR #22:
URL: https://github.com/apache/maven-war-plugin/pull/22#discussion_r853930705


##########
src/it/MWAR-450/verify.bsh:
##########
@@ -0,0 +1,94 @@
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.*;
+
+import org.codehaus.plexus.util.*;
+
+boolean result = true;
+
+try
+{
+    File target = new File( basedir, "target/mwar450/WEB-INF/classes" );
+    if ( !target.exists() || !target.isDirectory() )
+    {
+        System.err.println( "target/mwar450/WEB-INF/classes is missing or is not a directory." );
+        return false;
+    }
+
+    // Load and check log4j.xml
+    File log4jxml = new File( target, "log4j.xml" );
+    if ( !log4jxml.exists() || log4jxml.isDirectory() )
+    {
+        System.err.println( "log4j.xml is missing or is a directory." );
+        return false;
+    }
+    FileInputStream fis = new FileInputStream ( log4jxml );
+    String paramContent = IOUtil.toString ( fis, "UTF-8" );
+    System.out.println( "content='" + paramContent + "'" );
+    int indexOf = paramContent.indexOf( "This file is encoded in UTF-8 and should remain so after filtering - åäö" );
+    if ( indexOf < 0 )
+    {
+      System.err.println( "Non-ascii characters changed encoding during filtering" );
+      return false;
+    }
+
+    // Load and check my.properties
+    File myProperties = new File( target, "my.properties" );
+    if ( !myProperties.exists() || myProperties.isDirectory() )
+    {
+        System.err.println( "my.properties is missing or is a directory." );
+        return false;
+    }
+    Properties properties = new Properties();

Review Comment:
   In jdk9 encoding of properties was changed.
   https://docs.oracle.com/javase/9/intl/internationalization-enhancements-jdk-9.htm
   
   Maybe good assertions will be length of file?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org