This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Maven: Why is my test ignoring project.properties ?

 
Dave Alvarado
Ranch Hand
Posts: 436
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm using Maven 1.1 and running some unit tests. I am testing a web service that requires a username and password for access. So I can run my test like so (from within my test directory):

maven -Dtest.service.username=username -Dtest.service.password=password -Dtestcase=myco.dor.dmv.driver.matching.test.MatchingServiceTest -Dhttp.nonProxyHosts=localhost test:single

However, if I try and put the command line properties (e.g. test.service.username) into my project.properties file and run

maven -Dtestcase=myco.dor.dmv.driver.matching.test.MatchingServiceTest -Dhttp.nonProxyHosts=localhost test:single

my test dies with the output below. How can I specify these proeprties in a file? Thanks, - Dave

<error message="Username may not be null" type="java.lang.IllegalArgumentException">java.lang.IllegalArgumentException: Username may not be null
at org.apache.commons.httpclient.UsernamePasswordCredentials.<init>(UsernamePasswordCredentials.java:89)
at org.apache.axis2.transport.http.AbstractHTTPSender.setAuthenticationInfo(AbstractHTTPSender.java:330)
at org.apache.axis2.transport.http.AbstractHTTPSender.getHostConfiguration(AbstractHTTPSender.java:267)
at org.apache.axis2.transport.http.AbstractHTTPSender.executeMethod(AbstractHTTPSender.java:502)
at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:191)
at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:77)
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:327)
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:206)
at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:396)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:374)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:211)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:163)
at myco.dor.dmv.driver.matching.soap.MatchingServiceStub.verifyAge(MatchingServiceStub.java:522)
at myco.dor.dmv.driver.matching.test.MatchingServiceTest.testVerifyAgeOver18(MatchingServiceTest.java:60)
at org.apache.commons.jelly.tags.ant.AntTag.doTag(AntTag.java:195)
at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:250)
at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
at org.apache.commons.jelly.TagSupport.invokeBody(TagSupport.java:186)
at org.apache.commons.jelly.tags.core.OtherwiseTag.doTag(OtherwiseTag.java:41)
at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:250)
at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
at org.apache.commons.jelly.TagSupport.invokeBody(TagSupport.java:186)
at org.apache.commons.jelly.tags.core.ChooseTag.doTag(ChooseTag.java:38)
at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:250)
at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
at org.apache.commons.jelly.TagSupport.invokeBody(TagSupport.java:186)
at org.apache.commons.jelly.tags.core.IfTag.doTag(IfTag.java:42)
at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:250)
at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
at org.apache.maven.jelly.tags.werkz.MavenGoalTag.runBodyTag(MavenGoalTag.java:83)
at org.apache.maven.jelly.tags.werkz.MavenGoalTag$MavenGoalAction.performAction(MavenGoalTag.java:116)
at org.apache.maven.werkz.Goal.fire(Goal.java:691)
at org.apache.maven.werkz.Goal.attain(Goal.java:623)
at org.apache.maven.plugin.PluginManager.attainGoals(PluginManager.java:712)
at org.apache.maven.MavenSession.attainGoals(MavenSession.java:265)
at org.apache.maven.cli.App.doMain(App.java:307)
at org.apache.maven.cli.App.main(App.java:217)
at com.werken.forehead.Forehead.run(Forehead.java:551)
at com.werken.forehead.Forehead.main(Forehead.java:581)
</error>


 
manuel aldana
Ranch Hand
Posts: 308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i guess you meant maven version 2.1?

1) if you pass to maven command you pass it to the maven run itself. to passthrough the stuff to the surefire plugin you have to configure the surefireplugin. see http://maven.apache.org/plugins/maven-surefire-plugin/test-mojo.html#systemProperties

2) you should reconsider passing property arguments to the as maven run property. first you (and your colleages) get quickly confused if more and more properties are added. better practice is either to code it directly in your test class or use src/test/resources to place property files there.


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic