|
I am having trouble understanding a mystery.
I have code that checks my .properties file to make sure that it has not been corrupted after being edited by a non UTF-8 editor. In particular I have a property called lambda = λ and I check to see that it actually does resolve to the correct character. If I run my code from main (my manual unit test) it works. If I run my test from JUnit in Eclipse, it works. But when the same test runs under Maven it fails because lambda = ? When I look in the actual properties file that the test runs with, lambda = λ, but somehow when the code runs it gets lambda = ?. I thought this was maybe a surefire configuration problems so I am using <pluginManagement> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.9</version> <configuration> <junitArtifactName>junit:junit</junitArtifactName> <encoding>UTF-8</encoding> <inputEncoding>UTF-8</inputEncoding> <outputEncoding>UTF-8</outputEncoding> <argLine>-Xms256m -Xmx512m -XX:MaxPermSize=128m -ea</argLine> </configuration> </plugin> </plugins> </pluginManagement> but this makes no difference. Does anyone have any idea why my JUnit test fails running under surefire, but not running under Eclipse? Cheers, Eric --------------------------------------------------------------------- To unsubscribe, e-mail: [hidden email] For additional commands, e-mail: [hidden email] |
|
Where is your .properties file located and what type of encoding do you have
in your POM for sources/resources ? Regards Jeff MAURY On Tue, Oct 11, 2011 at 12:04 AM, Eric Kolotyluk <[hidden email]>wrote: > I am having trouble understanding a mystery. > > I have code that checks my .properties file to make sure that it has not > been corrupted after being edited by a non UTF-8 editor. In particular I > have a property called lambda = λ and I check to see that it actually does > resolve to the correct character. > > If I run my code from main (my manual unit test) it works. If I run my test > from JUnit in Eclipse, it works. But when the same test runs under Maven it > fails because lambda = ? > > When I look in the actual properties file that the test runs with, lambda = > λ, but somehow when the code runs it gets lambda = ?. > > I thought this was maybe a surefire configuration problems so I am using > > <pluginManagement> > <plugins> > <plugin> > <groupId>org.apache.maven.**plugins</groupId> > <artifactId>maven-surefire-**plugin</artifactId> > <version>2.9</version> > <configuration> > <junitArtifactName>junit:**junit</junitArtifactName> > <encoding>UTF-8</encoding> > <inputEncoding>UTF-8</**inputEncoding> > <outputEncoding>UTF-8</**outputEncoding> > <argLine>-Xms256m -Xmx512m -XX:MaxPermSize=128m -ea</argLine> > </configuration> > </plugin> > </plugins> > </pluginManagement> > > but this makes no difference. Does anyone have any idea why my JUnit test > fails running under surefire, but not running under Eclipse? > > Cheers, Eric > > ------------------------------**------------------------------**--------- > To unsubscribe, e-mail: users-unsubscribe@maven.**apache.org<[hidden email]> > For additional commands, e-mail: [hidden email] > > -- "Legacy code" often differs from its suggested alternative by actually working and scaling. - Bjarne Stroustrup http://www.jeffmaury.com http://riadiscuss.jeffmaury.com http://www.twitter.com/jeffmaury |
|
My .properties file is located in the root of target/classes directory.
You mean as in <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.resourceEncoding>UTF-8</project.build.resourceEncoding> </properties> in my parent POM? Cheers, Eric On 2011-10-10 3:10 PM, Jeff MAURY wrote: > Where is your .properties file located and what type of encoding do you have > in your POM for sources/resources ? > > Regards > Jeff MAURY > > On Tue, Oct 11, 2011 at 12:04 AM, Eric Kolotyluk > <[hidden email]>wrote: > >> I am having trouble understanding a mystery. >> >> I have code that checks my .properties file to make sure that it has not >> been corrupted after being edited by a non UTF-8 editor. In particular I >> have a property called lambda = λ and I check to see that it actually does >> resolve to the correct character. >> >> If I run my code from main (my manual unit test) it works. If I run my test >> from JUnit in Eclipse, it works. But when the same test runs under Maven it >> fails because lambda = ? >> >> When I look in the actual properties file that the test runs with, lambda = >> λ, but somehow when the code runs it gets lambda = ?. >> >> I thought this was maybe a surefire configuration problems so I am using >> >> <pluginManagement> >> <plugins> >> <plugin> >> <groupId>org.apache.maven.**plugins</groupId> >> <artifactId>maven-surefire-**plugin</artifactId> >> <version>2.9</version> >> <configuration> >> <junitArtifactName>junit:**junit</junitArtifactName> >> <encoding>UTF-8</encoding> >> <inputEncoding>UTF-8</**inputEncoding> >> <outputEncoding>UTF-8</**outputEncoding> >> <argLine>-Xms256m -Xmx512m -XX:MaxPermSize=128m -ea</argLine> >> </configuration> >> </plugin> >> </plugins> >> </pluginManagement> >> >> but this makes no difference. Does anyone have any idea why my JUnit test >> fails running under surefire, but not running under Eclipse? >> >> Cheers, Eric >> >> ------------------------------**------------------------------**--------- >> To unsubscribe, e-mail: users-unsubscribe@maven.**apache.org<[hidden email]> >> For additional commands, e-mail: [hidden email] >> >> > --------------------------------------------------------------------- To unsubscribe, e-mail: [hidden email] For additional commands, e-mail: [hidden email] |
|
In reply to this post by Eric Kolotyluk
Eric Kolotyluk wrote:
> I am having trouble understanding a mystery. > > I have code that checks my .properties file to make sure that it has not > been corrupted after being edited by a non UTF-8 editor. In particular I > have a property called lambda = λ and I check to see that it actually > does resolve to the correct character. > > If I run my code from main (my manual unit test) it works. If I run my > test from JUnit in Eclipse, it works. But when the same test runs under > Maven it fails because lambda = ? > > When I look in the actual properties file that the test runs with, > lambda = λ, but somehow when the code runs it gets lambda = ?. > > I thought this was maybe a surefire configuration problems so I am using > > <pluginManagement> > <plugins> > <plugin> > <groupId>org.apache.maven.plugins</groupId> > <artifactId>maven-surefire-plugin</artifactId> > <version>2.9</version> > <configuration> > <junitArtifactName>junit:junit</junitArtifactName> > <encoding>UTF-8</encoding> > <inputEncoding>UTF-8</inputEncoding> > <outputEncoding>UTF-8</outputEncoding> > <argLine>-Xms256m -Xmx512m -XX:MaxPermSize=128m -ea</argLine> > </configuration> > </plugin> > </plugins> > </pluginManagement> > > but this makes no difference. Does anyone have any idea why my JUnit > test fails running under surefire, but not running under Eclipse? .properties files are supposed to be ISO-8859-1: http://download.oracle.com/javase/7/docs/api/java/util/Properties.html#load(java.io.InputStream) - Jörg --------------------------------------------------------------------- To unsubscribe, e-mail: [hidden email] For additional commands, e-mail: [hidden email] |
|
In reply to this post by Eric Kolotyluk
How are you reading in your properties files? By default, latin-1 is
assumed. Configure your surefire JVM to read files as UTF-8 with: <argLine>-Xms256m -Xmx512m -XX:MaxPermSize=128m -ea -Dfile.encoding=UTF-8</argLine> Kalle On Mon, Oct 10, 2011 at 3:04 PM, Eric Kolotyluk <[hidden email]> wrote: > I am having trouble understanding a mystery. > > I have code that checks my .properties file to make sure that it has not > been corrupted after being edited by a non UTF-8 editor. In particular I > have a property called lambda = λ and I check to see that it actually does > resolve to the correct character. > > If I run my code from main (my manual unit test) it works. If I run my test > from JUnit in Eclipse, it works. But when the same test runs under Maven it > fails because lambda = ? > > When I look in the actual properties file that the test runs with, lambda = > λ, but somehow when the code runs it gets lambda = ?. > > I thought this was maybe a surefire configuration problems so I am using > > <pluginManagement> > <plugins> > <plugin> > <groupId>org.apache.maven.plugins</groupId> > <artifactId>maven-surefire-plugin</artifactId> > <version>2.9</version> > <configuration> > <junitArtifactName>junit:junit</junitArtifactName> > <encoding>UTF-8</encoding> > <inputEncoding>UTF-8</inputEncoding> > <outputEncoding>UTF-8</outputEncoding> > <argLine>-Xms256m -Xmx512m -XX:MaxPermSize=128m -ea</argLine> > </configuration> > </plugin> > </plugins> > </pluginManagement> > > but this makes no difference. Does anyone have any idea why my JUnit test > fails running under surefire, but not running under Eclipse? > > Cheers, Eric > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [hidden email] > For additional commands, e-mail: [hidden email] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [hidden email] For additional commands, e-mail: [hidden email] |
|
In reply to this post by Jörg Schaible
On 2011-10-10 3:56 PM, Jörg Schaible wrote:
> Eric Kolotyluk wrote: > >> I am having trouble understanding a mystery. >> >> I have code that checks my .properties file to make sure that it has not >> been corrupted after being edited by a non UTF-8 editor. In particular I >> have a property called lambda = λ and I check to see that it actually >> does resolve to the correct character. >> >> If I run my code from main (my manual unit test) it works. If I run my >> test from JUnit in Eclipse, it works. But when the same test runs under >> Maven it fails because lambda = ? >> >> When I look in the actual properties file that the test runs with, >> lambda = λ, but somehow when the code runs it gets lambda = ?. >> >> I thought this was maybe a surefire configuration problems so I am using >> >> <pluginManagement> >> <plugins> >> <plugin> >> <groupId>org.apache.maven.plugins</groupId> >> <artifactId>maven-surefire-plugin</artifactId> >> <version>2.9</version> >> <configuration> >> <junitArtifactName>junit:junit</junitArtifactName> >> <encoding>UTF-8</encoding> >> <inputEncoding>UTF-8</inputEncoding> >> <outputEncoding>UTF-8</outputEncoding> >> <argLine>-Xms256m -Xmx512m -XX:MaxPermSize=128m -ea</argLine> >> </configuration> >> </plugin> >> </plugins> >> </pluginManagement> >> >> but this makes no difference. Does anyone have any idea why my JUnit >> test fails running under surefire, but not running under Eclipse? > .properties files are supposed to be ISO-8859-1: > http://download.oracle.com/javase/7/docs/api/java/util/Properties.html#load(java.io.InputStream) > > - Jörg Properties#load(Reader reader) in Java 6, so you could set up a UTF-8 reader for a stream. I have been using UTF-8 without problems until I ran my tests under surefire. Cheers, Eric > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [hidden email] > For additional commands, e-mail: [hidden email] > --------------------------------------------------------------------- To unsubscribe, e-mail: [hidden email] For additional commands, e-mail: [hidden email] |
|
In reply to this post by kaosko
Awesome Kalle - thanks.
Where should I send the case of beer? Cheers, Eric On 2011-10-10 4:00 PM, Kalle Korhonen wrote: > How are you reading in your properties files? By default, latin-1 is > assumed. Configure your surefire JVM to read files as UTF-8 with: > <argLine>-Xms256m -Xmx512m -XX:MaxPermSize=128m -ea > -Dfile.encoding=UTF-8</argLine> > > Kalle > > > On Mon, Oct 10, 2011 at 3:04 PM, Eric Kolotyluk > <[hidden email]> wrote: >> I am having trouble understanding a mystery. >> >> I have code that checks my .properties file to make sure that it has not >> been corrupted after being edited by a non UTF-8 editor. In particular I >> have a property called lambda = λ and I check to see that it actually does >> resolve to the correct character. >> >> If I run my code from main (my manual unit test) it works. If I run my test >> from JUnit in Eclipse, it works. But when the same test runs under Maven it >> fails because lambda = ? >> >> When I look in the actual properties file that the test runs with, lambda = >> λ, but somehow when the code runs it gets lambda = ?. >> >> I thought this was maybe a surefire configuration problems so I am using >> >> <pluginManagement> >> <plugins> >> <plugin> >> <groupId>org.apache.maven.plugins</groupId> >> <artifactId>maven-surefire-plugin</artifactId> >> <version>2.9</version> >> <configuration> >> <junitArtifactName>junit:junit</junitArtifactName> >> <encoding>UTF-8</encoding> >> <inputEncoding>UTF-8</inputEncoding> >> <outputEncoding>UTF-8</outputEncoding> >> <argLine>-Xms256m -Xmx512m -XX:MaxPermSize=128m -ea</argLine> >> </configuration> >> </plugin> >> </plugins> >> </pluginManagement> >> >> but this makes no difference. Does anyone have any idea why my JUnit test >> fails running under surefire, but not running under Eclipse? >> >> Cheers, Eric >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [hidden email] >> For additional commands, e-mail: [hidden email] >> >> > --------------------------------------------------------------------- > To unsubscribe, e-mail: [hidden email] > For additional commands, e-mail: [hidden email] > --------------------------------------------------------------------- To unsubscribe, e-mail: [hidden email] For additional commands, e-mail: [hidden email] |
|
A whole case? I *love* inflation.
Kalle 2011/10/10 Eric Kolotyluk <[hidden email]>: > Awesome Kalle - thanks. > > Where should I send the case of beer? > > Cheers, Eric > > On 2011-10-10 4:00 PM, Kalle Korhonen wrote: >> >> How are you reading in your properties files? By default, latin-1 is >> assumed. Configure your surefire JVM to read files as UTF-8 with: >> <argLine>-Xms256m -Xmx512m -XX:MaxPermSize=128m -ea >> -Dfile.encoding=UTF-8</argLine> >> >> Kalle >> >> >> On Mon, Oct 10, 2011 at 3:04 PM, Eric Kolotyluk >> <[hidden email]> wrote: >>> >>> I am having trouble understanding a mystery. >>> >>> I have code that checks my .properties file to make sure that it has not >>> been corrupted after being edited by a non UTF-8 editor. In particular I >>> have a property called lambda = λ and I check to see that it actually >>> does >>> resolve to the correct character. >>> >>> If I run my code from main (my manual unit test) it works. If I run my >>> test >>> from JUnit in Eclipse, it works. But when the same test runs under Maven >>> it >>> fails because lambda = ? >>> >>> When I look in the actual properties file that the test runs with, lambda >>> = >>> λ, but somehow when the code runs it gets lambda = ?. >>> >>> I thought this was maybe a surefire configuration problems so I am using >>> >>> <pluginManagement> >>> <plugins> >>> <plugin> >>> <groupId>org.apache.maven.plugins</groupId> >>> <artifactId>maven-surefire-plugin</artifactId> >>> <version>2.9</version> >>> <configuration> >>> <junitArtifactName>junit:junit</junitArtifactName> >>> <encoding>UTF-8</encoding> >>> <inputEncoding>UTF-8</inputEncoding> >>> <outputEncoding>UTF-8</outputEncoding> >>> <argLine>-Xms256m -Xmx512m -XX:MaxPermSize=128m -ea</argLine> >>> </configuration> >>> </plugin> >>> </plugins> >>> </pluginManagement> >>> >>> but this makes no difference. Does anyone have any idea why my JUnit test >>> fails running under surefire, but not running under Eclipse? >>> >>> Cheers, Eric >>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: [hidden email] >>> For additional commands, e-mail: [hidden email] >>> >>> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [hidden email] >> For additional commands, e-mail: [hidden email] >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [hidden email] > For additional commands, e-mail: [hidden email] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [hidden email] For additional commands, e-mail: [hidden email] |
|
Actually - that helped - but it's not a stable solution. For some reason
the tests pass when run from m2e, but fail when run from the command line. I'm still trying to figure out what the difference is. Cheers, Eric On 2011-10-10 4:41 PM, Kalle Korhonen wrote: > A whole case? I *love* inflation. > > Kalle > > > 2011/10/10 Eric Kolotyluk<[hidden email]>: >> Awesome Kalle - thanks. >> >> Where should I send the case of beer? >> >> Cheers, Eric >> >> On 2011-10-10 4:00 PM, Kalle Korhonen wrote: >>> How are you reading in your properties files? By default, latin-1 is >>> assumed. Configure your surefire JVM to read files as UTF-8 with: >>> <argLine>-Xms256m -Xmx512m -XX:MaxPermSize=128m -ea >>> -Dfile.encoding=UTF-8</argLine> >>> >>> Kalle >>> >>> >>> On Mon, Oct 10, 2011 at 3:04 PM, Eric Kolotyluk >>> <[hidden email]> wrote: >>>> I am having trouble understanding a mystery. >>>> >>>> I have code that checks my .properties file to make sure that it has not >>>> been corrupted after being edited by a non UTF-8 editor. In particular I >>>> have a property called lambda = λ and I check to see that it actually >>>> does >>>> resolve to the correct character. >>>> >>>> If I run my code from main (my manual unit test) it works. If I run my >>>> test >>>> from JUnit in Eclipse, it works. But when the same test runs under Maven >>>> it >>>> fails because lambda = ? >>>> >>>> When I look in the actual properties file that the test runs with, lambda >>>> = >>>> λ, but somehow when the code runs it gets lambda = ?. >>>> >>>> I thought this was maybe a surefire configuration problems so I am using >>>> >>>> <pluginManagement> >>>> <plugins> >>>> <plugin> >>>> <groupId>org.apache.maven.plugins</groupId> >>>> <artifactId>maven-surefire-plugin</artifactId> >>>> <version>2.9</version> >>>> <configuration> >>>> <junitArtifactName>junit:junit</junitArtifactName> >>>> <encoding>UTF-8</encoding> >>>> <inputEncoding>UTF-8</inputEncoding> >>>> <outputEncoding>UTF-8</outputEncoding> >>>> <argLine>-Xms256m -Xmx512m -XX:MaxPermSize=128m -ea</argLine> >>>> </configuration> >>>> </plugin> >>>> </plugins> >>>> </pluginManagement> >>>> >>>> but this makes no difference. Does anyone have any idea why my JUnit test >>>> fails running under surefire, but not running under Eclipse? >>>> >>>> Cheers, Eric >>>> >>>> --------------------------------------------------------------------- >>>> To unsubscribe, e-mail: [hidden email] >>>> For additional commands, e-mail: [hidden email] >>>> >>>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: [hidden email] >>> For additional commands, e-mail: [hidden email] >>> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [hidden email] >> For additional commands, e-mail: [hidden email] >> >> > --------------------------------------------------------------------- > To unsubscribe, e-mail: [hidden email] > For additional commands, e-mail: [hidden email] > --------------------------------------------------------------------- To unsubscribe, e-mail: [hidden email] For additional commands, e-mail: [hidden email] |
|
Different forkMode perhaps?
http://maven.apache.org/plugins/maven-surefire-plugin/test-mojo.html#forkMode, e.g: <forkMode>once</forkMode> Just send the whole keg while you are at it :) Kalle 2011/10/10 Eric Kolotyluk <[hidden email]>: > Actually - that helped - but it's not a stable solution. For some reason the > tests pass when run from m2e, but fail when run from the command line. I'm > still trying to figure out what the difference is. > > Cheers, Eric > > On 2011-10-10 4:41 PM, Kalle Korhonen wrote: >> >> A whole case? I *love* inflation. >> >> Kalle >> >> >> 2011/10/10 Eric Kolotyluk<[hidden email]>: >>> >>> Awesome Kalle - thanks. >>> >>> Where should I send the case of beer? >>> >>> Cheers, Eric >>> >>> On 2011-10-10 4:00 PM, Kalle Korhonen wrote: >>>> >>>> How are you reading in your properties files? By default, latin-1 is >>>> assumed. Configure your surefire JVM to read files as UTF-8 with: >>>> <argLine>-Xms256m -Xmx512m -XX:MaxPermSize=128m -ea >>>> -Dfile.encoding=UTF-8</argLine> >>>> >>>> Kalle >>>> >>>> >>>> On Mon, Oct 10, 2011 at 3:04 PM, Eric Kolotyluk >>>> <[hidden email]> wrote: >>>>> >>>>> I am having trouble understanding a mystery. >>>>> >>>>> I have code that checks my .properties file to make sure that it has >>>>> not >>>>> been corrupted after being edited by a non UTF-8 editor. In particular >>>>> I >>>>> have a property called lambda = λ and I check to see that it actually >>>>> does >>>>> resolve to the correct character. >>>>> >>>>> If I run my code from main (my manual unit test) it works. If I run my >>>>> test >>>>> from JUnit in Eclipse, it works. But when the same test runs under >>>>> Maven >>>>> it >>>>> fails because lambda = ? >>>>> >>>>> When I look in the actual properties file that the test runs with, >>>>> lambda >>>>> = >>>>> λ, but somehow when the code runs it gets lambda = ?. >>>>> >>>>> I thought this was maybe a surefire configuration problems so I am >>>>> using >>>>> >>>>> <pluginManagement> >>>>> <plugins> >>>>> <plugin> >>>>> <groupId>org.apache.maven.plugins</groupId> >>>>> <artifactId>maven-surefire-plugin</artifactId> >>>>> <version>2.9</version> >>>>> <configuration> >>>>> <junitArtifactName>junit:junit</junitArtifactName> >>>>> <encoding>UTF-8</encoding> >>>>> <inputEncoding>UTF-8</inputEncoding> >>>>> <outputEncoding>UTF-8</outputEncoding> >>>>> <argLine>-Xms256m -Xmx512m -XX:MaxPermSize=128m -ea</argLine> >>>>> </configuration> >>>>> </plugin> >>>>> </plugins> >>>>> </pluginManagement> >>>>> >>>>> but this makes no difference. Does anyone have any idea why my JUnit >>>>> test >>>>> fails running under surefire, but not running under Eclipse? >>>>> >>>>> Cheers, Eric >>>>> >>>>> --------------------------------------------------------------------- >>>>> To unsubscribe, e-mail: [hidden email] >>>>> For additional commands, e-mail: [hidden email] >>>>> >>>>> >>>> --------------------------------------------------------------------- >>>> To unsubscribe, e-mail: [hidden email] >>>> For additional commands, e-mail: [hidden email] >>>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: [hidden email] >>> For additional commands, e-mail: [hidden email] >>> >>> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [hidden email] >> For additional commands, e-mail: [hidden email] >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [hidden email] > For additional commands, e-mail: [hidden email] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [hidden email] For additional commands, e-mail: [hidden email] |
|
<forkMode>once</forkMode>
Doesn't help. I have some new insight on the problem. I changed my code to if (lambda.length() == 1) { char λ = lambda.charAt(0); if (λ != 'λ') //if (!lambda.equals("λ")) { // UTF-8 sanity check failed! println(System.err, "lambda = '" + lambda + "'"); String message = "UTF-8 encoding problem for " + propertiesResource; println(System.err, message); throw new PropertiesError(message); } } This code works when built in Eclipse, but fails to compile from the command line with [INFO] Compiling 30 source files to P:\Intersystem\main\platform.Java\intersystem-common\target\classes [INFO] ------------------------------------------------------------- [ERROR] COMPILATION ERROR : [INFO] ------------------------------------------------------------- [ERROR] /Intersystem/main/platform.Java/intersystem-common/src/main/java/com/kodak/intersystem/common/Properties.java:[354,38] illegal character: \187 [ERROR] /Intersystem/main/platform.Java/intersystem-common/src/main/java/com/kodak/intersystem/common/Properties.java:[355,37] illegal character: \187 [ERROR] /Intersystem/main/platform.Java/intersystem-common/src/main/java/com/kodak/intersystem/common/Properties.java:[355,42] unclosed character literal [ERROR] /Intersystem/main/platform.Java/intersystem-common/src/main/java/com/kodak/intersystem/common/Properties.java:[355,44] illegal character: \187 [ERROR] /Intersystem/main/platform.Java/intersystem-common/src/main/java/com/kodak/intersystem/common/Properties.java:[355,45] unclosed character literal [ERROR] /Intersystem/main/platform.Java/intersystem-common/src/main/java/com/kodak/intersystem/common/Properties.java:[364,24] illegal start of expression [INFO] 6 errors [INFO] ------------------------------------------------------------- [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE I can't figure out why the compiler is failing because I can clearly see [DEBUG] (f) encoding = UTF-8 in the Maven output just before the errors. Anyone have any ideas? Is there some other compiler option I am missing? Cheers, Eric On 2011-10-10 5:23 PM, Kalle Korhonen wrote: > Different forkMode perhaps? > http://maven.apache.org/plugins/maven-surefire-plugin/test-mojo.html#forkMode, > e.g: > <forkMode>once</forkMode> > > Just send the whole keg while you are at it :) > > Kalle > > > 2011/10/10 Eric Kolotyluk<[hidden email]>: >> Actually - that helped - but it's not a stable solution. For some reason the >> tests pass when run from m2e, but fail when run from the command line. I'm >> still trying to figure out what the difference is. >> >> Cheers, Eric >> >> On 2011-10-10 4:41 PM, Kalle Korhonen wrote: >>> A whole case? I *love* inflation. >>> >>> Kalle >>> >>> >>> 2011/10/10 Eric Kolotyluk<[hidden email]>: >>>> Awesome Kalle - thanks. >>>> >>>> Where should I send the case of beer? >>>> >>>> Cheers, Eric >>>> >>>> On 2011-10-10 4:00 PM, Kalle Korhonen wrote: >>>>> How are you reading in your properties files? By default, latin-1 is >>>>> assumed. Configure your surefire JVM to read files as UTF-8 with: >>>>> <argLine>-Xms256m -Xmx512m -XX:MaxPermSize=128m -ea >>>>> -Dfile.encoding=UTF-8</argLine> >>>>> >>>>> Kalle >>>>> >>>>> >>>>> On Mon, Oct 10, 2011 at 3:04 PM, Eric Kolotyluk >>>>> <[hidden email]> wrote: >>>>>> I am having trouble understanding a mystery. >>>>>> >>>>>> I have code that checks my .properties file to make sure that it has >>>>>> not >>>>>> been corrupted after being edited by a non UTF-8 editor. In particular >>>>>> I >>>>>> have a property called lambda = λ and I check to see that it actually >>>>>> does >>>>>> resolve to the correct character. >>>>>> >>>>>> If I run my code from main (my manual unit test) it works. If I run my >>>>>> test >>>>>> from JUnit in Eclipse, it works. But when the same test runs under >>>>>> Maven >>>>>> it >>>>>> fails because lambda = ? >>>>>> >>>>>> When I look in the actual properties file that the test runs with, >>>>>> lambda >>>>>> = >>>>>> λ, but somehow when the code runs it gets lambda = ?. >>>>>> >>>>>> I thought this was maybe a surefire configuration problems so I am >>>>>> using >>>>>> >>>>>> <pluginManagement> >>>>>> <plugins> >>>>>> <plugin> >>>>>> <groupId>org.apache.maven.plugins</groupId> >>>>>> <artifactId>maven-surefire-plugin</artifactId> >>>>>> <version>2.9</version> >>>>>> <configuration> >>>>>> <junitArtifactName>junit:junit</junitArtifactName> >>>>>> <encoding>UTF-8</encoding> >>>>>> <inputEncoding>UTF-8</inputEncoding> >>>>>> <outputEncoding>UTF-8</outputEncoding> >>>>>> <argLine>-Xms256m -Xmx512m -XX:MaxPermSize=128m -ea</argLine> >>>>>> </configuration> >>>>>> </plugin> >>>>>> </plugins> >>>>>> </pluginManagement> >>>>>> >>>>>> but this makes no difference. Does anyone have any idea why my JUnit >>>>>> test >>>>>> fails running under surefire, but not running under Eclipse? >>>>>> >>>>>> Cheers, Eric >>>>>> >>>>>> --------------------------------------------------------------------- >>>>>> To unsubscribe, e-mail: [hidden email] >>>>>> For additional commands, e-mail: [hidden email] >>>>>> >>>>>> >>>>> --------------------------------------------------------------------- >>>>> To unsubscribe, e-mail: [hidden email] >>>>> For additional commands, e-mail: [hidden email] >>>>> >>>> --------------------------------------------------------------------- >>>> To unsubscribe, e-mail: [hidden email] >>>> For additional commands, e-mail: [hidden email] >>>> >>>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: [hidden email] >>> For additional commands, e-mail: [hidden email] >>> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [hidden email] >> For additional commands, e-mail: [hidden email] >> >> > --------------------------------------------------------------------- > To unsubscribe, e-mail: [hidden email] > For additional commands, e-mail: [hidden email] > --------------------------------------------------------------------- To unsubscribe, e-mail: [hidden email] For additional commands, e-mail: [hidden email] |
|
Eric,
A couple of points: 1: Javac has an option to control the input encoding of java source files. There's a corresponding configuration option for the maven-compiler-plugin. 2: Adding -Dfile.encoding=utf-8 to MAVEN_OPTS will cause maven, and any other piece of java it launches, to use UTF-8 as the default encoding. If surefire is forking you'll have to add this to the systemPropertyValues. 2011/10/10 Eric Kolotyluk <[hidden email]>: > <forkMode>once</forkMode> > > Doesn't help. > > I have some new insight on the problem. I changed my code to > > if (lambda.length() == 1) > { > char λ = lambda.charAt(0); > if (λ != 'λ') > //if (!lambda.equals("λ")) > { > // UTF-8 sanity check failed! > println(System.err, "lambda = '" + lambda + "'"); > String message = "UTF-8 encoding problem for " + > propertiesResource; > println(System.err, message); > throw new PropertiesError(message); > } > } > > This code works when built in Eclipse, but fails to compile from the command > line with > > [INFO] Compiling 30 source files to > P:\Intersystem\main\platform.Java\intersystem-common\target\classes > [INFO] ------------------------------------------------------------- > [ERROR] COMPILATION ERROR : > [INFO] ------------------------------------------------------------- > [ERROR] > /Intersystem/main/platform.Java/intersystem-common/src/main/java/com/kodak/intersystem/common/Properties.java:[354,38] > illegal character: \187 > [ERROR] > /Intersystem/main/platform.Java/intersystem-common/src/main/java/com/kodak/intersystem/common/Properties.java:[355,37] > illegal character: \187 > [ERROR] > /Intersystem/main/platform.Java/intersystem-common/src/main/java/com/kodak/intersystem/common/Properties.java:[355,42] > unclosed character literal > [ERROR] > /Intersystem/main/platform.Java/intersystem-common/src/main/java/com/kodak/intersystem/common/Properties.java:[355,44] > illegal character: \187 > [ERROR] > /Intersystem/main/platform.Java/intersystem-common/src/main/java/com/kodak/intersystem/common/Properties.java:[355,45] > unclosed character literal > [ERROR] > /Intersystem/main/platform.Java/intersystem-common/src/main/java/com/kodak/intersystem/common/Properties.java:[364,24] > illegal start of expression > [INFO] 6 errors > [INFO] ------------------------------------------------------------- > [INFO] > ------------------------------------------------------------------------ > [INFO] BUILD FAILURE > > I can't figure out why the compiler is failing because I can clearly see > > [DEBUG] (f) encoding = UTF-8 > > in the Maven output just before the errors. > > Anyone have any ideas? Is there some other compiler option I am missing? > > Cheers, Eric > > On 2011-10-10 5:23 PM, Kalle Korhonen wrote: >> >> Different forkMode perhaps? >> >> http://maven.apache.org/plugins/maven-surefire-plugin/test-mojo.html#forkMode, >> e.g: >> <forkMode>once</forkMode> >> >> Just send the whole keg while you are at it :) >> >> Kalle >> >> >> 2011/10/10 Eric Kolotyluk<[hidden email]>: >>> >>> Actually - that helped - but it's not a stable solution. For some reason >>> the >>> tests pass when run from m2e, but fail when run from the command line. >>> I'm >>> still trying to figure out what the difference is. >>> >>> Cheers, Eric >>> >>> On 2011-10-10 4:41 PM, Kalle Korhonen wrote: >>>> >>>> A whole case? I *love* inflation. >>>> >>>> Kalle >>>> >>>> >>>> 2011/10/10 Eric Kolotyluk<[hidden email]>: >>>>> >>>>> Awesome Kalle - thanks. >>>>> >>>>> Where should I send the case of beer? >>>>> >>>>> Cheers, Eric >>>>> >>>>> On 2011-10-10 4:00 PM, Kalle Korhonen wrote: >>>>>> >>>>>> How are you reading in your properties files? By default, latin-1 is >>>>>> assumed. Configure your surefire JVM to read files as UTF-8 with: >>>>>> <argLine>-Xms256m -Xmx512m -XX:MaxPermSize=128m -ea >>>>>> -Dfile.encoding=UTF-8</argLine> >>>>>> >>>>>> Kalle >>>>>> >>>>>> >>>>>> On Mon, Oct 10, 2011 at 3:04 PM, Eric Kolotyluk >>>>>> <[hidden email]> wrote: >>>>>>> >>>>>>> I am having trouble understanding a mystery. >>>>>>> >>>>>>> I have code that checks my .properties file to make sure that it has >>>>>>> not >>>>>>> been corrupted after being edited by a non UTF-8 editor. In >>>>>>> particular >>>>>>> I >>>>>>> have a property called lambda = λ and I check to see that it actually >>>>>>> does >>>>>>> resolve to the correct character. >>>>>>> >>>>>>> If I run my code from main (my manual unit test) it works. If I run >>>>>>> my >>>>>>> test >>>>>>> from JUnit in Eclipse, it works. But when the same test runs under >>>>>>> Maven >>>>>>> it >>>>>>> fails because lambda = ? >>>>>>> >>>>>>> When I look in the actual properties file that the test runs with, >>>>>>> lambda >>>>>>> = >>>>>>> λ, but somehow when the code runs it gets lambda = ?. >>>>>>> >>>>>>> I thought this was maybe a surefire configuration problems so I am >>>>>>> using >>>>>>> >>>>>>> <pluginManagement> >>>>>>> <plugins> >>>>>>> <plugin> >>>>>>> <groupId>org.apache.maven.plugins</groupId> >>>>>>> <artifactId>maven-surefire-plugin</artifactId> >>>>>>> <version>2.9</version> >>>>>>> <configuration> >>>>>>> <junitArtifactName>junit:junit</junitArtifactName> >>>>>>> <encoding>UTF-8</encoding> >>>>>>> <inputEncoding>UTF-8</inputEncoding> >>>>>>> <outputEncoding>UTF-8</outputEncoding> >>>>>>> <argLine>-Xms256m -Xmx512m -XX:MaxPermSize=128m -ea</argLine> >>>>>>> </configuration> >>>>>>> </plugin> >>>>>>> </plugins> >>>>>>> </pluginManagement> >>>>>>> >>>>>>> but this makes no difference. Does anyone have any idea why my JUnit >>>>>>> test >>>>>>> fails running under surefire, but not running under Eclipse? >>>>>>> >>>>>>> Cheers, Eric >>>>>>> >>>>>>> --------------------------------------------------------------------- >>>>>>> To unsubscribe, e-mail: [hidden email] >>>>>>> For additional commands, e-mail: [hidden email] >>>>>>> >>>>>>> >>>>>> --------------------------------------------------------------------- >>>>>> To unsubscribe, e-mail: [hidden email] >>>>>> For additional commands, e-mail: [hidden email] >>>>>> >>>>> --------------------------------------------------------------------- >>>>> To unsubscribe, e-mail: [hidden email] >>>>> For additional commands, e-mail: [hidden email] >>>>> >>>>> >>>> --------------------------------------------------------------------- >>>> To unsubscribe, e-mail: [hidden email] >>>> For additional commands, e-mail: [hidden email] >>>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: [hidden email] >>> For additional commands, e-mail: [hidden email] >>> >>> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [hidden email] >> For additional commands, e-mail: [hidden email] >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [hidden email] > For additional commands, e-mail: [hidden email] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [hidden email] For additional commands, e-mail: [hidden email] |
|
In reply to this post by Eric Kolotyluk
Hi Erik,
> I am having trouble understanding a mystery. > > I have code that checks my .properties file to make sure that it has not > been corrupted after being edited by a non UTF-8 editor. In particular I > have a property called lambda = λ and I check to see that it actually > does resolve to the correct character. > > If I run my code from main (my manual unit test) it works. If I run my > test from JUnit in Eclipse, it works. But when the same test runs under > Maven it fails because lambda = ? I can understand your use case, and we have had similar problems in our department: Code was (is) built and tested locally on Windows PCs, but in production runs under AIX. From time to time we had problems with German umlauts because some guys hardcoded them in their Java code... The only solution that works cross-platform not only from within Java files, but also from property files is to replace non-ASCII-characters by their Unicode value. Example: before: String str = "Schließen"; // ^= "close" after: String str = ""Schlie\u00DFen"; Doesn't look as nice as before, right, and isn't directly readable, but prevents you from such troubles as you have. As I wrote, this also works for properties. HTH Thorsten |
|
In reply to this post by Eric Kolotyluk
Hi Erik,
> <forkMode>once</forkMode> > > Doesn't help. > > I have some new insight on the problem. I changed my code to > > if (lambda.length() == 1) > { > char λ = lambda.charAt(0); > if (λ != 'λ') > //if (!lambda.equals("λ")) > { > // UTF-8 sanity check failed! > println(System.err, "lambda = '" + lambda + "'"); > String message = "UTF-8 encoding problem for " + > propertiesResource; > println(System.err, message); > throw new PropertiesError(message); > } > } > > This code works when built in Eclipse, but fails to compile from the > command line with *snip* Can't you just use plain ASCII characters in your source code? This will prevent you from such mysterious behaviour. And, as I wrote in an earlier mail, replace non-ASCII-characters in strings by their Unicode value. In that case, if I have seen right, replace the lambda char by \u03BB (Unicode value of the Greek small letter lambda). Saves you a lot of time.... Regards Thorsten |
|
In reply to this post by Benson Margulies
suggest the extra step of set encoding="UTF-8" at top of applicable config files:<?xml version="1.0" encoding="UTF-8"?> yesterday i was able to find the cause of CXF WSDL2Java failure for ApacheCXF Wsdl2Java with JaxB mappinghttps://issues.apache.org/jira/browse/CXF-1463 <xs:complexType name="Benson_Marguiles"> <xs:element name="Benson" type="ns0:Benson"/> <xs:element name="Marguiles" type="ns0:Marguiles"/> </xs:sequence> </xs:complexType> $ApacheCXF_HOME\bin\wsdl2java BensonMarguiles.wsdl NullPointerException if i change complexType name to all lowercase wsdl2java produces correct code Axis-2.1.5+ ignores camelcase and creates packagenames with all lowercase e.g. benson_marguiles.Benson.java benson_marguiles.Marguiles.java Thanks,Martin Gainty ______________________________________________ All the smart people get off at Kendall Square..personal quote > Date: Mon, 10 Oct 2011 21:40:41 -0400 > Subject: Re: UTF-8 Test Mystery > From: [hidden email] > To: [hidden email] > > Eric, > > A couple of points: > > 1: Javac has an option to control the input encoding of java source > files. There's a corresponding configuration option for the > maven-compiler-plugin. > > 2: Adding -Dfile.encoding=utf-8 to MAVEN_OPTS will cause maven, and > any other piece of java it launches, to use UTF-8 as the default > encoding. If surefire is forking you'll have to add this to the > systemPropertyValues. > > > 2011/10/10 Eric Kolotyluk <[hidden email]>: > > <forkMode>once</forkMode> > > > > Doesn't help. > > > > I have some new insight on the problem. I changed my code to > > > > if (lambda.length() == 1) > > { > > char λ = lambda.charAt(0); > > if (λ != 'λ') > > //if (!lambda.equals("λ")) > > { > > // UTF-8 sanity check failed! > > println(System.err, "lambda = '" + lambda + "'"); > > String message = "UTF-8 encoding problem for " + > > propertiesResource; > > println(System.err, message); > > throw new PropertiesError(message); > > } > > } > > > > This code works when built in Eclipse, but fails to compile from the command > > line with > > > > [INFO] Compiling 30 source files to > > P:\Intersystem\main\platform.Java\intersystem-common\target\classes > > [INFO] ------------------------------------------------------------- > > [ERROR] COMPILATION ERROR : > > [INFO] ------------------------------------------------------------- > > [ERROR] > > /Intersystem/main/platform.Java/intersystem-common/src/main/java/com/kodak/intersystem/common/Properties.java:[354,38] > > illegal character: \187 > > [ERROR] > > /Intersystem/main/platform.Java/intersystem-common/src/main/java/com/kodak/intersystem/common/Properties.java:[355,37] > > illegal character: \187 > > [ERROR] > > /Intersystem/main/platform.Java/intersystem-common/src/main/java/com/kodak/intersystem/common/Properties.java:[355,42] > > unclosed character literal > > [ERROR] > > /Intersystem/main/platform.Java/intersystem-common/src/main/java/com/kodak/intersystem/common/Properties.java:[355,44] > > illegal character: \187 > > [ERROR] > > /Intersystem/main/platform.Java/intersystem-common/src/main/java/com/kodak/intersystem/common/Properties.java:[355,45] > > unclosed character literal > > [ERROR] > > /Intersystem/main/platform.Java/intersystem-common/src/main/java/com/kodak/intersystem/common/Properties.java:[364,24] > > illegal start of expression > > [INFO] 6 errors > > [INFO] ------------------------------------------------------------- > > [INFO] > > ------------------------------------------------------------------------ > > [INFO] BUILD FAILURE > > > > I can't figure out why the compiler is failing because I can clearly see > > > > [DEBUG] (f) encoding = UTF-8 > > > > in the Maven output just before the errors. > > > > Anyone have any ideas? Is there some other compiler option I am missing? > > > > Cheers, Eric > > > > On 2011-10-10 5:23 PM, Kalle Korhonen wrote: > >> > >> Different forkMode perhaps? > >> > >> http://maven.apache.org/plugins/maven-surefire-plugin/test-mojo.html#forkMode, > >> e.g: > >> <forkMode>once</forkMode> > >> > >> Just send the whole keg while you are at it :) > >> > >> Kalle > >> > >> > >> 2011/10/10 Eric Kolotyluk<[hidden email]>: > >>> > >>> Actually - that helped - but it's not a stable solution. For some reason > >>> the > >>> tests pass when run from m2e, but fail when run from the command line. > >>> I'm > >>> still trying to figure out what the difference is. > >>> > >>> Cheers, Eric > >>> > >>> On 2011-10-10 4:41 PM, Kalle Korhonen wrote: > >>>> > >>>> A whole case? I *love* inflation. > >>>> > >>>> Kalle > >>>> > >>>> > >>>> 2011/10/10 Eric Kolotyluk<[hidden email]>: > >>>>> > >>>>> Awesome Kalle - thanks. > >>>>> > >>>>> Where should I send the case of beer? > >>>>> > >>>>> Cheers, Eric > >>>>> > >>>>> On 2011-10-10 4:00 PM, Kalle Korhonen wrote: > >>>>>> > >>>>>> How are you reading in your properties files? By default, latin-1 is > >>>>>> assumed. Configure your surefire JVM to read files as UTF-8 with: > >>>>>> <argLine>-Xms256m -Xmx512m -XX:MaxPermSize=128m -ea > >>>>>> -Dfile.encoding=UTF-8</argLine> > >>>>>> > >>>>>> Kalle > >>>>>> > >>>>>> > >>>>>> On Mon, Oct 10, 2011 at 3:04 PM, Eric Kolotyluk > >>>>>> <[hidden email]> wrote: > >>>>>>> > >>>>>>> I am having trouble understanding a mystery. > >>>>>>> > >>>>>>> I have code that checks my .properties file to make sure that it has > >>>>>>> not > >>>>>>> been corrupted after being edited by a non UTF-8 editor. In > >>>>>>> particular > >>>>>>> I > >>>>>>> have a property called lambda = λ and I check to see that it actually > >>>>>>> does > >>>>>>> resolve to the correct character. > >>>>>>> > >>>>>>> If I run my code from main (my manual unit test) it works. If I run > >>>>>>> my > >>>>>>> test > >>>>>>> from JUnit in Eclipse, it works. But when the same test runs under > >>>>>>> Maven > >>>>>>> it > >>>>>>> fails because lambda = ? > >>>>>>> > >>>>>>> When I look in the actual properties file that the test runs with, > >>>>>>> lambda > >>>>>>> = > >>>>>>> λ, but somehow when the code runs it gets lambda = ?. > >>>>>>> > >>>>>>> I thought this was maybe a surefire configuration problems so I am > >>>>>>> using > >>>>>>> > >>>>>>> <pluginManagement> > >>>>>>> <plugins> > >>>>>>> <plugin> > >>>>>>> <groupId>org.apache.maven.plugins</groupId> > >>>>>>> <artifactId>maven-surefire-plugin</artifactId> > >>>>>>> <version>2.9</version> > >>>>>>> <configuration> > >>>>>>> <junitArtifactName>junit:junit</junitArtifactName> > >>>>>>> <encoding>UTF-8</encoding> > >>>>>>> <inputEncoding>UTF-8</inputEncoding> > >>>>>>> <outputEncoding>UTF-8</outputEncoding> > >>>>>>> <argLine>-Xms256m -Xmx512m -XX:MaxPermSize=128m -ea</argLine> > >>>>>>> </configuration> > >>>>>>> </plugin> > >>>>>>> </plugins> > >>>>>>> </pluginManagement> > >>>>>>> > >>>>>>> but this makes no difference. Does anyone have any idea why my JUnit > >>>>>>> test > >>>>>>> fails running under surefire, but not running under Eclipse? > >>>>>>> > >>>>>>> Cheers, Eric > >>>>>>> > >>>>>>> --------------------------------------------------------------------- > >>>>>>> To unsubscribe, e-mail: [hidden email] > >>>>>>> For additional commands, e-mail: [hidden email] > >>>>>>> > >>>>>>> > >>>>>> --------------------------------------------------------------------- > >>>>>> To unsubscribe, e-mail: [hidden email] > >>>>>> For additional commands, e-mail: [hidden email] > >>>>>> > >>>>> --------------------------------------------------------------------- > >>>>> To unsubscribe, e-mail: [hidden email] > >>>>> For additional commands, e-mail: [hidden email] > >>>>> > >>>>> > >>>> --------------------------------------------------------------------- > >>>> To unsubscribe, e-mail: [hidden email] > >>>> For additional commands, e-mail: [hidden email] > >>>> > >>> --------------------------------------------------------------------- > >>> To unsubscribe, e-mail: [hidden email] > >>> For additional commands, e-mail: [hidden email] > >>> > >>> > >> --------------------------------------------------------------------- > >> To unsubscribe, e-mail: [hidden email] > >> For additional commands, e-mail: [hidden email] > >> > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [hidden email] > > For additional commands, e-mail: [hidden email] > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [hidden email] > For additional commands, e-mail: [hidden email] > |
|
In reply to this post by Benson Margulies
OK, I got things working with
<properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.resourceEncoding>UTF-8</project.build.resourceEncoding> <maven.compile.encoding>UTF-8</maven.compile.encoding> </properties> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.3.2</version> <configuration> <!-- <fork>true</fork> --> <executable>P:\ValueInPrint\Main\jdk\jdk1.5.0_11\bin\javac</executable> </configuration> </plugin> I could not figure out how to get it to work with the <fork>true</fork> setting, even after setting MAVEN_OPTS=-Dfile.encoding=utf-8 I removed <plugin> --> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.9</version> <configuration> <junitArtifactName>junit:junit</junitArtifactName> <encoding>UTF-8</encoding> <inputEncoding>UTF-8</inputEncoding> <outputEncoding>UTF-8</outputEncoding> <argLine>-Xms256m -Xmx512m -XX:MaxPermSize=128m -ea -Dfile.encoding=UTF-8</argLine> </configuration> </plugin> and things still seem to work correctly, but I should probably leave it in anyway to be sure in the future. To summarize, this whole problem was caused by the compiler not compiling the literal "λ" correctly so my original code if (!lambda.equals("λ")) was failing - javac was substituting some other string literal - I did not figure this out until stepping through the code with the debugger. Somehow in the Eclipse and JUnit environment it was working correctly sometimes and not others, but always failing from the command line, so I assumed it was surefire. I do not think there was any problem with surefire, as using the default settings seems to work. In short my code and unit test were doing exactly what they were supposed to do to make sure UTF-8 was being handled properly, in particular my unit test caught the compiler doing the wrong thing in certain situations - it was just hard for me to believe the compiler was compiling the wrong code and easier to assume it was surefire or something. Maybe in the 22nd century we will not have so many problems with UTF-8 :-) Thanks everyone for your help and insight. Cheers, Eric On 2011-10-10 6:40 PM, Benson Margulies wrote: > Eric, > > A couple of points: > > 1: Javac has an option to control the input encoding of java source > files. There's a corresponding configuration option for the > maven-compiler-plugin. > > 2: Adding -Dfile.encoding=utf-8 to MAVEN_OPTS will cause maven, and > any other piece of java it launches, to use UTF-8 as the default > encoding. If surefire is forking you'll have to add this to the > systemPropertyValues. > > > 2011/10/10 Eric Kolotyluk<[hidden email]>: >> <forkMode>once</forkMode> >> >> Doesn't help. >> >> I have some new insight on the problem. I changed my code to >> >> if (lambda.length() == 1) >> { >> char λ = lambda.charAt(0); >> if (λ != 'λ') >> //if (!lambda.equals("λ")) >> { >> // UTF-8 sanity check failed! >> println(System.err, "lambda = '" + lambda + "'"); >> String message = "UTF-8 encoding problem for " + >> propertiesResource; >> println(System.err, message); >> throw new PropertiesError(message); >> } >> } >> >> This code works when built in Eclipse, but fails to compile from the command >> line with >> >> [INFO] Compiling 30 source files to >> P:\Intersystem\main\platform.Java\intersystem-common\target\classes >> [INFO] ------------------------------------------------------------- >> [ERROR] COMPILATION ERROR : >> [INFO] ------------------------------------------------------------- >> [ERROR] >> /Intersystem/main/platform.Java/intersystem-common/src/main/java/com/kodak/intersystem/common/Properties.java:[354,38] >> illegal character: \187 >> [ERROR] >> /Intersystem/main/platform.Java/intersystem-common/src/main/java/com/kodak/intersystem/common/Properties.java:[355,37] >> illegal character: \187 >> [ERROR] >> /Intersystem/main/platform.Java/intersystem-common/src/main/java/com/kodak/intersystem/common/Properties.java:[355,42] >> unclosed character literal >> [ERROR] >> /Intersystem/main/platform.Java/intersystem-common/src/main/java/com/kodak/intersystem/common/Properties.java:[355,44] >> illegal character: \187 >> [ERROR] >> /Intersystem/main/platform.Java/intersystem-common/src/main/java/com/kodak/intersystem/common/Properties.java:[355,45] >> unclosed character literal >> [ERROR] >> /Intersystem/main/platform.Java/intersystem-common/src/main/java/com/kodak/intersystem/common/Properties.java:[364,24] >> illegal start of expression >> [INFO] 6 errors >> [INFO] ------------------------------------------------------------- >> [INFO] >> ------------------------------------------------------------------------ >> [INFO] BUILD FAILURE >> >> I can't figure out why the compiler is failing because I can clearly see >> >> [DEBUG] (f) encoding = UTF-8 >> >> in the Maven output just before the errors. >> >> Anyone have any ideas? Is there some other compiler option I am missing? >> >> Cheers, Eric >> >> On 2011-10-10 5:23 PM, Kalle Korhonen wrote: >>> Different forkMode perhaps? >>> >>> http://maven.apache.org/plugins/maven-surefire-plugin/test-mojo.html#forkMode, >>> e.g: >>> <forkMode>once</forkMode> >>> >>> Just send the whole keg while you are at it :) >>> >>> Kalle >>> >>> >>> 2011/10/10 Eric Kolotyluk<[hidden email]>: >>>> Actually - that helped - but it's not a stable solution. For some reason >>>> the >>>> tests pass when run from m2e, but fail when run from the command line. >>>> I'm >>>> still trying to figure out what the difference is. >>>> >>>> Cheers, Eric >>>> >>>> On 2011-10-10 4:41 PM, Kalle Korhonen wrote: >>>>> A whole case? I *love* inflation. >>>>> >>>>> Kalle >>>>> >>>>> >>>>> 2011/10/10 Eric Kolotyluk<[hidden email]>: >>>>>> Awesome Kalle - thanks. >>>>>> >>>>>> Where should I send the case of beer? >>>>>> >>>>>> Cheers, Eric >>>>>> >>>>>> On 2011-10-10 4:00 PM, Kalle Korhonen wrote: >>>>>>> How are you reading in your properties files? By default, latin-1 is >>>>>>> assumed. Configure your surefire JVM to read files as UTF-8 with: >>>>>>> <argLine>-Xms256m -Xmx512m -XX:MaxPermSize=128m -ea >>>>>>> -Dfile.encoding=UTF-8</argLine> >>>>>>> >>>>>>> Kalle >>>>>>> >>>>>>> >>>>>>> On Mon, Oct 10, 2011 at 3:04 PM, Eric Kolotyluk >>>>>>> <[hidden email]> wrote: >>>>>>>> I am having trouble understanding a mystery. >>>>>>>> >>>>>>>> I have code that checks my .properties file to make sure that it has >>>>>>>> not >>>>>>>> been corrupted after being edited by a non UTF-8 editor. In >>>>>>>> particular >>>>>>>> I >>>>>>>> have a property called lambda = λ and I check to see that it actually >>>>>>>> does >>>>>>>> resolve to the correct character. >>>>>>>> >>>>>>>> If I run my code from main (my manual unit test) it works. If I run >>>>>>>> my >>>>>>>> test >>>>>>>> from JUnit in Eclipse, it works. But when the same test runs under >>>>>>>> Maven >>>>>>>> it >>>>>>>> fails because lambda = ? >>>>>>>> >>>>>>>> When I look in the actual properties file that the test runs with, >>>>>>>> lambda >>>>>>>> = >>>>>>>> λ, but somehow when the code runs it gets lambda = ?. >>>>>>>> >>>>>>>> I thought this was maybe a surefire configuration problems so I am >>>>>>>> using >>>>>>>> >>>>>>>> <pluginManagement> >>>>>>>> <plugins> >>>>>>>> <plugin> >>>>>>>> <groupId>org.apache.maven.plugins</groupId> >>>>>>>> <artifactId>maven-surefire-plugin</artifactId> >>>>>>>> <version>2.9</version> >>>>>>>> <configuration> >>>>>>>> <junitArtifactName>junit:junit</junitArtifactName> >>>>>>>> <encoding>UTF-8</encoding> >>>>>>>> <inputEncoding>UTF-8</inputEncoding> >>>>>>>> <outputEncoding>UTF-8</outputEncoding> >>>>>>>> <argLine>-Xms256m -Xmx512m -XX:MaxPermSize=128m -ea</argLine> >>>>>>>> </configuration> >>>>>>>> </plugin> >>>>>>>> </plugins> >>>>>>>> </pluginManagement> >>>>>>>> >>>>>>>> but this makes no difference. Does anyone have any idea why my JUnit >>>>>>>> test >>>>>>>> fails running under surefire, but not running under Eclipse? >>>>>>>> >>>>>>>> Cheers, Eric >>>>>>>> >>>>>>>> --------------------------------------------------------------------- >>>>>>>> To unsubscribe, e-mail: [hidden email] >>>>>>>> For additional commands, e-mail: [hidden email] >>>>>>>> >>>>>>>> >>>>>>> --------------------------------------------------------------------- >>>>>>> To unsubscribe, e-mail: [hidden email] >>>>>>> For additional commands, e-mail: [hidden email] >>>>>>> >>>>>> --------------------------------------------------------------------- >>>>>> To unsubscribe, e-mail: [hidden email] >>>>>> For additional commands, e-mail: [hidden email] >>>>>> >>>>>> >>>>> --------------------------------------------------------------------- >>>>> To unsubscribe, e-mail: [hidden email] >>>>> For additional commands, e-mail: [hidden email] >>>>> >>>> --------------------------------------------------------------------- >>>> To unsubscribe, e-mail: [hidden email] >>>> For additional commands, e-mail: [hidden email] >>>> >>>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: [hidden email] >>> For additional commands, e-mail: [hidden email] >>> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [hidden email] >> For additional commands, e-mail: [hidden email] >> >> > --------------------------------------------------------------------- > To unsubscribe, e-mail: [hidden email] > For additional commands, e-mail: [hidden email] > --------------------------------------------------------------------- To unsubscribe, e-mail: [hidden email] For additional commands, e-mail: [hidden email] |
|
Eric,
http://maven.apache.org/plugins/maven-surefire-plugin/examples/system-properties.html Add file.encoding that way for fork mode. On Tue, Oct 11, 2011 at 8:27 AM, Eric Kolotyluk <[hidden email]> wrote: > OK, I got things working with > > <properties> > <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> > <project.build.resourceEncoding>UTF-8</project.build.resourceEncoding> > <maven.compile.encoding>UTF-8</maven.compile.encoding> > </properties> > > <plugin> > <groupId>org.apache.maven.plugins</groupId> > <artifactId>maven-compiler-plugin</artifactId> > <version>2.3.2</version> > <configuration> > <!-- <fork>true</fork> --> > <executable>P:\ValueInPrint\Main\jdk\jdk1.5.0_11\bin\javac</executable> > </configuration> > </plugin> > > I could not figure out how to get it to work with the <fork>true</fork> > setting, even after setting MAVEN_OPTS=-Dfile.encoding=utf-8 > > I removed > > <plugin> --> > <groupId>org.apache.maven.plugins</groupId> > <artifactId>maven-surefire-plugin</artifactId> > <version>2.9</version> > <configuration> > <junitArtifactName>junit:junit</junitArtifactName> > <encoding>UTF-8</encoding> > <inputEncoding>UTF-8</inputEncoding> > <outputEncoding>UTF-8</outputEncoding> > <argLine>-Xms256m -Xmx512m -XX:MaxPermSize=128m -ea > -Dfile.encoding=UTF-8</argLine> > </configuration> > </plugin> > > and things still seem to work correctly, but I should probably leave it in > anyway to be sure in the future. > > To summarize, this whole problem was caused by the compiler not compiling > the literal "λ" correctly so my original code > > if (!lambda.equals("λ")) > > was failing - javac was substituting some other string literal - I did not > figure this out until stepping through the code with the debugger. Somehow > in the Eclipse and JUnit environment it was working correctly sometimes and > not others, but always failing from the command line, so I assumed it was > surefire. I do not think there was any problem with surefire, as using the > default settings seems to work. > > In short my code and unit test were doing exactly what they were supposed to > do to make sure UTF-8 was being handled properly, in particular my unit test > caught the compiler doing the wrong thing in certain situations - it was > just hard for me to believe the compiler was compiling the wrong code and > easier to assume it was surefire or something. > > Maybe in the 22nd century we will not have so many problems with UTF-8 :-) > > Thanks everyone for your help and insight. > > Cheers, Eric > > On 2011-10-10 6:40 PM, Benson Margulies wrote: >> >> Eric, >> >> A couple of points: >> >> 1: Javac has an option to control the input encoding of java source >> files. There's a corresponding configuration option for the >> maven-compiler-plugin. >> >> 2: Adding -Dfile.encoding=utf-8 to MAVEN_OPTS will cause maven, and >> any other piece of java it launches, to use UTF-8 as the default >> encoding. If surefire is forking you'll have to add this to the >> systemPropertyValues. >> >> >> 2011/10/10 Eric Kolotyluk<[hidden email]>: >>> >>> <forkMode>once</forkMode> >>> >>> Doesn't help. >>> >>> I have some new insight on the problem. I changed my code to >>> >>> if (lambda.length() == 1) >>> { >>> char λ = lambda.charAt(0); >>> if (λ != 'λ') >>> //if (!lambda.equals("λ")) >>> { >>> // UTF-8 sanity check failed! >>> println(System.err, "lambda = '" + lambda + "'"); >>> String message = "UTF-8 encoding problem for " + >>> propertiesResource; >>> println(System.err, message); >>> throw new PropertiesError(message); >>> } >>> } >>> >>> This code works when built in Eclipse, but fails to compile from the >>> command >>> line with >>> >>> [INFO] Compiling 30 source files to >>> P:\Intersystem\main\platform.Java\intersystem-common\target\classes >>> [INFO] ------------------------------------------------------------- >>> [ERROR] COMPILATION ERROR : >>> [INFO] ------------------------------------------------------------- >>> [ERROR] >>> >>> /Intersystem/main/platform.Java/intersystem-common/src/main/java/com/kodak/intersystem/common/Properties.java:[354,38] >>> illegal character: \187 >>> [ERROR] >>> >>> /Intersystem/main/platform.Java/intersystem-common/src/main/java/com/kodak/intersystem/common/Properties.java:[355,37] >>> illegal character: \187 >>> [ERROR] >>> >>> /Intersystem/main/platform.Java/intersystem-common/src/main/java/com/kodak/intersystem/common/Properties.java:[355,42] >>> unclosed character literal >>> [ERROR] >>> >>> /Intersystem/main/platform.Java/intersystem-common/src/main/java/com/kodak/intersystem/common/Properties.java:[355,44] >>> illegal character: \187 >>> [ERROR] >>> >>> /Intersystem/main/platform.Java/intersystem-common/src/main/java/com/kodak/intersystem/common/Properties.java:[355,45] >>> unclosed character literal >>> [ERROR] >>> >>> /Intersystem/main/platform.Java/intersystem-common/src/main/java/com/kodak/intersystem/common/Properties.java:[364,24] >>> illegal start of expression >>> [INFO] 6 errors >>> [INFO] ------------------------------------------------------------- >>> [INFO] >>> ------------------------------------------------------------------------ >>> [INFO] BUILD FAILURE >>> >>> I can't figure out why the compiler is failing because I can clearly see >>> >>> [DEBUG] (f) encoding = UTF-8 >>> >>> in the Maven output just before the errors. >>> >>> Anyone have any ideas? Is there some other compiler option I am missing? >>> >>> Cheers, Eric >>> >>> On 2011-10-10 5:23 PM, Kalle Korhonen wrote: >>>> >>>> Different forkMode perhaps? >>>> >>>> >>>> http://maven.apache.org/plugins/maven-surefire-plugin/test-mojo.html#forkMode, >>>> e.g: >>>> <forkMode>once</forkMode> >>>> >>>> Just send the whole keg while you are at it :) >>>> >>>> Kalle >>>> >>>> >>>> 2011/10/10 Eric Kolotyluk<[hidden email]>: >>>>> >>>>> Actually - that helped - but it's not a stable solution. For some >>>>> reason >>>>> the >>>>> tests pass when run from m2e, but fail when run from the command line. >>>>> I'm >>>>> still trying to figure out what the difference is. >>>>> >>>>> Cheers, Eric >>>>> >>>>> On 2011-10-10 4:41 PM, Kalle Korhonen wrote: >>>>>> >>>>>> A whole case? I *love* inflation. >>>>>> >>>>>> Kalle >>>>>> >>>>>> >>>>>> 2011/10/10 Eric Kolotyluk<[hidden email]>: >>>>>>> >>>>>>> Awesome Kalle - thanks. >>>>>>> >>>>>>> Where should I send the case of beer? >>>>>>> >>>>>>> Cheers, Eric >>>>>>> >>>>>>> On 2011-10-10 4:00 PM, Kalle Korhonen wrote: >>>>>>>> >>>>>>>> How are you reading in your properties files? By default, latin-1 is >>>>>>>> assumed. Configure your surefire JVM to read files as UTF-8 with: >>>>>>>> <argLine>-Xms256m -Xmx512m -XX:MaxPermSize=128m -ea >>>>>>>> -Dfile.encoding=UTF-8</argLine> >>>>>>>> >>>>>>>> Kalle >>>>>>>> >>>>>>>> >>>>>>>> On Mon, Oct 10, 2011 at 3:04 PM, Eric Kolotyluk >>>>>>>> <[hidden email]> wrote: >>>>>>>>> >>>>>>>>> I am having trouble understanding a mystery. >>>>>>>>> >>>>>>>>> I have code that checks my .properties file to make sure that it >>>>>>>>> has >>>>>>>>> not >>>>>>>>> been corrupted after being edited by a non UTF-8 editor. In >>>>>>>>> particular >>>>>>>>> I >>>>>>>>> have a property called lambda = λ and I check to see that it >>>>>>>>> actually >>>>>>>>> does >>>>>>>>> resolve to the correct character. >>>>>>>>> >>>>>>>>> If I run my code from main (my manual unit test) it works. If I run >>>>>>>>> my >>>>>>>>> test >>>>>>>>> from JUnit in Eclipse, it works. But when the same test runs under >>>>>>>>> Maven >>>>>>>>> it >>>>>>>>> fails because lambda = ? >>>>>>>>> >>>>>>>>> When I look in the actual properties file that the test runs with, >>>>>>>>> lambda >>>>>>>>> = >>>>>>>>> λ, but somehow when the code runs it gets lambda = ?. >>>>>>>>> >>>>>>>>> I thought this was maybe a surefire configuration problems so I am >>>>>>>>> using >>>>>>>>> >>>>>>>>> <pluginManagement> >>>>>>>>> <plugins> >>>>>>>>> <plugin> >>>>>>>>> <groupId>org.apache.maven.plugins</groupId> >>>>>>>>> <artifactId>maven-surefire-plugin</artifactId> >>>>>>>>> <version>2.9</version> >>>>>>>>> <configuration> >>>>>>>>> <junitArtifactName>junit:junit</junitArtifactName> >>>>>>>>> <encoding>UTF-8</encoding> >>>>>>>>> <inputEncoding>UTF-8</inputEncoding> >>>>>>>>> <outputEncoding>UTF-8</outputEncoding> >>>>>>>>> <argLine>-Xms256m -Xmx512m -XX:MaxPermSize=128m -ea</argLine> >>>>>>>>> </configuration> >>>>>>>>> </plugin> >>>>>>>>> </plugins> >>>>>>>>> </pluginManagement> >>>>>>>>> >>>>>>>>> but this makes no difference. Does anyone have any idea why my >>>>>>>>> JUnit >>>>>>>>> test >>>>>>>>> fails running under surefire, but not running under Eclipse? >>>>>>>>> >>>>>>>>> Cheers, Eric >>>>>>>>> >>>>>>>>> >>>>>>>>> --------------------------------------------------------------------- >>>>>>>>> To unsubscribe, e-mail: [hidden email] >>>>>>>>> For additional commands, e-mail: [hidden email] >>>>>>>>> >>>>>>>>> >>>>>>>> >>>>>>>> --------------------------------------------------------------------- >>>>>>>> To unsubscribe, e-mail: [hidden email] >>>>>>>> For additional commands, e-mail: [hidden email] >>>>>>>> >>>>>>> --------------------------------------------------------------------- >>>>>>> To unsubscribe, e-mail: [hidden email] >>>>>>> For additional commands, e-mail: [hidden email] >>>>>>> >>>>>>> >>>>>> --------------------------------------------------------------------- >>>>>> To unsubscribe, e-mail: [hidden email] >>>>>> For additional commands, e-mail: [hidden email] >>>>>> >>>>> --------------------------------------------------------------------- >>>>> To unsubscribe, e-mail: [hidden email] >>>>> For additional commands, e-mail: [hidden email] >>>>> >>>>> >>>> --------------------------------------------------------------------- >>>> To unsubscribe, e-mail: [hidden email] >>>> For additional commands, e-mail: [hidden email] >>>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: [hidden email] >>> For additional commands, e-mail: [hidden email] >>> >>> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [hidden email] >> For additional commands, e-mail: [hidden email] >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [hidden email] > For additional commands, e-mail: [hidden email] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [hidden email] For additional commands, e-mail: [hidden email] |
| Powered by Nabble | Edit this page |
