You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Herbert Wu <he...@gmail.com> on 2009/06/02 22:50:08 UTC

Spring unit test cfg file

Sorry for the rookie question as I am just learning Maven and had difficulty
to find an answer for a simple spring cfg file issue:

In my unit test, I placed the unit-test spring-bean xml file
client-config.xml in src/test/com/demo folder, and how to instruct maven
classloader to load from this folder?

This is the annotated Spring unit test code that uses classpath to load the
spring-bean client-config.xml( Eclipse IDE loads it fine).
@ContextConfiguration(locations = {"classpath:com/demo/client-config.xml"})
@RunWith(SpringJUnit4ClassRunner.class)
public class HelloWorldAnnotationTest {
...
}

But "mvn test" apparently only looks target\test-classes\com\demo path - not
src/test/com/demo path, and complains client-config.xml file not found.

Thanks
-Herbert

Re: Spring unit test cfg file

Posted by Nayan Hajratwala <na...@chikli.com>.
I'm guessing you have an eclipse pre-3.4. I use the current 3.5 RC, which
works fine.

I also use the update-dev site, but it should be basically the same.

On Wed, 3 Jun 2009 13:07:12 -0500, Herbert Wu <he...@gmail.com> wrote:
> hmm..., I got this error when installing m2eclipse plugin:
> 
> Cannot complete the request.  See the details.
> Cannot find a solution satisfying the following requirements
> org.eclipse.swt
> [3.4.0.v3448f].
> 
> I use http://m2eclipse.sonatype.org/update/ and is this the correct url?
> 
> Thanks,
> -Herbert
> 
> 
> On Wed, Jun 3, 2009 at 11:41 AM, Nayan Hajratwala <na...@chikli.com>
wrote:
> 
>> If you install the m2eclipse plugin, it will (among other cool things)
>> automatically update your .classpath file to use the src/test/resources
>> directory.
>>
>>
>> On Wed, 3 Jun 2009 09:26:13 -0500, Herbert Wu <he...@gmail.com>
>> wrote:
>> > Great, it worked. I can easily adjust Eclipse IDE to look for
>> > src/test/resources/ to make both mvn and IDE working.
>> > Thanks a lot!
>> > -Herbert
>> >
>> > On Tue, Jun 2, 2009 at 3:50 PM, Herbert Wu <he...@gmail.com>
wrote:
>> >
>> >> Sorry for the rookie question as I am just learning Maven and had
>> >> difficulty to find an answer for a simple spring cfg file issue:
>> >>
>> >> In my unit test, I placed the unit-test spring-bean xml file
>> >> client-config.xml in src/test/com/demo folder, and how to instruct
>> >> maven
>> >> classloader to load from this folder?
>> >>
>> >> This is the annotated Spring unit test code that uses classpath to
>> >> load
>> >> the
>> >> spring-bean client-config.xml( Eclipse IDE loads it fine).
>> >> @ContextConfiguration(locations =
>> >> {"classpath:com/demo/client-config.xml"})
>> >> @RunWith(SpringJUnit4ClassRunner.class)
>> >> public class HelloWorldAnnotationTest {
>> >> ...
>> >> }
>> >>
>> >> But "mvn test" apparently only looks target\test-classes\com\demo
path
>> >> -
>> >> not src/test/com/demo path, and complains client-config.xml file not
>> >> found.
>> >>
>> >> Thanks
>> >> -Herbert
>> >>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>>

-- 
  Nayan Hajratwala
  http://agileshrugged.com
  734.658.6032

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


Re: Spring unit test cfg file

Posted by Herbert Wu <he...@gmail.com>.
hmm..., I got this error when installing m2eclipse plugin:

Cannot complete the request.  See the details.
Cannot find a solution satisfying the following requirements org.eclipse.swt
[3.4.0.v3448f].

I use http://m2eclipse.sonatype.org/update/ and is this the correct url?

Thanks,
-Herbert


On Wed, Jun 3, 2009 at 11:41 AM, Nayan Hajratwala <na...@chikli.com> wrote:

> If you install the m2eclipse plugin, it will (among other cool things)
> automatically update your .classpath file to use the src/test/resources
> directory.
>
>
> On Wed, 3 Jun 2009 09:26:13 -0500, Herbert Wu <he...@gmail.com> wrote:
> > Great, it worked. I can easily adjust Eclipse IDE to look for
> > src/test/resources/ to make both mvn and IDE working.
> > Thanks a lot!
> > -Herbert
> >
> > On Tue, Jun 2, 2009 at 3:50 PM, Herbert Wu <he...@gmail.com> wrote:
> >
> >> Sorry for the rookie question as I am just learning Maven and had
> >> difficulty to find an answer for a simple spring cfg file issue:
> >>
> >> In my unit test, I placed the unit-test spring-bean xml file
> >> client-config.xml in src/test/com/demo folder, and how to instruct maven
> >> classloader to load from this folder?
> >>
> >> This is the annotated Spring unit test code that uses classpath to load
> >> the
> >> spring-bean client-config.xml( Eclipse IDE loads it fine).
> >> @ContextConfiguration(locations =
> >> {"classpath:com/demo/client-config.xml"})
> >> @RunWith(SpringJUnit4ClassRunner.class)
> >> public class HelloWorldAnnotationTest {
> >> ...
> >> }
> >>
> >> But "mvn test" apparently only looks target\test-classes\com\demo path -
> >> not src/test/com/demo path, and complains client-config.xml file not
> >> found.
> >>
> >> Thanks
> >> -Herbert
> >>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: Spring unit test cfg file

Posted by Nayan Hajratwala <na...@chikli.com>.
If you install the m2eclipse plugin, it will (among other cool things)
automatically update your .classpath file to use the src/test/resources
directory.


On Wed, 3 Jun 2009 09:26:13 -0500, Herbert Wu <he...@gmail.com> wrote:
> Great, it worked. I can easily adjust Eclipse IDE to look for
> src/test/resources/ to make both mvn and IDE working.
> Thanks a lot!
> -Herbert
> 
> On Tue, Jun 2, 2009 at 3:50 PM, Herbert Wu <he...@gmail.com> wrote:
> 
>> Sorry for the rookie question as I am just learning Maven and had
>> difficulty to find an answer for a simple spring cfg file issue:
>>
>> In my unit test, I placed the unit-test spring-bean xml file
>> client-config.xml in src/test/com/demo folder, and how to instruct maven
>> classloader to load from this folder?
>>
>> This is the annotated Spring unit test code that uses classpath to load
>> the
>> spring-bean client-config.xml( Eclipse IDE loads it fine).
>> @ContextConfiguration(locations =
>> {"classpath:com/demo/client-config.xml"})
>> @RunWith(SpringJUnit4ClassRunner.class)
>> public class HelloWorldAnnotationTest {
>> ...
>> }
>>
>> But "mvn test" apparently only looks target\test-classes\com\demo path -
>> not src/test/com/demo path, and complains client-config.xml file not
>> found.
>>
>> Thanks
>> -Herbert
>>


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


Re: Spring unit test cfg file

Posted by Herbert Wu <he...@gmail.com>.
Great, it worked. I can easily adjust Eclipse IDE to look for
src/test/resources/ to make both mvn and IDE working.
Thanks a lot!
-Herbert

On Tue, Jun 2, 2009 at 3:50 PM, Herbert Wu <he...@gmail.com> wrote:

> Sorry for the rookie question as I am just learning Maven and had
> difficulty to find an answer for a simple spring cfg file issue:
>
> In my unit test, I placed the unit-test spring-bean xml file
> client-config.xml in src/test/com/demo folder, and how to instruct maven
> classloader to load from this folder?
>
> This is the annotated Spring unit test code that uses classpath to load the
> spring-bean client-config.xml( Eclipse IDE loads it fine).
> @ContextConfiguration(locations = {"classpath:com/demo/client-config.xml"})
> @RunWith(SpringJUnit4ClassRunner.class)
> public class HelloWorldAnnotationTest {
> ...
> }
>
> But "mvn test" apparently only looks target\test-classes\com\demo path -
> not src/test/com/demo path, and complains client-config.xml file not found.
>
> Thanks
> -Herbert
>
>

Re: Spring unit test cfg file

Posted by Wayne Fay <wa...@gmail.com>.
> In my unit test, I placed the unit-test spring-bean xml file
> client-config.xml in src/test/com/demo folder, and how to instruct maven
> classloader to load from this folder?

Move it to src/test/resources/com/demo.

Wayne

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