You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by "Vincent Siveton (JIRA)" <ji...@codehaus.org> on 2005/09/01 22:20:03 UTC

[jira] Commented: (MPXDOC-154) system locale setting makes test cases fail.

    [ http://jira.codehaus.org/browse/MPXDOC-154?page=comments#action_45653 ] 

Vincent Siveton commented on MPXDOC-154:
----------------------------------------

Lukas,
I tried your test suites on Mandrake 10.1 (with java 1.4.2_04-b05) and all commands were successful.
I can't reproduce the test case failure on my system.

HTH

> system locale setting makes test cases fail.
> --------------------------------------------
>
>          Key: MPXDOC-154
>          URL: http://jira.codehaus.org/browse/MPXDOC-154
>      Project: maven-xdoc-plugin
>         Type: Bug
>     Versions: 1.9.1
>  Environment: java version "1.4.2_08"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_08-b03)
> Java HotSpot(TM) Client VM (build 1.4.2_08-b03, mixed mode)
> Fedora Core 3 x86
>     Reporter: Henning Schmiedehausen

>
>
> [henning@forge maven-xdoc-plugin-1.9.1]$ echo $LANG
> en_US
> [henning@forge maven-xdoc-plugin-1.9.1]$ rm -rf target ; maven -q test
> [...]
> test:test:
>     [junit] Running org.apache.maven.xdoc.util.LocaleUtilTest
>     [junit] Tests run: 7, Failures: 0, Errors: 0, Time elapsed: 1.854 sec <--------- !!!!!!!!!!!!!!!!!!!
>     [junit] Running org.apache.maven.NavBeanTest
>     [junit] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 1.567 sec
> [henning@forge maven-xdoc-plugin-1.9.1]$ export LANG=en_US.UTF-8 (this is the default on all recent Linux systems)
> [henning@forge maven-xdoc-plugin-1.9.1]$ rm -rf target; maven -q test:test
> [...]
> test:test:
>     [junit] Running org.apache.maven.xdoc.util.LocaleUtilTest
>     [junit] Tests run: 7, Failures: 1, Errors: 0, Time elapsed: 1.843 sec
>     [junit] [ERROR] TEST org.apache.maven.xdoc.util.LocaleUtilTest FAILED  <-------- !!!!!!!!!!!!!!!!!!
>     [junit] Running org.apache.maven.NavBeanTest
>     [junit] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 1.506 sec
> Same behaviour for plugins/trunk/xdoc

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: [jira] Commented: (MPXDOC-154) system locale setting makes test cases fail.

Posted by "Henning P. Schmiedehausen" <hp...@intermeta.de>.
Vincent Siveton <vi...@gmail.com> writes:

+1 for this. I'd prefer to set the encoding to ISO-8859-1 or US-ASCII
because IMHO it reflects the reality better.

	Regards
		Henning


>Hi guys,

>I am running java on Mandrake 10.1 (fr_CA).

>Personally, I prefer Juan solution. 

>On my system, by adding the following parameter, the build fails :
>+++ project.properties
>+maven.compile.encoding=UTF-8
>=> Failed

>So, I propose here a mixed solution to be safe [1]:
>+++ src/test/org/apache/maven/xdoc/util/LocaleUtilTest.java
>-    assertEquals(result, "Fran�ais");
>+    assertEquals(result, "Fran\u00e7ais");

>+++ project.properties
>+maven.compile.encoding=UTF-8
>=> Success

>Thoughts?

>Cheers,

>Vincent

>[1] Let's see http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/javac.html#options
>"-encoding encoding 
>Set the source file encoding name, such as EUCJIS/SJIS. If -encoding
>is not specified, the platform default converter is used. "



>2005/9/2, Juan F. Codagnone <ju...@users.sourceforge.net>:
>> 
>> On Thursday 01 September 2005 21:25, Lukas Theussl wrote:
>> ...
>> > Can you guys confirm that this still works for you?
>> 
>> yeap, that fixes the problem. The other solution that works, is telling the
>> compiler that these java classes are written en latin1:
>> 
>> Index: project.properties
>> ===================================================================
>> --- project.properties  (revision 266297)
>> +++ project.properties  (working copy)
>> @@ -18,3 +18,4 @@
>>  # P R O J E C T  P R O P E R T I E S
>>  # -------------------------------------------------------------------
>>  maven.junit.fork=yes
>> +maven.compile.encoding=ISO-8859-1
>> 
>> 
>> Regards,
>>     Juan.
>> 
>> pd. first post!
>> 
>> --
>> Buenos Aires, Argentina                          8�C with winds at 24 km/h SSW
>> 
>> 
>>

>---------------------------------------------------------------------
>To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
>For additional commands, e-mail: dev-help@maven.apache.org


-- 
Dipl.-Inf. (Univ.) Henning P. Schmiedehausen          INTERMETA GmbH
hps@intermeta.de        +49 9131 50 654 0   http://www.intermeta.de/

RedHat Certified Engineer -- Jakarta Turbine Development  -- hero for hire
   Linux, Java, perl, Solaris -- Consulting, Training, Development

		      4 - 8 - 15 - 16 - 23 - 42

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: [jira] Commented: (MPXDOC-154) system locale setting makes test cases fail.

Posted by Vincent Siveton <vi...@gmail.com>.
Hi guys,

I am running java on Mandrake 10.1 (fr_CA).

Personally, I prefer Juan solution. 

On my system, by adding the following parameter, the build fails :
+++ project.properties
+maven.compile.encoding=UTF-8
=> Failed

So, I propose here a mixed solution to be safe [1]:
+++ src/test/org/apache/maven/xdoc/util/LocaleUtilTest.java
-    assertEquals(result, "Français");
+    assertEquals(result, "Fran\u00e7ais");

+++ project.properties
+maven.compile.encoding=UTF-8
=> Success

Thoughts?

Cheers,

Vincent

[1] Let's see http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/javac.html#options
"-encoding encoding 
Set the source file encoding name, such as EUCJIS/SJIS. If -encoding
is not specified, the platform default converter is used. "



2005/9/2, Juan F. Codagnone <ju...@users.sourceforge.net>:
> 
> On Thursday 01 September 2005 21:25, Lukas Theussl wrote:
> ...
> > Can you guys confirm that this still works for you?
> 
> yeap, that fixes the problem. The other solution that works, is telling the
> compiler that these java classes are written en latin1:
> 
> Index: project.properties
> ===================================================================
> --- project.properties  (revision 266297)
> +++ project.properties  (working copy)
> @@ -18,3 +18,4 @@
>  # P R O J E C T  P R O P E R T I E S
>  # -------------------------------------------------------------------
>  maven.junit.fork=yes
> +maven.compile.encoding=ISO-8859-1
> 
> 
> Regards,
>     Juan.
> 
> pd. first post!
> 
> --
> Buenos Aires, Argentina                          8°C with winds at 24 km/h SSW
> 
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: [jira] Commented: (MPXDOC-154) system locale setting makes test cases fail.

Posted by "Juan F. Codagnone" <ju...@users.sourceforge.net>.
On Thursday 01 September 2005 21:25, Lukas Theussl wrote:
...
> Can you guys confirm that this still works for you?

yeap, that fixes the problem. The other solution that works, is telling the 
compiler that these java classes are written en latin1:

Index: project.properties
===================================================================
--- project.properties  (revision 266297)
+++ project.properties  (working copy)
@@ -18,3 +18,4 @@
 # P R O J E C T  P R O P E R T I E S
 # -------------------------------------------------------------------
 maven.junit.fork=yes
+maven.compile.encoding=ISO-8859-1


Regards,
     Juan.

pd. first post!

-- 
Buenos Aires, Argentina                          8°C with winds at 24 km/h SSW

Re: [jira] Commented: (MPXDOC-154) system locale setting makes test

Posted by "Henning P. Schmiedehausen" <hp...@intermeta.de>.
Lukas Theussl <th...@triumf.ca> writes:

>    String expect = "Fran�ais";

IMHO you are barking at the wrong tree.

As long as you have non-US-ASCII characters in the Java source code,
all bets are off. The compiler interprets the contents of the source
file according to its own language preferences. man javac(1), look for
"-encoding".

Just work around this by adding

maven.compile.encoding = ISO-8859-1

to the project.properties. Trying to second guess the platform
encoding will lead you nowhere.

Without this line, the tests still fail. Using UTF-8 locale, Java tries
to interpret the c-cedille as Unicode and the match fails.

You will still put a "gotcha" in. If someone opens the source code
file with an unicode based editor, the character will be unreadable
and if he changes it to a correct UTF-8 c-cedille (can you spell
emacs?), then the tests will fail _again_. So replace the c-cedille
with a \xxx sequence. Can't tell you the right value from the top of
my head, though.

This is what we got for not making UTF-8 compatible to ISO-8859-1. 

	Regards
		Henning

>    String result = LocaleUtil.displayName(locale, locale);
>    try { // Convert from Unicode to UTF-8
>        String string = "Fran\u00e7ais";
>        byte[] utf8 = string.getBytes("UTF-8");
>        expect = new String(utf8, "UTF-8");
>    } catch (UnsupportedEncodingException e) {
>    }
>    assertEquals(result, expect);
>  }

>Can you guys confirm that this still works for you?

>- Lukas

>---------------------------------------------------------------------
>To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
>For additional commands, e-mail: dev-help@maven.apache.org

-- 
Dipl.-Inf. (Univ.) Henning P. Schmiedehausen          INTERMETA GmbH
hps@intermeta.de        +49 9131 50 654 0   http://www.intermeta.de/

RedHat Certified Engineer -- Jakarta Turbine Development  -- hero for hire
   Linux, Java, perl, Solaris -- Consulting, Training, Development

		      4 - 8 - 15 - 16 - 23 - 42

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: [jira] Commented: (MPXDOC-154) system locale setting makes test cases fail.

Posted by Lukas Theussl <th...@triumf.ca>.
I seem to have solved the problem by replacing the cedilla by its 
unicode representation. Here's the testDisplayName() method in 
LocaleUtilTest.java:

  public void testDisplayName() {
    Locale locale = new Locale("fr");
    String expect = "Français";
    String result = LocaleUtil.displayName(locale, locale);
    try { // Convert from Unicode to UTF-8
        String string = "Fran\u00e7ais";
        byte[] utf8 = string.getBytes("UTF-8");
        expect = new String(utf8, "UTF-8");
    } catch (UnsupportedEncodingException e) {
    }
    assertEquals(result, expect);
  }

Can you guys confirm that this still works for you?

- Lukas

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: [jira] Commented: (MPXDOC-154) system locale setting makes test cases fail.

Posted by Lukas Theussl <th...@triumf.ca>.
You mean you can't reproduce Henning's original case either? I just 
tried again, the problem is still the same. Which locale are you in, en_US?

The problem comes from the testDisplayName() method in 
LocaleUtilTest.java. The cedilla in "Français" is sometimes correct and 
sometimes not.
Maybe an OS issue or a Java issue?

- Lukas

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org