You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by mbabauer <mi...@bankofamerica.com> on 2007/08/02 18:18:30 UTC
Spring XML files and classpaths for JUnit
I need some assistance in how to add a folder to the classpath for JUnit
testing.
My situation is this...we use Spring to wire most of our stuff together. I
would like to have some JUnits that use a test configuration for Spring.
The Spring config file(s) are located in <root>/src/test/resources, and the
test code itself is in <root>/src/test/java. I would like the JUnit to use
the ClasspathXmlApplicationContext, which looks to the classpath for a given
XML file for context configuration, but I have not found a way to add the
<root>/src/test/resources folder to the classpath for just the 'test' phase.
I am also not sure I am going down the right path.
For reference, I have attached my POM:
http://www.nabble.com/file/p11967682/pom.xml pom.xml
--
View this message in context: http://www.nabble.com/Spring-XML-files-and-classpaths-for-JUnit-tf4207069s177.html#a11967682
Sent from the Maven - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Spring XML files and classpaths for JUnit
Posted by Arnaud Bailly <ab...@oqube.com>.
mbabauer <mi...@bankofamerica.com> writes:
> I need some assistance in how to add a folder to the classpath for JUnit
> testing.
>
> My situation is this...we use Spring to wire most of our stuff together. I
> would like to have some JUnits that use a test configuration for Spring.
> The Spring config file(s) are located in <root>/src/test/resources, and the
> test code itself is in <root>/src/test/java. I would like the JUnit to use
> the ClasspathXmlApplicationContext, which looks to the classpath for a given
> XML file for context configuration, but I have not found a way to add the
> <root>/src/test/resources folder to the classpath for just the 'test' phase.
> I am also not sure I am going down the right path.
Hello,
That's weird because the purpose of /src/test/resources is precisely
to *add* those resources in the classpath of the executed tests. I do
this routinely on every project.
Do the target/test-classes directory contains your resources ? Do you
have special config in your parent files that would change
target/srcs/resources directories ? Did you run mvn -X to check the
classpath used ?
Regards,
--
OQube < software engineering \ génie logiciel >
Arnaud Bailly, Dr.
\web> http://www.oqube.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Assembly descriptors: excludes in filesets not excluding
Posted by Andrew Boyer <ab...@Endeca.com>.
I have a basic assembly descriptor like this:
<assembly>
<id>dist</id>
<formats>
<format>zip</format>
<format>tar.gz</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>target/dist</directory>
<outputDirectory>/</outputDirectory>
<excludes>
<exclude>*-tests.jar</exclude>
</excludes>
</fileSet>
</fileSets>
</assembly>
When I run the assembly:single target, it zips up the dist directory,
but includes the test jars. I played with this a bit, passing in the
full test jar name, but it still included it. I pulled down the source
code for the assembly plugin, and looked at the FileSetAssemblyPhase
object. I didn't see any reference to excludes. Grepping through the
source, I see that FilterUtils has a filterProject method (which is used
by ModuleSetAssemblyPhase), and a filterArtifact method (which doesn't
seem to be used.
Is this a known issue?
Thanks,
Andrew
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Spring XML files and classpaths for JUnit
Posted by Janning Vygen <vy...@planwerk6.de>.
On Thursday 02 August 2007 18:18:30 mbabauer wrote:
> I need some assistance in how to add a folder to the classpath for JUnit
> testing.
>
> My situation is this...we use Spring to wire most of our stuff together. I
> would like to have some JUnits that use a test configuration for Spring.
> The Spring config file(s) are located in <root>/src/test/resources, and the
> test code itself is in <root>/src/test/java. I would like the JUnit to use
> the ClasspathXmlApplicationContext, which looks to the classpath for a
> given XML file for context configuration, but I have not found a way to add
> the <root>/src/test/resources folder to the classpath for just the 'test'
> phase. I am also not sure I am going down the right path.
are you running your junit test from maven like "mvn test" or do you run your
junit test inside eclipse?
If you run it with "mvn test" maven will copy the resources from
src/test/resources to target/test-classes and it will have
target/test-classes on the classpath
if you run it inside eclipse check out the .classpath file or look
at "Configure build path". My .classpath looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src/main/java"/>
<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
<classpathentry excluding="**" kind="src" output="target/classes"
path="src/main/resources"/>
<classpathentry excluding="**" kind="src" output="target/classes"
path="src/test/resources"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con"
path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
your test should look something like this:
import
org.springframework.test.AbstractTransactionalDataSourceSpringContextTests;
public class MyTests extends AbstractTransactionalDataSourceSpringContextTests
{
protected String[] getConfigLocations ( )
{
return new String[] { "applicationContextTest.xml" };
}
// .. tests
}
hope this helps in any way. if not give us some more information.
kind regards
Janning
> For reference, I have attached my POM:
> http://www.nabble.com/file/p11967682/pom.xml pom.xml
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org