ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jerome Lacoste <>
Subject [SOLVED] System.getProperties() returns an empty list when unit test run within Ant 1.4.1
Date Mon, 19 Aug 2002 11:58:20 GMT
Jerome Lacoste wrote:

> Hi Anties,
> I've got this strange problem: one of my UnitTest fails when I run it 
> within Ant, while it doens't fail when I run it directly from the same VM.
> I've had trouble like that before and they are usualy environment 
> related but this one is very strange:
> Here's the code of my Unit Test:
> public void testSystemGetProperties() {
>    // Skip debug code to printout System.getProperties()
>    ...
>    if (System.getProperties().size() == 0)
>    {
>      fail("WARNING something is wrong in your environment. 
> System.getProperties().size() == 0");
>    }
>  }
> As you can see, System.getProperties().size() == 0 fails when I run 
> this test within ant. According to the API this should never happen.
> Even more strange is that if I try to access any single System 
> property within the same code, I will obtain it without problem!
> I.e. System.getProperty("user.dir") works OK but 
> System.getProperties() still returns an empty list!!

I have two ways of solving the problem:
- either using fork="true" as advised by Erik Hatcher
- either switch to Ant 1.5, which also solves the problem

This was obvisouly a bug in Ant 1.4.1. It appears to be solved in Ant 
1.5 but I can't say for sure.
Perhaps the bug is still there but hidden by some side effects.
Someone should perhaps confirm that this bug really disappeared.


Thanks all.

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message