But I do use the @Before annotation, and I was planning to call my database cleanup from here. But my problem is that the database properties are not accessible to me (I think), and they are managed by maven (are they not?).
Med venlig hilsen / Kind regards Søren Krogh Neigaard Systems Engineer Søren Frichs Vej 39, 8000 Aarhus C Denmark Mobile +4541965252 [email protected] www.systematic.com -----Original Message----- From: [email protected] [mailto:[email protected]] Sent: 5. februar 2010 09:13 To: Maven Users List Subject: RE: Read properties from pom.xml from Java Søren Krogh Neigaard <[email protected]> wrote on 05.02.2010 07:45:51: > We are already using > the sql-maven-plugin to bootstrap the database, but it only gets run > once before all junit tests are run, and that is not what I need, I > need it to run for every test to ensure a clean database. > > I can easily make some code that drops my tables and so on, but I > need the correct database properties from the correct settings.xml. > > Bernd you talked about making a plugin that gets called before every > test, how can I do this? Søren, after reading this post from you I know that my suggestion is not what you want, since you already have it (starting the sql-maven-plugin once before all tests). If you need something to be done before every single test, you'll have to use Junit's '@Before' annotated methods. If you need some advice here, we should make this outside this list since this is no Maven issue at all. Bernd > > Med venlig hilsen / Kind regards > > > Søren Krogh Neigaard > Systems Engineer > > Søren Frichs Vej 39, 8000 Aarhus C > Denmark > > Mobile +4541965252 > [email protected] > www.systematic.com > > > -----Original Message----- > From: [email protected] [ > mailto:[email protected]] > Sent: 4. februar 2010 11:59 > To: Maven Users List > Subject: Re: Read properties from pom.xml from Java > > Sounds like this might help you: > > - Create a Maven plugin which is executed in any phase >>bevore<< test, > e.g. 'generate-test-resources'. This will make it possible to set up the > database. This plugin might help for starting the database (only if you're > using HSQL): > http://gforge.openehealth.org/gf/project/development/wiki/? > pagename=Documentation+HSQLDB+plugin > , but there are others, too. > > - Reading of POM-properties inside a Maven plugin is easy and described > here: > http://www.sonatype.com/books/mvnref-book/reference/writing-plugins- > sect-mojo-params.html#writing-plugins-sect-param-values > > However, the scenario described by you clearly indicates that this is not > a unit test instead it is an integration test where other rules/plugins > might apply, e.g. maven-invoker-plugin. But this would recommend a > restructuring of your project and might not be what you want. > > Bernd > > > > > > > Søren Krogh Neigaard <[email protected]> wrote on > 04.02.2010 09:59:26: > > > [image removed] > > > > Read properties from pom.xml from Java > > > > Søren Krogh Neigaard > > > > to: > > > > users > > > > 04.02.2010 10:00 > > > > Please respond to "Maven Users List" > > > > Hi > > > > > > > > I have been tossed into a maven controlled project. We run our junit > > tests from Eclipse and also on our build server. When ever they are > > run, some maven magic happens so that username/password/driver/url > > for the dabase is correctly set for the user pc or the buildserver. > > However I need to make a small helper class for my junit tests that > > wipes the database and loads some testdata on the database for every > > junit test. > > > > > > > > The username/password/driver/url for the database is set in the > > pom.xml file by maven. How do I read these values from my Java helper > class? > > > > > > > > Best regards > > > > Søren > > > > > > > > > > InterComponentWare AG: > Vorstand: Peter Kirschbauer (Vors.), Jörg Stadler / > Aufsichtsratsvors.: Prof. Dr. Christof Hettich > Firmensitz: 69190 Walldorf, Industriestraße 41 / AG Mannheim HRB > 351761 / USt.-IdNr.: DE 198388516 = > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > InterComponentWare AG: Vorstand: Peter Kirschbauer (Vors.), Jörg Stadler / Aufsichtsratsvors.: Prof. Dr. Christof Hettich Firmensitz: 69190 Walldorf, Industriestraße 41 / AG Mannheim HRB 351761 / USt.-IdNr.: DE 198388516 = --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
