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 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>
> > > > > >
> > > <groupId>org.apache.maven.plugins</
> > > > > > groupId>
> > > > > > <artifactId>maven-
compiler-
> > > plugin</
> > > > > > artifactId>
> > > > > > <configuration>
> > > > > > <source>1.4</
source>
> > > > > > <target>1.4</
target>
> > > > > > </configuration>
> > > > > > </plugin>
> > > > > > </plugins>
> > > > > > </build>
> > > > > >
> > > > > > 6. Run "m2 clean:clean install" and it should now
compile ok.
> > > > > >
> > > > > > *****************
> > > > > >
> > > > > > The only thing I can think of then is that by default
> > source and
> > > > > > target are set to something like 1.3 out of the box,
> > > > > > though if not I'm at a loss to explain it.
> > > > > >
> > > > > > AW
> > > > > >
> > > > > >
> > > > > > before you run maven, and it reports you are on 1.4.2 then
> > that
> > > > > > should be the one and only vm you are using.
> > > > > > On 4 Oct 2005, at 08:59, David Sag wrote:
> > > > > >
> > > > > > >
> > > > > > > Hi Ashley,
> > > > > > >
> > > > > > > i am not sure how I'd check to see what version of Java
> > m2 is
> > > > > > > running but my Mac's default Java is
> > > > > > > java version "1.4.2_09"
> > > > > > > Java(TM) 2 Runtime Environment, Standard Edition (build
> > > > > 1.4.2_09-232)
> > > > > > > Java HotSpot(TM) Client VM (build 1.4.2-54, mixed mode)
> > > > > > >
> > > > > > > so i assume it's running that. i see no reason why
it would
> > > > > try to
> > > > > > > run in any earlier version of java.
> > > > > > >
> > > > > > > assert was introduced as part of java 1.4 and this same
> > > code built
> > > > > > > fine under maven 1 and ant. It's only now i have
migrated
> > > to m2
> > > > > > > that these assert errors are showing up.
> > > > > > >
> > > > > > > I have logged a bug with the maven2 Jira. see http://
> > > > > > > jira.codehaus.org/browse/MNG-1075
> > > > > > >
> > > > > > > Kind regards,
> > > > > > > Dave Sag
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > Ashley Williams <[EMAIL PROTECTED]>
> > > > > > > 03/10/05 04:36 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.
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > Could you check which version of java maven is
running in?
> > > > > > >
> > > > > > > I haven't been able to reproduce your problem. I'm
currently
> > > > > running
> > > > > > > Java 5 on Mac OS X and have used the assert keyword. The
> > only
> > > > > thing I
> > > > > > > could think of is that you're running maven under
jdk1.3,
> > but
> > > > > then I
> > > > > > > would have expected an 'unknown source/target' error
> > before it
> > > > > even
> > > > > > > tried to compile your code.
> > > > > > >
> > > > > > > So I don't believe the problem lies with Maven.
> > > > > > >
> > > > > > > Just a thought: was the assert keyword introduced at
version
> > > > > 1.4.2?
> > > > > > > Might be worth a google.
> > > > > > >
> > > > > > > AW
> > > > > > >
> > > > > > > On 3 Oct 2005, at 10:49, David Sag wrote:
> > > > > > >
> > > > > > > >
> > > > > > > > Hi M2 people,
> > > > > > > >
> > > > > > > > I am evaluating maven 2 and test-porting some small
> > projects
> > > > > over
> > > > > > > > to m2 from ant and m1.
> > > > > > > >
> > > > > > > > I am finding it mostly straightforward but i can't
work
> > out
> > > > > how to
> > > > > > > > tell maven2 that i want to enable asserts. whenever i
> > > compile i
> > > > > > > > just get the error
> > > > > > > >
> > > > > > > > cannot resolve symbol
> > > > > > > > symbol : method assert (boolean)
> > > > > > > >
> > > > > > > > I have tried forcing java1.4 in the pom.xml with the
> > > following :
> > > > > > > >
> > > > > > > > <plugins>
> > > > > > > > <plugin>
> > > > > > > > <groupId>org.apache.maven.plugins</groupId>
> > > > > > > > <artifactId>maven-compiler-plugin</artifactId>
> > > > > > > > <configuration>
> > > > > > > > <source>1.4</source>
> > > > > > > > <target>1.4</target>
> > > > > > > > </configuration>
> > > > > > > > </plugin>
> > > > > > > > </plugins>
> > > > > > > >
> > > > > > > > but it made no difference.
> > > > > > > >
> > > > > > > > i looked through the issues in jira and found
nothing to
> > > > > indicate
> > > > > > > > that this is a known bug.
> > > > > > > >
> > > > > > > > has anyone else hit this and if so how do i work-
around
> > it?
> > > > > > > >
> > > > > > > > Kind regards,
> > > > > > > >
> > > > > > > > Dave Sag
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > >
> > >
> >
---------------------------------------------------------------------
> > > > > > > To unsubscribe, e-mail: users-
[EMAIL PROTECTED]
> > > > > > > For additional commands, e-mail: users-
[EMAIL PROTECTED]
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > >
> > >
> >
---------------------------------------------------------------------
> > > > > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > > > > For additional commands, e-mail: users-
[EMAIL PROTECTED]
> > > > > >
> > > >
> > > >
> > > >
> > >
> >
---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > > For additional commands, e-mail: [EMAIL PROTECTED]
> > > >
> >
> >
> >
---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>