Announcement Announcement Module
Collapse
No announcement yet.
Spring AOP Junit testing having problem while loading applicationContext.xml Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring AOP Junit testing having problem while loading applicationContext.xml

    I refer Junit4.4 with sprint test jar file
    Code is shown below:

    Java Junit Test Class

    package com.vizu.bim.test;
    import static org.junit.Assert.*;

    import org.junit.Test;
    import org.junit.runner.RunWith;
    import org.springframework.beans.factory.annotation.Autow ired;
    import org.springframework.test.context.ContextConfigurat ion;
    import org.springframework.test.context.TestExecutionList eners;
    import org.springframework.test.context.junit4.SpringJUni t4ClassRunner;
    import org.springframework.test.context.support.Dependenc yInjectionTestExecutionListener;
    import org.springframework.test.context.support.DirtiesCo ntextTestExecutionListener;
    import org.springframework.test.context.transaction.Trans actionConfiguration;
    import org.springframework.test.context.transaction.Trans actionalTestExecutionListener;
    import org.springframework.transaction.annotation.Transac tional;

    import com.vizu.bim.business.logic.VizuBimBusinessLogicIm pl;
    import com.vizu.service.BimService;

    @RunWith(SpringJUnit4ClassRunner.class)

    @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class,
    DirtiesContextTestExecutionListener.class,
    TransactionalTestExecutionListener.class })
    @ContextConfiguration(locations="/applicationContext.xml")
    @TransactionConfiguration(transactionManager="tran sactionManager", defaultRollback=false)

    public class TestVizuBimBusinessLogic {

    @Autowired
    private BimService bimService = null;
    @Autowired
    private VizuBimBusinessLogicImpl vizuBimBusinessLogicImpl = null;

    /**
    * Tests message.
    */
    @Test
    public void testBimService(){
    assertEquals("S1010", bimService.getSiteId("Hi"));
    System.out.println("bimService='{}'" + bimService.getSiteId("Hi"));
    }
    @Test
    @Transactional
    public void testVizuBimBusinessLogic(){
    assertNotNull("S1010", vizuBimBusinessLogicImpl.loadCampaign(45l));
    // System.out.println("VizuBimBusinessLogic='{}'" + vizuBimBusinessLogicImpl);
    }


    }

    Error msg :

    java.lang.IllegalStateException: Failed to load ApplicationContext
    at org.springframework.test.context.TestContext.getAp plicationContext(TestContext.java:203)
    at org.springframework.test.context.support.Dependenc yInjectionTestExecutionListener.injectDependencies (DependencyInjectionTestExecutionListener.java:109 )
    at org.springframework.test.context.support.Dependenc yInjectionTestExecutionListener.prepareTestInstanc e(DependencyInjectionTestExecutionListener.java:75 )
    at org.springframework.test.context.TestContextManage r.prepareTestInstance(TestContextManager.java:255)
    at org.springframework.test.context.junit4.SpringJUni t4ClassRunner.createTest(SpringJUnit4ClassRunner.j ava:93)
    at org.springframework.test.context.junit4.SpringJUni t4ClassRunner.invokeTestMethod(SpringJUnit4ClassRu nner.java:130)
    at org.junit.internal.runners.JUnit4ClassRunner.runMe thods(JUnit4ClassRunner.java:51)
    at org.junit.internal.runners.JUnit4ClassRunner$1.run (JUnit4ClassRunner.java:44)
    at org.junit.internal.runners.ClassRoadie.runUnprotec ted(ClassRoadie.java:27)
    at org.junit.internal.runners.ClassRoadie.runProtecte d(ClassRoadie.java:37)
    at org.junit.internal.runners.JUnit4ClassRunner.run(J Unit4ClassRunner.java:42)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestR eference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecutio n.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.main(RemoteTestRunner.java:197)
    Caused by: org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'dataSource' defined in class path resource [applicationContext.xml]: Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: warning no match for this type name: com.vizu.bim.web.admin.ajax.BimAjaxLogic [Xlint:invalidAbsoluteTypeName]
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.doCreateBean(AbstractAu towireCapableBeanFactory.java:527)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 91)
    at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:222)
    at org.springframework.beans.factory.support.Abstract BeanFactory.doGetBean(AbstractBeanFactory.java:288 )
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:190)
    at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:580)
    at org.springframework.context.support.AbstractApplic ationContext.finishBeanFactoryInitialization(Abstr actApplicationContext.java:895)
    at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:425)
    at org.springframework.test.context.support.AbstractG enericContextLoader.loadContext(AbstractGenericCon textLoader.java:96)
    at org.springframework.test.context.support.AbstractG enericContextLoader.loadContext(AbstractGenericCon textLoader.java:44)
    at org.springframework.test.context.TestContext.loadA pplicationContext(TestContext.java:173)
    at org.springframework.test.context.TestContext.getAp plicationContext(TestContext.java:199)
    ... 16 more
    Caused by: java.lang.IllegalArgumentException: warning no match for this type name: com.vizu.bim.web.admin.ajax.BimAjaxLogic [Xlint:invalidAbsoluteTypeName]
    at org.aspectj.weaver.tools.PointcutParser.parsePoint cutExpression(PointcutParser.java:302)
    at org.springframework.aop.aspectj.AspectJExpressionP ointcut.buildPointcutExpression(AspectJExpressionP ointcut.java:195)
    at org.springframework.aop.aspectj.AspectJExpressionP ointcut.checkReadyToMatch(AspectJExpressionPointcu t.java:181)
    at org.springframework.aop.aspectj.AspectJExpressionP ointcut.getClassFilter(AspectJExpressionPointcut.j ava:162)
    at org.springframework.aop.support.AopUtils.canApply( AopUtils.java:200)
    at org.springframework.aop.support.AopUtils.canApply( AopUtils.java:254)
    at org.springframework.aop.support.AopUtils.findAdvis orsThatCanApply(AopUtils.java:286)
    at org.springframework.aop.framework.autoproxy.Abstra ctAdvisorAutoProxyCreator.findAdvisorsThatCanApply (AbstractAdvisorAutoProxyCreator.java:117)
    at org.springframework.aop.framework.autoproxy.Abstra ctAdvisorAutoProxyCreator.findEligibleAdvisors(Abs tractAdvisorAutoProxyCreator.java:87)
    at org.springframework.aop.framework.autoproxy.Abstra ctAdvisorAutoProxyCreator.getAdvicesAndAdvisorsFor Bean(AbstractAdvisorAutoProxyCreator.java:68)
    at org.springframework.aop.framework.autoproxy.Abstra ctAutoProxyCreator.wrapIfNecessary(AbstractAutoPro xyCreator.java:359)
    at org.springframework.aop.framework.autoproxy.Abstra ctAutoProxyCreator.postProcessAfterInitialization( AbstractAutoProxyCreator.java:322)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.applyBeanPostProcessors AfterInitialization(AbstractAutowireCapableBeanFac tory.java:407)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.initializeBean(Abstract AutowireCapableBeanFactory.java:1426)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.doCreateBean(AbstractAu towireCapableBeanFactory.java:519)
    ... 28 more

  • #2
    java.lang.IllegalArgumentException: warning no match for this type name
    this exception usually means you have a malformed AspectJ pointcut definition somewhere (xml or annotation) in the Spring configuration you are trying to load.

    Comment

    Working...
    X