2012-12-18 2 views
0

안녕하세요, JUNIT 테스트 케이스를 실행하려고 할 때 다음과 같은 오류가 발생합니다. 누군가가이 문제를 도와 줄 수 있다면 큰 도움이 될 것입니다.JUNIT 테스트 케이스를 실행하는 중 오류가 발생했습니다.

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'commonValuesBackingBean' defined in class path resource [resources/ffms-storevisit-spring.xml]: Cannot resolve reference to bean 'cycleBackingBean' while setting bean property 'cycleBackingBean'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cycleBackingBean' defined in class path resource [resources/ffms-storevisit-spring.xml]: Cannot resolve reference to bean 'cycleManager' while setting bean property 'cycleManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cycleManager' defined in class path resource [resources/ffms-storevisit-spring.xml]: Cannot resolve reference to bean 'cycleBO' while setting bean property 'cycleBO'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cycleBO' defined in class path resource [resources/ffms-storevisit-spring.xml]: Cannot resolve reference to bean 'cycleDAO' while setting bean property 'cycleDAO'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cycleDAO' defined in class path resource [resources/ffms-storevisit-spring.xml]: Cannot resolve reference to bean 'sqlMapClient' while setting bean property 'sqlMapClient'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlMapClient' defined in class path resource [resources/ffms-common-spring.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigParser.parse(Ljava/io/InputStream;Ljava/util/Properties;)Lcom/ibatis/sqlmap/client/SqlMapClient; 
     at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:275) 
     at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:104) 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1245) 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010) 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472) 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409) 
     at java.security.AccessController.doPrivileged(Native Method) 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380) 
     at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264) 
     at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:221) 
     at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261) 
     at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185) 
     at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164) 
     at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429) 
     at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:729) 
     at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:381) 
     at com.newsamerica.BaseTestCase.oneTimeSetUp(BaseTestCase.java:150) 
     at com.newsamerica.BaseTestCase.setUp(BaseTestCase.java:90) 
     at com.newsamerica.integration.dao.ffms.fcoperations.SelectiveRaiDAOTest.setUp(SelectiveRaiDAOTest.java:651) 
     at junit.framework.TestCase.runBare(TestCase.java:128) 
     at junit.framework.TestResult$1.protect(TestResult.java:106) 
     at junit.framework.TestResult.runProtected(TestResult.java:124) 
     at junit.framework.TestResult.run(TestResult.java:109) 
     at junit.framework.TestCase.run(TestCase.java:120) 
     at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130) 
     at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) 
     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) 
     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) 
     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) 
     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) 

내가 실행하려고하는 코드이고,

import java.util.ArrayList; 
import java.util.LinkedList; 
import java.util.List; 
import java.util.Map; 
import com.newsamerica.integration.dao.ffms.dispatchboard.DispatchBoardDAO; 
import com.newsamerica.value.ffms.fcoperations.EnableRAICodeValue; 
import com.newsamerica.value.ffms.fcoperations.SearchRequestLiteValue; 
import com.newsamerica.value.ffms.fcoperations.SearchRequestValue; 
import junit.framework.*; 
import com.newsamerica.BaseTestCase; 

public class SelectiveRaiDAOTest extends BaseTestCase { 
    SelectiveRaiDAO fixture = new SelectiveRaiDAO(); 
public SelectiveRaiDAOTest(){} 
    public void testCheckValidJobChain_1() 
     throws Exception { 
     Map<Object, Object> map = getMethodMap(this,"testCheckValidJobChain_1"); 
     EnableRAICodeValue enableValue = new EnableRAICodeValue(); 
     enableValue.setJobId((String)map.get("JobId")); 
     enableValue.setChainId((String)map.get("ChainId")); 
     enableValue.setWaveNumber((int) Double.parseDouble((String)map.get("WaveNumber"))); 
     boolean result = fixture.checkValidJobChain(enableValue); 
     assertTrue(result); 
     } 
protected void setUp() 
     throws Exception { 
     super.setUp(); 
     fixture = (SelectiveRaiDAO) getContext().getBean(
     "selectiveRaiDAO"); 
     } 
protected void tearDown() 
     throws Exception { 
     super.tearDown(); 
     } 
    public static void main(String[] args) { 
     if (args.length == 0) { 
      junit.textui.TestRunner.run(SelectiveRaiDAOTest.class); 
     } else { 
      TestSuite suite = new TestSuite("Selected tests"); 
      for (int i = 0; i < args.length; i++) { 
       TestCase test = new SelectiveRaiDAOTest(); 
       test.setName(args[i]); 
       suite.addTest(test); 
      } 
      junit.textui.TestRunner.run(suite); 
     } 
    } 

    @Override 
    protected String getPropertyFileName() { 
     return null; 
    } 
} 

설정에서 getContext.getBean 방법 (봄 주입 의미 임)

 import java.io.File; 
import java.io.FileInputStream; 
import java.io.IOException; 
import java.io.InputStream; 
import java.util.Collection; 
import java.util.Map; 
import java.util.ResourceBundle; 

import javax.faces.FactoryFinder; 
import javax.faces.application.ApplicationFactory; 
import javax.faces.component.UIViewRoot; 
import javax.faces.lifecycle.LifecycleFactory; 
import javax.faces.render.RenderKitFactory; 
import javax.sql.DataSource; 
import junit.framework.TestCase; 

import org.apache.commons.dbcp.BasicDataSource; 
import org.apache.shale.test.mock.MockApplication; 
import org.apache.shale.test.mock.MockExternalContext; 
import org.apache.shale.test.mock.MockFacesContext; 
import org.apache.shale.test.mock.MockFacesContextFactory; 
import org.apache.shale.test.mock.MockHttpServletRequest; 
import org.apache.shale.test.mock.MockHttpServletResponse; 
import org.apache.shale.test.mock.MockHttpSession; 
import org.apache.shale.test.mock.MockLifecycle; 
import org.apache.shale.test.mock.MockLifecycleFactory; 
import org.apache.shale.test.mock.MockRenderKit; 
import org.apache.shale.test.mock.MockServletConfig; 
import org.springframework.beans.factory.support.BeanDefinitionRegistry; 
import org.springframework.core.io.FileSystemResourceLoader; 
import org.springframework.mock.web.MockServletContext; 
import org.springframework.web.context.support.XmlWebApplicationContext; 
/* 
* Base spring test class 
*/ 
public abstract class BaseTestCase extends TestCase { 

    public static final String DATA_SOURCE = "com.newsamerica.DataSource"; 

    private static XmlWebApplicationContext context = null; 

    public static InputStream excelFile; 
    public static Collection<Object[]> spreadsheetData; 
    public static SpreadsheetData sheet; 
    public static Map<Object ,Object> paramMap; 
    //private static ShaleMockObjects shaleMockObjects; 
     public static MockApplication   application = null; 
     public static MockServletConfig  config = null; 
     public static MockExternalContext  externalContext = null; 
     public static MockFacesContext  facesContext = null; 
     public static MockFacesContextFactory facesContextFactory = null; 
     public static MockLifecycle   lifecycle = null; 
     public static MockLifecycleFactory lifecycleFactory = null; 
     public static MockRenderKit   renderKit = null; 
     public static MockHttpServletRequest request = null; 
     public static MockHttpServletResponse response = null; 
     public static MockServletContext  servletContext = null; 
     public static MockHttpSession   session = null; 


     public void loadTestSpreadsheet() throws IOException { 

        sheet=new SpreadsheetData(excelFile,null);   

       // System.out.println("k3"); 

       } 


     public DataSource getDataSource() { 
       BasicDataSource realDataSource = new BasicDataSource(); 
       realDataSource.setDriverClassName(getPropertyValue("driverClassName")); 
       realDataSource.setUrl(getPropertyValue("url")); 
       realDataSource.setUsername(getPropertyValue("username")); 
       realDataSource.setPassword(getPropertyValue("password")); 
       return realDataSource; 
      } 

    protected void setUp() throws Exception { 
     try { 


      if (context == null) { 
       super.setUp(); 
       oneTimeSetUp(); 
      } 
     } catch (Exception ex) { 
      //System.out.println(ex.getStackTrace()); 
     } 
    } 

    /* 
    * Setup the testing environment. 
    */ 
    protected void oneTimeSetUp() throws Exception { 
     try { 
      //System.out.println(excelFile); 
      excelFile = new FileInputStream(new File("D:/sure/workspace/NAPI/xxnapi/napi_war/config/resources/n/TestData-spreadsheet.xls")); 
      //System.out.println(excelFile); 
      sheet=new SpreadsheetData(excelFile); 
      //loadTestSpreadsheet(); 
     // spreadsheetData = sheet.getData(); 
       // paramMap=sheet.getMap(); 
       //System.out.println(paramMap); 
      if (context == null) { 
       String[] configFiles = new String[] { 


         "classpath:resources/jndiDataSource.xml", 
         "classpath:resources/ffms-common-spring.xml", 
         "classpath:resources/ffms-storevisit-spring.xml", 
         //"classpath:resources/ffms-cancelorders-faces.xml", 
         "classpath:resources/ffms-dispatchboard-spring.xml", 
         "classpath:resources/ffms-orgstructure-spring.xml", 
         "classpath:resources/ffms-emplookup-spring.xml", 
         "classpath:resources/ffms-exceptions-spring.xml", 
         "classpath:resources/ffms-fcoperations-spring.xml", 
         "classpath:resources/ffms-inventory-spring.xml", 
         "classpath:resources/ffms-jobinformation-spring.xml", 
         "classpath:resources/ffms-jobwavelookup-spring.xml", 
         "classpath:resources/ffms-loginhomepage-spring.xml", 
         "classpath:resources/ffms-manageuser-spring.xml", 
         "classpath:resources/ffms-masterstorelist-spring.xml", 
         "classpath:resources/ffms-messaging-spring.xml", 
         "classpath:resources/ffms-orgstructure-spring.xml", 
         "classpath:resources/ffms-orgstructureadmin-spring.xml", 
         "classpath:resources/ffms-shippinglocation-spring.xml", 
         "classpath:resources/ffms-storelist-spring.xml", 
         "classpath:resources/ffms-storelistassignment-spring.xml", 

         "classpath:resources/ffms-storevisitadmin-spring.xml", 
         "classpath:resources/ffms-survey-spring.xml", 
         "classpath:resources/ffms-tande-spring.xml", 
         "classpath:resources/ffms-tandemain-spring.xml" 
       }; 

       MockServletContext sctx = new MockServletContext(""); 
       context = new XmlWebApplicationContext(); 

       context.setServletContext(sctx); 

       context.setConfigLocations(configFiles); 

       context.setAllowBeanDefinitionOverriding(true); 
       context.refresh(); 
       BeanDefinitionRegistry factory = 
          (BeanDefinitionRegistry) context.getAutowireCapableBeanFactory(); 
       factory.removeBeanDefinition("dataSource"); 
      // context.getBeanFactory().setAllowBeanDefinitionOverriding() 
       context.getBeanFactory().registerSingleton("dataSource",getDataSource()); 
       context.refresh(); 

       // Set up Servlet API Objects 
       // servletContext = new MockServletContext(); 
       // config = new MockServletConfig(servletContext); 
       session = new MockHttpSession(); 
       session.setServletContext(sctx); 
       request = new MockHttpServletRequest(session); 
       session.setId("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXERTXCDFBGFHDHFGDSDFDASSGGGGGG"); 
       request.setServletContext(sctx); 
       response = new MockHttpServletResponse(); 

       // Set up JSF API Objects 
       FactoryFinder.releaseFactories(); 
       FactoryFinder.setFactory(FactoryFinder.APPLICATION_FACTORY, 
       "org.apache.shale.test.mock.MockApplicationFactory"); 
       FactoryFinder.setFactory(FactoryFinder.FACES_CONTEXT_FACTORY, 
       "org.apache.shale.test.mock.MockFacesContextFactory"); 
       FactoryFinder.setFactory(FactoryFinder.LIFECYCLE_FACTORY, 
       "org.apache.shale.test.mock.MockLifecycleFactory"); 
       FactoryFinder.setFactory(FactoryFinder.RENDER_KIT_FACTORY, 
       "org.apache.shale.test.mock.MockRenderKitFactory"); 

       externalContext = 
        new MockExternalContext(sctx, request, response); 
       lifecycleFactory = (MockLifecycleFactory) 
       FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY); 
       lifecycle = (MockLifecycle) 
       lifecycleFactory.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE); 
       facesContextFactory = (MockFacesContextFactory) 
       FactoryFinder.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY); 
       facesContext = (MockFacesContext) 
       facesContextFactory.getFacesContext(sctx, 
         request, 
         response, 
         lifecycle); 
       externalContext = (MockExternalContext) facesContext.getExternalContext(); 
       UIViewRoot root = new UIViewRoot(); 
       root.setViewId("/viewId"); 
       root.setRenderKitId(RenderKitFactory.HTML_BASIC_RENDER_KIT); 
       facesContext.setViewRoot(root); 
       ApplicationFactory applicationFactory = (ApplicationFactory) 
       FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY); 
       application = new MockApplication(); 
       applicationFactory.setApplication(application); 
       facesContext.setApplication(application); 
       RenderKitFactory renderKitFactory = (RenderKitFactory) 
       FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY); 
       renderKit = new MockRenderKit(); 
       renderKitFactory.addRenderKit(RenderKitFactory.HTML_BASIC_RENDER_KIT, renderKit); 
      } 
     } catch (Exception ex) { 
      ex.printStackTrace(); 
      //System.out.println(ex.getStackTrace()); 
     } 
    } 

    public Map<Object, Object> getParamMap() { 
     return paramMap; 
    } 


    public Map<Object, Object> getMethodMap(String methodName) { 
     //System.out.println(methodName+"method name"); 
     // System.out.println(paramMap); 
      return (Map<Object, Object>) paramMap.get(methodName); 
    } 

     public Map<Object, Object> getMethodMap(Object obj,String methodName) { 
      //System.out.println(methodName+"method name"); 
      //System.out.println(obj.getClass().getName()); 
       return (Map<Object, Object>) sheet.getMap(obj.getClass().getName()).get(methodName); 
     } 

    public void setParamMap(Map<Object, Object> paramMap) { 
     this.paramMap = paramMap; 
    } 
    protected void tearDown() throws Exception { 
      //context.destroy(); 
      //context = null; 
      //super.tearDown(); 
     } 
    public String getPropertyValue(String propertyName) { 
     ResourceBundle testData = ResourceBundle 
       .getBundle(DATA_SOURCE); 
     return testData.getString(propertyName); 
    } 

    /** 
    * Gets the Properties file name. 
    * 
    * @return the Properties file name 
    */ 
    protected abstract String getPropertyFileName(); 

    /** 
    * @return the context 
    */ 
    public XmlWebApplicationContext getContext() { 
     return context; 
    } 

    /** 
    * @param context 
    *   the ctx to set 
    */ 
    public void setContext(XmlWebApplicationContext context) { 
     this.context = context; 
    } 

} 
다음 클래스에 존재

열렬히 답장을 기다리고 있습니다. 미리 감사드립니다.

+0

연구를 수행하고 질문에 더 간결해야합니다. –

+2

코드가 너무 많아서 [SSCCE] (http://sscce.org)로 줄여보십시오. 어쨌든, 당신을위한 단서는'Invoke of init method failed; 중첩 예외는 java.lang.NoSuchMethodError입니다. com/lib/lib/lib/lib/lib/클래스 패스에 ibatis-sqlmap의 두 가지 버전이 있습니까? –

+0

답장을 보내 주셔서 감사합니다. 내 클래스 경로에 ibatis-sqlmap 버전이 하나만 있습니다. 나와 함께 곰, 프로그래밍에 익숙하지 않음 – suresh

답변

1

귀하의 CLASSPATH에 ibatis-sqlmap 병이 있습니다. 그런 다음 파일을 열고 (압축 파일이므로) com/ibatis/sqlmap/engine/builder/xml/SqlMapConfigParser.class 파일인지 확인하십시오.

이것이 없다면 이는 jar 파일이 손상되었거나 수정되었음을 의미합니다. 그곳에 있으면 CLASSPATH가 잘못되었습니다.