-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Tests unitaires via Ant : unknown protocol: classpath
PostPosted: Wed Jan 09, 2008 6:38 am 
Newbie

Joined: Wed Jan 09, 2008 6:26 am
Posts: 19
Bonjour,

Je suis passé d'Hibernate 3.1.3 à 3.2.5, en utilisant désormais le protocole classpath:// dans les fichiers .hbm, pour faire des inclusions, du genre:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
   "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
   "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"
   [<!ENTITY common SYSTEM "classpath://x/y/z/Common.hbm">]>

<hibernate-mapping package="x.y">

(...)
&common;
(...)

</hibernate-mapping>


Le lancement de mes tests unitaires à la main fonctionne. Par contre, leur lancement depuis une tâche ant génère l'erreur suivante (unknown protocol: classpath):

Code:
test:
    [junit] Running appli.test.AllTest
    [junit] Testsuite: appli.test.AllTest
    [junit] Tests run: 5, Failures: 0, Errors: 1, Time elapsed: 1,86 sec
    [junit] Tests run: 5, Failures: 0, Errors: 1, Time elapsed: 1,86 sec
    [junit] Testcase: testStringtoArray took 0 sec
    [junit] Testcase: testValidate took 0,047 sec
    [junit] Testcase: testIsCompatible took 0 sec
    [junit] Testcase: testValidateTemporelImpl took 0 sec
    [junit] Testcase: testSaveGetUpdateDeleteTypeIntrant took 1,781 sec
    [junit]    Caused an ERROR
    [junit] Error creating bean with name 'sessionFactory' defined in URL [file:W:/OGIVE/dev/appli/WebContent/WEB-INF/applicationContext-general.xml]: Initialization of bean failed; nested exception is org.hibernate.InvalidMappingException: Could not parse mapping document from input stream
    [junit] org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in URL [file:W:/OGIVE/dev/appli/WebContent/WEB-INF/applicationContext-general.xml]: Initialization of bean failed; nested exception is org.hibernate.InvalidMappingException: Could not parse mapping document from input stream
    [junit] org.hibernate.InvalidMappingException: Could not parse mapping document from input stream
    [junit]    at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:508)
    [junit]    at org.springframework.orm.hibernate3.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:679)
    [junit]    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1091)
    [junit]    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:396)
    [junit]    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:233)
    [junit]    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:145)
    [junit]    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:277)
    [junit]    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:313)
    [junit]    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:87)
    [junit]    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:72)
    [junit]    at org.springframework.test.AbstractSpringContextTests.loadContextLocations(AbstractSpringContextTests.java:135)
    [junit]    at org.springframework.test.AbstractDependencyInjectionSpringContextTests.loadContextLocations(AbstractDependencyInjectionSpringContextTests.java:224)
    [junit]    at org.springframework.test.AbstractSpringContextTests.getContext(AbstractSpringContextTests.java:115)
    [junit]    at org.springframework.test.AbstractDependencyInjectionSpringContextTests.setUp(AbstractDependencyInjectionSpringContextTests.java:192)
    [junit] Caused by: org.dom4j.DocumentException: unknown protocol: classpath Nested exception: [b]unknown protocol: classpath[/b]
    [junit]    at org.dom4j.io.SAXReader.read(SAXReader.java:484)
    [junit]    at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:499)


Je n'arrive pas à trouver ce qui ne va pas, bien qu'un problème similaire ait été mentionné ici:

http://forum.hibernate.org/viewtopic.php?p=2372397

Ma configuration Ant est la suivante:

Code:
<project name="dev" basedir="../" default="war">

   (...)

   <!-- Chemins du projet -->
   <property file="${basedir}/ant/build.properties"/>
   <property name="src.dir" value="${basedir}/src"/>
   <property name="webroot.dir" value="${basedir}/WebContent"/>
   <property name="webinf.dir" value="${webroot.dir}/WEB-INF"/>
   <property name="bin.dir" value="${webinf.dir}/classes"/>
   <property name="build.dir" value="build"/>
   <property name="doc.dir" value="doc"/>
   <property name="doc.javadoc.dir" value="${doc.dir}/javadoc"/>
   <property name="doc.jdepend.dir" value="${doc.dir}/jdepend"/>
   <property name="doc.javancss.dir" value="${doc.dir}/javaNCSS"/>
   <property name="outils.dir" value="outils"/>
   <property name="outils.jdepend.dir" value="${outils.dir}/jdepend"/>
   <property name="outils.javancss.dir" value="${outils.dir}/javaNCSS"/>
   <property name="outils.lib.dir" value="${outils.dir}/lib"/>
   <property name="tomcat.dir" value="C:\Tomcat"/>
   <property name="tomcat.common.lib.dir" value="${tomcat.dir}/common/lib"/>
   <property name="deploy.dir" value="${tomcat.dir}/webapps"/>
   
   <!-- Classpath : librairies JAR du projet -->
   <path id="compile.classpath">
      <fileset dir="${webinf.dir}/lib">
         <include name="*.jar"/>
      </fileset>
      <pathelement path ="${webinf.dir}/classes"/>
      <pathelement path ="${classpath.external}"/>
      <pathelement path ="${classpath}"/>
      <fileset dir="${tomcat.common.lib.dir}">
         <include name="*.jar"/>
      </fileset>
   </path>

   (...)
   
   <!-- Execution des tests JUnit -->
   <target name="test" depends="compile" description="Tests unitaires et d'integration avec JUnit">
      <junit fork="yes" haltonerror="true" haltonfailure="on" printsummary="on">
         <formatter type="plain" usefile="false" />
         <test name="appli.test.AllTest"/>
         <classpath refid="compile.classpath"/>
      </junit>
   </target>

        (...)


Avez-vous une piste? Je galère et ne trouve pas... ;-)

Merci!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 09, 2008 2:22 pm 
Newbie

Joined: Wed Jan 09, 2008 6:26 am
Posts: 19
J'ai finalement découvert que les tests unitaires lancés par Ant sur les classes de mon projet compilées par Eclipse fonctionnent, alors qu'ils ne fonctionnent pas sur ces mêmes classes recompilées par Ant.

J'en déduis donc qu'il y a une différence entre la compilation Ant et la compilation Eclipse... mais je ne vois pas quoi! Qu'est-ce qui peut bien provoquer une telle erreur (unknown protocol: classpath): le parseur XML, la librairie Hibernate... ???


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.