ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Leal "Valmaņa" <achepat...@yahoo.es>
Subject RE: Properties files are not properly loaded when testing class under junit task (possible bug)
Date Sat, 15 Nov 2003 12:01:55 GMT

Hi David,

Did you not read the response I made to bug 24648?

http://issues.apache.org/bugzilla/show_bug.cgi?id=24648

 

NO AT THAT TIME, :-)

>>-----

You need to set the locale and not just

the "user.language" system property.

WHY?, IT IS ENOUGH, WHEN RUNNING DIRECTLY A JAVA INVOCATION FROM COMMAND LINE. THE JAVA CODE
SHOULD WORK ON THE SAME WAY INVOKING THE TASK junit.

If the locale is not specified, the default locale is used. BUT

this is only set once: in java.util.Locale#getDefault()

which uses the "user.language" property to find the

default locale if the default is null.

By the time you call junit, the default locale would have

been retrieved many times.

You can do one of two things:

1) set default locale by hand in the test:

Locale.setDefault(new Locale(System.getProperty("user.language")))

2) call "junit" with the attribute "fork" = yes

OK, I UNDERSTAND WHAT YOU MEAN, EVEN I DON'T SEE SO MUCH WHY WE HAVE TO SET THE DEFAULT LOCALE
INTERNALLY.

THANK YOU,

DAVID

>>-----

To clarify, either of the options work, but it is better

to do both.

Peter

On Friday 14 November 2003 14:02, David Leal Valmaa wrote:

> Dear Stefan,

>

> -----Mensaje original-----

>

> De: Stefan Bodewig [mailto:bodewig@apache.org]

>

> Enviado el: viernes, 14 de noviembre de 2003 14:18

>

> Para: user@ant.apache.org

>

> Asunto: Re: Properties files are not properly loaded when testing class

>

> under junit task (possible bug)

>

> On Tue, 11 Nov 2003, David Leal <achepati67@yahoo.es> wrote:

> > I have detected that the junit task doesn't take into account a

> >

> > change on the variable user.language, for example on the invokation:

>

> It does, as your own Syste.out output shows. I think the problem is

>

> in the ResourceBundle class (ot the classes supporting it). If you

>

> change the locale related system properties, this won't affect

>

> ResourceBundle at all, much like changing java.class.path doesn't have

>

> any effect on the classes your VM can load.

>

> I DON'T KNOW, BECAUSE IF I RUN THE TEST CLASS DIRECTLY FROM JAVA, IT

> WORKS!!!!

>

> I fear you have to set your properties before you start a new VM (and

>

> as a corrolary have to start a new VM whenever you want the change to

>

> take any effect). And then, I'm not sure whether user.language is the

>

> property that get's consulted by ResourceBundle at all.

>

> DO YOU MEAN TO FORK THE VM?, I HAVE PROBLEMS WHEN I DO THAT, I GET A CLASS

> NOT FOUND

>

> MESSAGE. THAT IS WHY I AM USING YOUR RECOMENDATION ABOUT TO USE THE NESTED

> ELEMENT: <sysproperty>

>

> > ant -Duser.language=en

>

> Sets an Ant property, not a Java system property. For a system

>

> property you have to use the ANT_OPTS environment variable.

>

> OK, I HAVE USED IT, BUT IT DOESN'T WORK TOO.

>

> I HAVE SET TO THE VALUE:

>

> SET ANT_OPTS=-Duser.language=en

>

> AND IT WORKS, SO NOW THE QUESTION IS HOW TO CONTROL ON THE ANT INVOKATIO,

> DO I HAVE THE VALUE OF THIS ENVIRONMENT VARIABLE IN ORDER TO TEST EJECUTION

> USING DIFERENT LOCALES? I SHOULD BE A SIMPLER WAY? NOW FOR TESTING A

> DIFFERENT LOCALE CONFIGURATION, I HAVE TO SET BY HAND THE VALUE OF THE

> VARIABLE ANT_OPTS.

>

> Thanks,

>

>

>

> ---------------------------------

> Do you Yahoo!?

> Protect your identity with Yahoo! Mail AddressGuard

 

---------------------------------------------------------------------

To unsubscribe, e-mail: user-unsubscribe@ant.apache.org



---------------------------------
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message