Re: classpath question

2008-12-30 Thread Linghua Wang
Hi,

I have not tried additional classpath feature in maven2. I am not sure
whether you load your xml file as following?

InputStream inputStream = YourClass.class. getResourceAsStream(The relative
PATH of your XML file);

Thanks.

Linghua

2008/12/28 Neo Anderson javadeveloper...@yahoo.co.uk

 I am build a project and that looks ok at the moment. However I encounter a
 problem when running test.

 My problem is that I have a customized xml. So I build a test located in
 the test/project/name/to/xmlTest.java, in which it will load an xml file to
 have  a small test. The xml file is located at
 reousrces/project/name/to/file.xml. Unfortunately, when executing the test
 (via mvn package), it seems the default classpath would be the place where
 pom.xml exists. Therefore, if in the xmlTest.java I specify xml path like

 parser.parse(project/name/to/file.xml);

 The maven throws Running project.name.xmlTest
 java.io.FileNotFoundException:
 $HOME/path/to/pom.xml/project/name/to/file.xml (No such file or directory)

 I read the doc -
 http://maven.apache.org/plugins/maven-surefire-plugin/examples/additional-classpath.html;
 seemingly I can add additional classpath whilst running test. But no luck,
 it still looks up the default one.

 I am able to specify the exactly path to solve the problem.
 For instance,

 parser.parse(src/parent_name/project/name/to/file.xml);

 where src/parent_name is the structure folder that will only be used when
 writing programme. But this is not what I want because I think that
 classpath should be configurable.

 Is any way I can configure to specify the classpath in pom.xml?

 Thanks in advice,














 -
 To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
 For additional commands, e-mail: users-h...@maven.apache.org




Re: How to add test classes into jar?

2008-12-14 Thread Linghua Wang
So specific as Wayne said.  BTW, now in JUnit4, test class don't have to
extends TestCase because of new design based on the JDK5's new
feature(annotation), so test class have a new chance to extends another
class.

Regards.

Linghua

2008/12/14 Wayne Fay wayne...@gmail.com

  You have some test classes that extends something else than TestCase and
 you
  want to share these intermediate classes between projects ?

 Or perhaps he has some utility classes that are used only by his
 tests, or he wants to re-use some test classes for some other reasons.
 There are many good reasons to make the test-jar artifact and share
 test classes amongst multiple projects.

 Wayne

 -
 To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
 For additional commands, e-mail: users-h...@maven.apache.org




Got 'initializationError' when run junit test class with maven.

2008-12-14 Thread Linghua Wang
Hi, all,

I am encounting with a fatal error while I try to run Junit by maven. I give
the information of my env as followings.

*Information of maven installed on my local host.*

Command :  mvn --version
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - -
Java version: 1.6.0_03
Default locale: zh_CN, platform encoding: UTF-8
OS name: linux version: 2.6.27-10-generic arch: i386 family: unix
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - -

*Junit Test Jar And Configration.*

junit-4.5.jar.  Currently, I am building the project C. Pro-C has a direct
parent Pro-B and Pro-B has a direct parent Pro-A. A and B were designed with
pom packaging.

Junit related dependence declaration in A.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
dependencyManagement
dependencies
dependency
groupIdjunit/groupId
artifactIdjunit/artifactId
version4.5/version
  /dependency
/dependencies
/dependencyManagement

... in B
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
project...
 dependencies
dependency
groupIdjunit/groupId
artifactIdjunit/artifactId
scopetest/scope
 /dependency
 /dependencies
.../project
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

None in C.

*My Test Case Design*:

@RunWith(Parameterized.class)


*Result*:
I executed mvn:test to try get all my test classes run. Unfortunately, maven
reported a error to me and just showed the type of error

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Tests in error:
  initializationError(FULL_CLASS_NAME).
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

I can not address this issue only by this error.
Is there a switch in maven to let me get all the tracking stack? Or is it
result from the compatiblity issue among  maven, junit and JDK?  Any
suggestions would be welcome.

Thank you.

Linghua


Re: Got 'initializationError' when run junit test class with maven.

2008-12-14 Thread Linghua Wang
Hi, Wayne,

Thanks for your continuous attention to my question. Seem that I should dig
more before posting a question. :-)

I am just going to answer my questions by myself.

Q: Is there a switch in maven to let me get all the tracking stack?

A: - We can find out the exception track stack in the surefire report after
execution the command:
   mvn surefire-report:report
   surefire report with HTML format  file under
../target/site/surefire-report.html.

What I have done:

1. Execute *mvn -Dmaven.surefire.debug test*, and configure the default
listening port(5005) on your IDE.

2. I found out the root cause - Test classes can not load the xml files
which contain all test data  files properly... Let me ignore my mistake,
just give the final solution here.

 Maven Test ClassPath:..target/test-classes/
 XML input data file: ..target/test-classes/data/input.xml

My solution:
 InputStream inputStream = MyJunitTest.class.getResourceAsStream(
/data/input.xml);


Thank you!


2008/12/15 Wayne Fay wayne...@gmail.com

  I can not address this issue only by this error.

 The people on this list probably can't address this issue only by the
 info in the email. Can you package up a sample project that shows the
 error, and attach it to a new JIRA issue?

  Is there a switch in maven to let me get all the tracking stack? Or is it
  result from the compatiblity issue among  maven, junit and JDK?  Any
  suggestions would be welcome.

 Did you try mvn -X test and/or scanning the output provided by
 Surefire (in target/surefire-reports)?

 Wayne

 -
 To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
 For additional commands, e-mail: users-h...@maven.apache.org




How 'Build in life-cycle bindings' works in Maven

2008-12-13 Thread Linghua Wang
Hi,

I am really puzzled about how 'Build in life-cycle bindings' works in Maven.


For example, 'jar' packaging, the default life-cycle bindings contains nine
phases - *process-resources,compile,process-test-resources,test-compile, test,
package, **install, deploy*. Actually, each phases 'build-in' binds to a
goal of plug-in. Moreover, Considering executing a goal of plug-in in Maven.


As far as I know, we should add the specify plugin into build element with
the specify execution goal(s). So I think such build-in life-cycle maybe
were defined in the super pom.xml, then I refer to it (
https://svn.apache.org/repos/asf/maven/components/branches/maven-2.0.x/maven-project/src/main/resources/org/apache/maven/project/pom-4.0.0.xml
)https://svn.apache.org/repos/asf/maven/components/branches/maven-2.0.x/maven-project/src/main/resources/org/apache/maven/project/pom-4.0.0.xml,
however,  I have not found anything I want. Could someone shed some light on
this? Or pull me out if I made mistake here.

Thanks.

Linghua.


Re: How does 'Build in life-cycle bindings' work in Maven

2008-12-13 Thread Linghua Wang
Correct typo.

2008/12/13 Linghua Wang mmchut.w...@gmail.com

 Hi,

 I am really puzzled about how 'Build in life-cycle bindings' works in
 Maven.

 For example, 'jar' packaging, the default life-cycle bindings contains nine
 phases - *process-resources,compile,process-test-resources,test-compile, test,
 package, **install, deploy*. Actually, each phases 'build-in' binds to a
 goal of plug-in. Moreover, Considering executing a goal of plug-in in Maven,
 as far as I know, we should add the specify plugin into build element with
 the specify execution goal(s). So I think such build-in life-cycle maybe
 were defined in the super pom.xml, then I refer to it ( 
 https://svn.apache.org/repos/asf/maven/components/branches/maven-2.0.x/maven-project/src/main/resources/org/apache/maven/project/pom-4.0.0.xml
 )https://svn.apache.org/repos/asf/maven/components/branches/maven-2.0.x/maven-project/src/main/resources/org/apache/maven/project/pom-4.0.0.xml,
 however,  I have not found anything I want. Could someone shed some light on
 this? Or pull me out if I made mistake here.

 Thanks.

 Linghua.





Re: How to add test classes into jar?

2008-12-12 Thread Linghua Wang
Thanks! I found out it based on your comments.  Followings is the details I
have done.

1. Add build snippet into pom.xml of project B. After the execution of
mvn:install, then .../src/main/java/ and /src/test/java were packaged
respectively and installed on my local repository.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - -
project
...
 build
plugins
plugin
groupIdorg.apache.maven.plugins/groupId
artifactIdmaven-jar-plugin/artifactId
version2.2/version
executions
execution
goals
goaltest-jar/goal
/goals
/execution
/executions
/plugin
/plugins
/build
...
/project
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - -

2. Add this dependency into project A.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - -
   !--The test myapp-hut--
dependency
groupIdcom.mycompany.hut/groupId
artifactIdmyapp-hut/artifactId
version1.0-SNAPSHOT/version
typetest-jar/type
scopetest/scope
/dependency
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - -

3. Then mvn test, things go smoothly.

Thank again.

2008/12/12 Wayne Fay wayne...@gmail.com

  Simply, we can resolve it by adding test classes into jar (default
  packaging). Somebody could tell me how? Or any other suggestions would be
  appriciated.

 You want to create and use a test-jar artifact. This is documented on
 the Maven site and in various other places, eg:
 http://stackoverflow.com/questions/174560/sharing-test-code-in-maven

 Wayne

 -
 To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
 For additional commands, e-mail: users-h...@maven.apache.org




The apache mailing thread does not support searching functionality?

2008-12-11 Thread Linghua Wang
All,

I joined maven mailing thread yesterday. But seem that I can not review the
former discussions what I am interested in effectively. All mailing threads
of apache do not support searching functionality? If yes, that is so
PAINFUL...

Regards.

Linghua.


How to add test classes into jar?

2008-12-11 Thread Linghua Wang
Hi,

I want to try maven-surefire-plugin. There are two projects A and B, A
depends on B,  and some test classes in A depend on that of in B. Both A and
B's POM has the following snippet.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - -
   plugin
groupIdorg.apache.maven.plugins/groupId
artifactIdmaven-surefire-plugin/artifactId
configuration
skipfalse/skip
/configuration
/plugin
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - -

Steps:

1. CD to directory of project B, execute mvn compiler:testCompile and mvn
install
2. CD to directory of project A, execute mvn compiler:testComplie, maven
always complain that some test classes can not be found in project B.

Question:

Simply, we can resolve it by adding test classes into jar (default
packaging). Somebody could tell me how? Or any other suggestions would be
appriciated.

Thanks.
Linghua.


Re: The apache mailing thread does not support searching functionality?

2008-12-11 Thread Linghua Wang
Hi, Brett,

Thanks for your feedback.

Minor Correct - Any of the 3 sites listed under *Other Archives* here will
let you search: http://maven.apache.org/mail-lists.html  :-)

Regards.

Linghua

2008/12/12 Brett Porter br...@apache.org

 Any of the 3 sites listed under Archives here will let you search:
 http://maven.apache.org/mail-lists.html

 - Brett


 On 12/12/2008, at 5:04 PM, Linghua Wang wrote:

  All,

 I joined maven mailing thread yesterday. But seem that I can not review
 the
 former discussions what I am interested in effectively. All mailing
 threads
 of apache do not support searching functionality? If yes, that is so
 PAINFUL...

 Regards.

 Linghua.


 --
 Brett Porter
 br...@apache.org
 http://blogs.exist.com/bporter/


 -
 To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
 For additional commands, e-mail: users-h...@maven.apache.org