Re: [m2] asserts aren't recognized with surefire

2005-10-04 Thread Ashley Williams
Have you tried launching maven with the java -ea switch? I don't  
think you can control these switches with surefire or any of the  
other maven plugins as far as I can tell, so I think you have to  
configure your own vm as best as you can.


I've just had a look at m2 shell script and I think you can set  
MAVEN_OPTS to achieve this. Let me know how you get on because I  
should be using asserts more often than I do!


On 4 Oct 2005, at 13:42, David Sag wrote:



you misunderstand me.

in the setter of my class under test I use assert(param != null);

and in my test i try to pass null to the setter and check that an  
AssertionError gets thrown.


but now when i run the tests the AssertionError is never thrown.   
In ANT i used to have to specify

assertions
enable/
/assertions
in my junit task.

i have looked thorugh the docs for the surefire plugin but find all  
these docs a little opaque. perhaps you have an example in your pom  
of something that works.


Kind regards,
Dave Sag







Ashley Williams [EMAIL PROTECTED]
04/10/05 02:25 PM
Please respond to
Maven Users List users@maven.apache.org


To
Maven Users List users@maven.apache.org
cc
Subject
Re: when compiling with m2 using Java 1.4 on Mac OSX asserts are  
not being recognised.






For the tests I thought you would be using junit Assert class, so
extend TestCase and keep calling assertEquals etc.
The docs for the plugins are at http://maven.apache.org/maven2/
plugins/index.html


On 4 Oct 2005, at 13:08, David Sag wrote:


 another related question

 now it's compiling with asserts in place but the asserts get
 ignored when the tests run.  how do i force the JVM's assert
 flags.  where are the links to the documentation for the compiler
 plugin?

 Kind regards,
 Dave Sag






 Ashley Williams [EMAIL PROTECTED] wrote on 04/10/2005
 01:47:46 PM:

  Actually by chance I've just changed one of my projects from  
java 5

  to java 1.4 and as such saw a nice visual representation of the
  default compiler settings in Eclipse:
 
  
  Use default compliance settings: yes
  Generated .class files compatibility:   1.2
  Source compatibility: 1.3
  
 
  so Maven probably isn't applying any default settings at all for
 your
  java vm, just relying on the existing vm setup, which is fair
 enough.
  Don't know if these defaults are the same on other platforms,  
but I

  would have thought so.
 
  I suppose it's better to configure the vm settings in maven rather
  than relying on platform settings since at least you can upgrade
 in a
  more controlled fashion. I just wish there was some way that if I
  specified for example java 5 in my pom, the maven shell script  
would
  be smart enough to select it automatically rather than me  
having to

  remember to switch to java 5 manually - not a trivial task on the
 Mac.
 
  Maybe if the settings.xml could take a list of existing vm's on  
your

  machine it could work.
 
  On 4 Oct 2005, at 12:24, David Sag wrote:
 
  
   Hi Ashley,
  
   haha well i am falling at step 1 now.  the archetype command  
fails

   with the following:
  
   [ERROR] ResourceManager : unable to find resource
   'VM_global_library.vm' in any resource loader.
  
   seems something broke m2 today, because i have used the same
   architype command only a few days ago to set up my project.
  
   however i have been able to make my project build with asserts
 - my
   problem it seems was that i did not wrap the plugins.../
 plugins
   section within build.../build
  
   so yes - it does seem that by default m2 will try to build as  
java

   1.3, but i was not correctly fixing that in my pom.xml
  
   i shall update the jira issue with this info
  
  
   Kind regards,
   Dave Sag
  
  
  
  
  
  
   Ashley Williams [EMAIL PROTECTED] wrote on 04/10/2005
   12:56:56 PM:
  
Well I suppose the good news is that I have got the assert
   keyword to
work so hopefully you will be able to as well.
   
Step by step:
   
1. Create a new project; m2 archetype:create - 
DgroupId=bogus -

DarchetypeId=bogus
   
2. Use the assert keyword: cd bogus; vi src/main/java/bogus/
App.java and change it like so:
   
 public static void main( String[] args )
 {
 assert(true);
 System.out.println( Hello World! );
 }
   
3. Ensure the current vm is 1.4.2 by doing java -version
 and do
   m2
install
   
4. Reproduce your problem - out of the box I get a compile
 error too
at this point.
   
5. Edit the pom vi pom.xml and add in the compiler plugin
 config:
 build
 plugins
 plugin
   
 groupIdorg.apache.maven.plugins/
groupId
 artifactIdmaven-compiler-
 plugin/
artifactId
 configuration
 source1.4/source

Re: [m2] asserts aren't recognized with surefire

2005-10-04 Thread David Sag

Hi Ashley,

in my humble opinion assertsenabled
should be the default for running *any* unit tests. it seems a litle
crazy that getting my unit tests to pass would require a custom MAVEN_OPTS
setting.

i have filed an 'imporvement' issue
in jira http://jira.codehaus.org/browse/MNG-1087

so with luck someone working on the
surefire plugin will pick this up and fix it.

for now it's entirely unacceptable to
me that such a valuable part of the java1.4 spec should be treated with
such disdain.

i can code around this wby writing my
own Assert class but that seems to be a rather stupid way to solve the
problem.

Kind regards,
Dave Sag 




 

Ashley Williams [EMAIL PROTECTED] wrote
on 04/10/2005 03:10:55 PM:

 Have you tried launching maven with the java -ea switch? I don't 
 think you can control these switches with surefire or any of the 
 other maven plugins as far as I can tell, so I think you have to 
 configure your own vm as best as you can.
 
 I've just had a look at m2 shell script and I think you can set 
 MAVEN_OPTS to achieve this. Let me know how you get on because I 
 should be using asserts more often than I do!
 
 On 4 Oct 2005, at 13:42, David Sag wrote:
 
 
  you misunderstand me.
 
  in the setter of my class under test I use assert(param != null);
 
  and in my test i try to pass null to the setter and check that
an 
  AssertionError gets thrown.
 
  but now when i run the tests the AssertionError is never thrown.
 
  In ANT i used to have to specify
assertions
  enable/
/assertions
  in my junit task.
 
  i have looked thorugh the docs for the surefire plugin but find
all 
  these docs a little opaque. perhaps you have an example in your
pom 
  of something that works.
 
  Kind regards,
  Dave Sag
 
 
 
 
 
 
 
  Ashley Williams [EMAIL PROTECTED]
  04/10/05 02:25 PM
  Please respond to
  Maven Users List users@maven.apache.org
 
 
  To
  Maven Users List users@maven.apache.org
  cc
  Subject
  Re: when compiling with m2 using Java 1.4 on Mac OSX asserts
are 
  not being recognised.
 
 
 
 
 
  For the tests I thought you would be using junit Assert class,
so
  extend TestCase and keep calling assertEquals etc.
  The docs for the plugins are at http://maven.apache.org/maven2/
  plugins/index.html
 
 
  On 4 Oct 2005, at 13:08, David Sag wrote:
 
  
   another related question
  
   now it's compiling with asserts in place but the asserts
get
   ignored when the tests run. how do i force the JVM's
assert
   flags. where are the links to the documentation for
the compiler
   plugin?
  
   Kind regards,
   Dave Sag
  
  
  
  
  
  
   Ashley Williams [EMAIL PROTECTED] wrote on
04/10/2005
   01:47:46 PM:
  
Actually by chance I've just changed one of my projects
from 
  java 5
to java 1.4 and as such saw a nice visual representation
of the
default compiler settings in Eclipse:
   

Use default compliance settings: yes
Generated .class files compatibility:  1.2
Source compatibility: 
 1.3

   
so Maven probably isn't applying any default settings
at all for
   your
java vm, just relying on the existing vm setup, which
is fair
   enough.
Don't know if these defaults are the same on other
platforms, 
  but I
would have thought so.
   
I suppose it's better to configure the vm settings
in maven rather
than relying on platform settings since at least you
can upgrade
   in a
more controlled fashion. I just wish there was some
way that if I
specified for example java 5 in my pom, the maven shell
script 
  would
be smart enough to select it automatically rather than
me 
  having to
remember to switch to java 5 manually - not a trivial
task on the
   Mac.
   
Maybe if the settings.xml could take a list of existing
vm's on 
  your
machine it could work.
   
On 4 Oct 2005, at 12:24, David Sag wrote:
   

 Hi Ashley,

 haha well i am falling at step 1 now. the
archetype command 
  fails
 with the following:

 [ERROR] ResourceManager : unable to find resource
 'VM_global_library.vm' in any resource loader.

 seems something broke m2 today, because i have
used the same
 architype command only a few days ago to set up
my project.

 however i have been able to make my project build
with asserts
   - my
 problem it seems was that i did not wrap the plugins.../
   plugins
 section within build.../build

 so yes - it does seem that by default m2 will
try to build as 
  java
 1.3, but i was not correctly fixing that in my
pom.xml

 i shall update the jira issue with this info


 Kind regards,
 Dave Sag






 Ashley Williams [EMAIL PROTECTED]
wrote on 04/10/2005
 12:56:56 PM:

  Well I suppose the good news is that I have
got the assert
 keyword to
  work so hopefully you will be able to as
well.
 
  Step by step:
 
  1. Create a new 

Re: [m2] asserts aren't recognized with surefire

2005-10-04 Thread David Sag

oh FYI - adding

export MAVEN_OPTS=-ea

to my .profile made everything work
fine.

Kind regards,
Dave Sag 




 





Ashley Williams [EMAIL PROTECTED]

04/10/05 03:10 PM



Please respond to
Maven Users List users@maven.apache.org





To
Maven Users List users@maven.apache.org


cc



Subject
Re: [m2] asserts aren't recognized with
surefire








Have you tried launching maven with the java -ea switch?
I don't 
think you can control these switches with surefire or any of the 
other maven plugins as far as I can tell, so I think you have to 
configure your own vm as best as you can.

I've just had a look at m2 shell script and I think you can set 
MAVEN_OPTS to achieve this. Let me know how you get on because I 
should be using asserts more often than I do!

On 4 Oct 2005, at 13:42, David Sag wrote:


 you misunderstand me.

 in the setter of my class under test I use assert(param != null);

 and in my test i try to pass null to the setter and check that an

 AssertionError gets thrown.

 but now when i run the tests the AssertionError is never thrown. 

 In ANT i used to have to specify
   assertions
 enable/
   /assertions
 in my junit task.

 i have looked thorugh the docs for the surefire plugin but find all

 these docs a little opaque. perhaps you have an example in your pom

 of something that works.

 Kind regards,
 Dave Sag







 Ashley Williams [EMAIL PROTECTED]
 04/10/05 02:25 PM
 Please respond to
 Maven Users List users@maven.apache.org


 To
 Maven Users List users@maven.apache.org
 cc
 Subject
 Re: when compiling with m2 using Java 1.4 on Mac OSX asserts are 
 not being recognised.





 For the tests I thought you would be using junit Assert class, so
 extend TestCase and keep calling assertEquals etc.
 The docs for the plugins are at http://maven.apache.org/maven2/
 plugins/index.html


 On 4 Oct 2005, at 13:08, David Sag wrote:

 
  another related question
 
  now it's compiling with asserts in place but the asserts get
  ignored when the tests run. how do i force the JVM's assert
  flags. where are the links to the documentation for the
compiler
  plugin?
 
  Kind regards,
  Dave Sag
 
 
 
 
 
 
  Ashley Williams [EMAIL PROTECTED] wrote on 04/10/2005
  01:47:46 PM:
 
   Actually by chance I've just changed one of my projects
from 
 java 5
   to java 1.4 and as such saw a nice visual representation
of the
   default compiler settings in Eclipse:
  
   
   Use default compliance settings: yes
   Generated .class files compatibility:  1.2
   Source compatibility: 
 1.3
   
  
   so Maven probably isn't applying any default settings at
all for
  your
   java vm, just relying on the existing vm setup, which is
fair
  enough.
   Don't know if these defaults are the same on other platforms,

 but I
   would have thought so.
  
   I suppose it's better to configure the vm settings in maven
rather
   than relying on platform settings since at least you can
upgrade
  in a
   more controlled fashion. I just wish there was some way
that if I
   specified for example java 5 in my pom, the maven shell
script 
 would
   be smart enough to select it automatically rather than me

 having to
   remember to switch to java 5 manually - not a trivial task
on the
  Mac.
  
   Maybe if the settings.xml could take a list of existing
vm's on 
 your
   machine it could work.
  
   On 4 Oct 2005, at 12:24, David Sag wrote:
  
   
Hi Ashley,
   
haha well i am falling at step 1 now. the archetype
command 
 fails
with the following:
   
[ERROR] ResourceManager : unable to find resource
'VM_global_library.vm' in any resource loader.
   
seems something broke m2 today, because i have used
the same
architype command only a few days ago to set up my
project.
   
however i have been able to make my project build with
asserts
  - my
problem it seems was that i did not wrap the plugins.../
  plugins
section within build.../build
   
so yes - it does seem that by default m2 will try to
build as 
 java
1.3, but i was not correctly fixing that in my pom.xml
   
i shall update the jira issue with this info
   
   
Kind regards,
Dave Sag
   
   
   
   
   
   
Ashley Williams [EMAIL PROTECTED] wrote
on 04/10/2005
12:56:56 PM:
   
 Well I suppose the good news is that I have got
the assert
keyword to
 work so hopefully you will be able to as well.

 Step by step:

 1. Create a new project; m2 archetype:create
- 
 DgroupId=bogus -
 DarchetypeId=bogus

 2. Use the assert keyword: cd bogus; vi
src/main/java/bogus/
 App.java and change it like so:

   public static void main( String[]
args )
   {
 assert(true);
 System.out.println(
Hello World! );
   }

 3. Ensure the current vm is 1.4.2 by doing java
-version
  and do
m2
 install

 4. Reproduce your problem - out of the box I get
a compile
  error too
 at this point

Re: [m2] asserts aren't recognized with surefire

2005-10-04 Thread Ashley Williams
You should know that what I've been suggesting is also in my humble  
opinion - I don't know for sure that there isn't an 'easy' way to  
configure the vm. If not them maybe you could expand your jira issue  
to include vm configuration in general rather than just for enabling  
asserts - maybe wait til the end of the day for any more responses.


I too am a recent convert to Maven and have found lots of stuff  
missing that I know I would personally love to have, but it's the age  
old problem of there not being 37 hours in the day for the dev team  
like the rest of us. In the meantime I find the people on this  
mailing list very helpful.


AW

On 4 Oct 2005, at 15:22, David Sag wrote:



Hi Ashley,

in my humble opinion assertsenabled should be the default for  
running *any* unit tests.  it seems a litle crazy that getting my  
unit tests to pass would require a custom MAVEN_OPTS setting.


i have filed an 'imporvement' issue in jira http:// 
jira.codehaus.org/browse/MNG-1087


so with luck someone working on the surefire plugin will pick this  
up and fix it.


for now it's entirely unacceptable to me that such a valuable part  
of the java1.4 spec should be treated with such disdain.


i can code around this wby writing my own Assert class but that  
seems to be a rather stupid way to solve the problem.


Kind regards,
Dave Sag






Ashley Williams [EMAIL PROTECTED] wrote on 04/10/2005  
03:10:55 PM:


 Have you tried launching maven with the java -ea switch? I don't
 think you can control these switches with surefire or any of the
 other maven plugins as far as I can tell, so I think you have to
 configure your own vm as best as you can.

 I've just had a look at m2 shell script and I think you can set
 MAVEN_OPTS to achieve this. Let me know how you get on because I
 should be using asserts more often than I do!

 On 4 Oct 2005, at 13:42, David Sag wrote:

 
  you misunderstand me.
 
  in the setter of my class under test I use assert(param != null);
 
  and in my test i try to pass null to the setter and check that an
  AssertionError gets thrown.
 
  but now when i run the tests the AssertionError is never thrown.
  In ANT i used to have to specify
  assertions
  enable/
  /assertions
  in my junit task.
 
  i have looked thorugh the docs for the surefire plugin but find  
all
  these docs a little opaque. perhaps you have an example in your  
pom

  of something that works.
 
  Kind regards,
  Dave Sag
 
 
 
 
 
 
 
  Ashley Williams [EMAIL PROTECTED]
  04/10/05 02:25 PM
  Please respond to
  Maven Users List users@maven.apache.org
 
 
  To
  Maven Users List users@maven.apache.org
  cc
  Subject
  Re: when compiling with m2 using Java 1.4 on Mac OSX asserts are
  not being recognised.
 
 
 
 
 
  For the tests I thought you would be using junit Assert class, so
  extend TestCase and keep calling assertEquals etc.
  The docs for the plugins are at http://maven.apache.org/maven2/
  plugins/index.html
 
 
  On 4 Oct 2005, at 13:08, David Sag wrote:
 
  
   another related question
  
   now it's compiling with asserts in place but the asserts get
   ignored when the tests run.  how do i force the JVM's assert
   flags.  where are the links to the documentation for the  
compiler

   plugin?
  
   Kind regards,
   Dave Sag
  
  
  
  
  
  
   Ashley Williams [EMAIL PROTECTED] wrote on 04/10/2005
   01:47:46 PM:
  
Actually by chance I've just changed one of my projects from
  java 5
to java 1.4 and as such saw a nice visual representation of  
the

default compiler settings in Eclipse:
   

Use default compliance settings: yes
Generated .class files compatibility:   1.2
Source compatibility: 1.3

   
so Maven probably isn't applying any default settings at  
all for

   your
java vm, just relying on the existing vm setup, which is fair
   enough.
Don't know if these defaults are the same on other platforms,
  but I
would have thought so.
   
I suppose it's better to configure the vm settings in maven  
rather
than relying on platform settings since at least you can  
upgrade

   in a
more controlled fashion. I just wish there was some way  
that if I

specified for example java 5 in my pom, the maven shell script
  would
be smart enough to select it automatically rather than me
  having to
remember to switch to java 5 manually - not a trivial task  
on the

   Mac.
   
Maybe if the settings.xml could take a list of existing  
vm's on

  your
machine it could work.
   
On 4 Oct 2005, at 12:24, David Sag wrote:
   

 Hi Ashley,

 haha well i am falling at step 1 now.  the archetype command
  fails
 with the following:

 [ERROR] ResourceManager : unable to find resource
 'VM_global_library.vm' in any resource loader.

 seems something broke m2 today, because i have used the same
 architype command only a