2012-09-04 1 views
2

maven을 통해 부두를 실행할 때 테스트/리소스 폴더에있는 jndi.properties 파일을로드하는 방법을 찾고 있습니다. extraClasspath 및 scannTargetPatterns를 사용하여 작업하려고 시도했지만 아무 것도 작동하지 않습니다. 아래에서 부두를 시작하고 멈추는 내 동전의 발췌 문장을 찾을 수 있습니다. 파일은에 있습니다 SRC/테스트/자원/jndi_folder/local_jndi.properties 및 SRC/테스트/자원/jndi_folder/remote_jndi.propertiesjetty-maven-pluggin을 통한 통합 테스트는 .properties 파일을 읽지 않습니다.

내 콘솔에서이 출력을 얻을 때문에 scanTargetPatterns 그들을 데리러 :

[INFO] Adding extra scan target from pattern: services/src/test/resources/jndi_folder /local_jndi.properties 
[INFO] Adding extra scan target from pattern: services/src/test/resources/jndi_folder/remote_jndi.properties 

하지만 내 통합 테스트를 실행할 때 내 코드가 .properties 파일을 찾을 수 없다는 nullpointer가 발생합니다.

<plugin> 
      <groupId>org.mortbay.jetty</groupId> 
      <artifactId>maven-jetty-plugin</artifactId> 
      <version>6.1.26</version> 
      <configuration> 
       <scanIntervalSeconds>0</scanIntervalSeconds> 
       <connectors> 
        <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector"> 
         <port>8080</port> 
         <maxIdleTime>60000</maxIdleTime> 
        </connector> 
       </connectors> 
       <webApp> 
        ${basedir}/target/messages 
       </webApp> 
       <contextPath> 
        messages 
       </contextPath> 
       <stopKey>stop</stopKey> 
       <stopPort>8005</stopPort> 
       <daemon>true</daemon> 
       <scanTargetPatterns> 
        <scanTargetPattern> 
         <directory> 
          ${basedir}/src/test/resources 
         </directory> 
         <includes> 
          <include>**/*.properties</include> 
         </includes> 
        </scanTargetPattern> 
       </scanTargetPatterns> 
      </configuration> 
      <executions> 
       <execution> 
        <id>start-jetty</id> 
        <phase>pre-integration-test</phase> 
        <goals> 
         <goal>run</goal> 
        </goals> 
       </execution> 
       <execution> 
        <id>stop-jetty</id> 
        <phase>post-integration-test</phase> 
        <goals> 
         <goal>stop</goal> 
        </goals> 
       </execution> 
      </executions> 

누구든지 나를 도와 줄 수 있다면 좋을 것입니다.

건배

답변

1

시도 구성 태그에 다음과 같은 추가 :

<useTestClasspath>true</useTestClasspath> 
관련 문제