We have found that SpringJUnit4ClassRunner is not compatible with the
4.5+ versions of JUnit.
I think that you will find that in
private UsuarioFacade usuarioFacade;
that UsuarioFacade must be an interface in order for Spring to do it's
magic. Is this the case?
This does not explain why the problem only manifests itself during
"mvn site", and not "mvn install" or "mvn test".
Did it seem to work with JUnit 4.6 at all? If it did, then you unit
tests were not executing because this combination cannot work.
What version of Maven are you using?
Cheers,
Steve C
On 06/07/2009, at 3:19 PM, Chávez, Carlos wrote:
Hi.
I mean, when I ran: mvn test, it works, no one exception is throw it
when i ran: mvn site, it does not work. The following exception is
showed:
org.apache.maven.surefire.booter.SurefireExecutionException:
org.junit.runner.notification.RunNotifier.testAborted(Lorg/junit/
runner/Des
cription;Ljava/lang/Throwable;)V; nested exception is
java.lang.NoSuchMethodError:
org.junit.runner.notification.RunNotifier.testAborted(Lorg/junit/
runner/Des
cription;Ljava/lang/Throwable;)V java.lang.NoSuchMethodError:
org.junit.runner.notification.RunNotifier.testAborted(Lorg/junit/
runner/Des
cription;Ljava/lang/Throwable;)V at
org
.springframework
.test.context.junit4.SpringJUnit4ClassRunner.invokeTestM
ethod(SpringJUnit4ClassRunner.java:155) at
The above exception dissapear when I use the junit version 4.4.
But now, I'm getting the following error messages:
org.springframework.beans.factory.BeanCreationException: Error
creating bean
with name 'ni.gob.cgr.siirci.facade.UsuarioFacadeTestCase':
Injection of
resource methods failed; nested exception is
org.springframework.beans.factory.BeanNotOfRequiredTypeException:
Bean named
'usuarioFacade' must be of type
[ni.gob.cgr.siirci.facade.UsuarioFacade], but
was actually of type [$Proxy18]
at
org
.springframework
.context
.annotation
.CommonAnnotationBeanPostProcessor
.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:305)
at
org
.springframework
.beans
.factory
.support
.AbstractAutowireCapableBeanFactory
.populateBean(AbstractAutowireCapableBeanFactory.java:998)
at
org
.springframework
.beans
.factory
.support
.AbstractAutowireCapableBeanFactory
.autowireBeanProperties(AbstractAutowireCapableBeanFactory.java:329)
at
org
.springframework
.test
.context
.support
.DependencyInjectionTestExecutionListener
.injectDependencies(DependencyInjectionTestExecutionListener.java:110)
at
org
.springframework
.test
.context
.support
.DependencyInjectionTestExecutionListener
.prepareTestInstance(DependencyInjectionTestExecutionListener.java:75)
at
org
.springframework
.test
.context
.TestContextManager.prepareTestInstance(TestContextManager.java:255)
at
org
.springframework
.test
.context
.junit4
.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:111)
at
org
.springframework
.test
.context
.junit4
.SpringJUnit4ClassRunner
.invokeTestMethod(SpringJUnit4ClassRunner.java:148)
at
org
.junit
.internal
.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)
at
org.junit.internal.runners.JUnit4ClassRunner
$1.run(JUnit4ClassRunner.java:44)
at
org
.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:
27)
at
org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:
37)
at
org
.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:
42)
at
org
.springframework
.test
.context
.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:97)
at
org
.apache
.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
at
org
.apache
.maven
.surefire
.suite
.AbstractDirectoryTestSuite
.executeTestSet(AbstractDirectoryTestSuite.java:140)
at
org
.apache
.maven
.surefire
.suite
.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:
127)
at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun
.reflect
.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun
.reflect
.DelegatingMethodAccessorImpl
.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org
.apache
.maven
.surefire
.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345)
at
org
.apache
.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009)
Caused by:
org.springframework.beans.factory.BeanNotOfRequiredTypeException:
Bean named 'usuarioFacade' must be of type
[ni.gob.cgr.siirci.facade.UsuarioFacade], but was actually of type
[$Proxy18]
at
org
.springframework
.beans
.factory
.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322)
at
org
.springframework
.beans
.factory
.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
at
org
.springframework
.beans
.factory
.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:168)
at
org
.springframework
.context
.annotation
.CommonAnnotationBeanPostProcessor
.autowireResource(CommonAnnotationBeanPostProcessor.java:435)
at
org
.springframework
.context
.annotation
.CommonAnnotationBeanPostProcessor
.getResource(CommonAnnotationBeanPostProcessor.java:409)
at
org
.springframework.context.annotation.CommonAnnotationBeanPostProcessor
$
ResourceElement
.getResourceToInject(CommonAnnotationBeanPostProcessor.java:537)
at
org.springframework.beans.factory.annotation.InjectionMetadata
$InjectedElement.inject(InjectionMetadata.java:192)
at
org
.springframework
.beans
.factory
.annotation.InjectionMetadata.injectMethods(InjectionMetadata.java:
117)
at
org
.springframework
.context
.annotation
.CommonAnnotationBeanPostProcessor
.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:302)
... 23 more
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed:
2.382 sec <<<
FAILURE!
I only have one usuarioFacade bean definition, my applicationContext
is very
simple, I have three bean defined apart of the datasource and
Hibernate stuff
see:
...
<tx:annotation-driven/>
<context:annotation-config/>
<bean id="sessionUtil" name="sessionUtil" autowire="byName"
class="ni.gob.cgr.siirci.hibernate.SessionUtil" />
<bean id="baseFacade" name="baseFacade" autowire="byName"
abstract="true"
class="ni.gob.cgr.siirci.facade.BaseFacade" />
<bean id="usuarioFacade" name="usuarioFacade" autowire="byName"
parent="baseFacade" class="ni.gob.cgr.siirci.facade.UsuarioFacade" />
...
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations={"/applicationContext.xml"})
@TransactionConfiguration
@Transactional
public class UsuarioFacadeTestCase extends TestCase {
private UsuarioFacade usuarioFacade;
public UsuarioFacade getUsuarioFacade() {
return usuarioFacade;
}
@Resource(name="usuarioFacade")
public void setUsuarioFacade(final UsuarioFacade usuarioFacade) {
this.usuarioFacade = usuarioFacade;
}
@Test
public void testUsuarioFacade() {
assertNotNull(usuarioFacade);
usuarioFacade.setUsrLogin("MI_LOGIN");
usuarioFacade.setUsrFullName("MI_FULL_NAME");
usuarioFacade.setUsrCargo("MI_CARGO");
usuarioFacade.save();
assertNotNull(usuarioFacade.getDelegate().getUsrId());
assertTrue(usuarioFacade.getDelegate().getUsrId() > 0);
}
}
Also, this error only happen when i ran: maven site
everything works for: maven test or maven install, but not for site.
--
Cheers.
Carlos Chávez.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]