By default src/main/resources should be made available on the test classpath, 
but _after_ the src/test/resources (allowing you to override stuff for tests by 
putting it in the src/test/resources directory so it is found first on the 
classpath). If you run mvn -X test you should be able to find the test 
classpath and see if it contains src/test/resources and src/main/resources.

Apologies if this seems obvious, but I can't see what the problem would be! A 
simple way to find out would be to write a JUnit test that looks for the 
applicationContext.xml file you want on the classpath by doing something like

public class FindAppContextTest extends TestCase {
        public void testFindAppContext() {
                
assertNotNull(MyTest.class.getResource("/applicationContext-jpa.xml"));
        }
}

That will allow you to re-run the test while you check the pom.xml, classpaths 
etc.

Ben

> -----Original Message-----
> From: Rick [mailto:[EMAIL PROTECTED]
> Sent: 24 September 2008 06:32
> To: Maven Users List
> Subject: Using spring How to share jpa applicationContext.xml file with
> main src and test source?
>
> I'm using the spring PetClinic as an example application to follow. I
> have things building and working in maven2, but I'm having an issue
> with the junit tests.
>
> I'd like to be able to share one of my application-context.xml files
> that is in my src/main/resources directory without having to keep it
> in two places.
>
> The application example I'm using for testing needs to call
> AbstractJpaTests which requires one to override the getConfigPaths.
> The problem is how do I get a handle outside of the test-classes in
> which the tests are being run?
>
> //the files below exist in my tests-classes directory, but I'd also
> like to use the one in my standard classes directory as well.
> // the / slash only seems to bring me to the base of my test-classes
> directory
>         @Override
>         protected String[] getConfigPaths() {
>                 return new String[] {
>                         "/applicationContext-jpa.xml",
>                         "/applicationContext-entityManager.xml"
>                 };
>         }
> }
>
> I've even tried adding an extra entry in my pom.xml for to use the
> main resources as well but it didn't seem to help:
>
> <testResources>
>             <testResource>
>                 <directory>src/main/resources</directory>
>                 <includes>
>                     <include>**/*.xml</include>
>                 </includes>
>             </testResource>
>                         <testResource>
>
> <directory>src/test/resources</directory>
>                                 <includes>
>                                         <include>**/*.xml</include>
>                                 </includes>
>                         </testResource>
>                 </testResources>
> --
> Rick
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]



This e-mail is confidential and intended solely for the use of the 
individual(s) to whom it is addressed. Any views or opinions expressed are 
those of the author. If you are not the intended recipient, please be advised 
that any use, dissemination, printing or copying of this email is strictly 
prohibited.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to