<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet title="XSL formatting" type="text/xsl" href="http://blog.netapsys.fr/index.php/feed/rss2/xslt" ?><rss version="2.0"
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:wfw="http://wellformedweb.org/CommentAPI/"
  xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
  <title>Netapsys Blog - annotations</title>
  <link>http://blog.netapsys.fr/index.php/</link>
  <description></description>
  <language>fr</language>
  <pubDate>Tue, 07 Sep 2010 08:07:18 +0200</pubDate>
  <copyright>Netapsys 2008 - 2009</copyright>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Dotclear</generator>
  
    
  <item>
    <title>Tests JUnit4 combiné avec Spring et Spring MVC en mode transactionnel</title>
    <link>http://blog.netapsys.fr/index.php/post/2009/01/08/Tests-Unitaires-et-dintegration-avec-Junit4-et-Spring-MVC-en-mode-transactionnel</link>
    <guid isPermaLink="false">urn:md5:a20f1b6fc0438b9a6560a953cc84b57f</guid>
    <pubDate>Fri, 17 Apr 2009 16:18:00 +0200</pubDate>
    <dc:creator>Abderrazek CHINE</dc:creator>
        <category>Java</category>
        <category>annotations</category><category>controlleurs</category><category>DAO</category><category>dataSource</category><category>framework</category><category>java</category><category>JEE</category><category>junit4</category><category>Junit4</category><category>netapsys</category><category>servlet</category><category>spring</category><category>Spring</category><category>spring 2.5</category><category>spring MVC</category><category>springframework</category><category>tests dintégration</category><category>tests unitaires</category><category>transaction</category><category>transactionManager</category><category>transactionnel</category><category>Web</category><category>webapp</category>    
    <description>&lt;p&gt;Le titre de ce billet montre bien l'étendue des thèmes variés qui seront traités. Il a pour objectif d'illustrer, à l'aide d'un exemple assez complet et proche des cas réels, la mise en place des tests, en mode transactionnel, pour les différentes couches applicatives. Ainsi les vraies difficultés rencontrées par les développeurs seront évoquées.
&lt;br /&gt;
Le billet traite &lt;a href=&quot;http://blog.netapsys.fr/index.php/tag/JUnit4&quot;&gt;JUnit4&lt;/a&gt; enrichi avec les annotations de &lt;a href=&quot;http://blog.netapsys.fr/index.php/tag/Spring&quot;&gt;Spring&lt;/a&gt; 2.5+ et ses lanceurs pour exécuter facilement les tests.
Des illustrations en mode transactionnel vous sont proposées à la fin de ce billet.&lt;br /&gt;
Le framework JUnit est l'oeuvre conjointe de Kent Beck (créateur de XP) et Erich Gamma (auteur des Design Patterns).&lt;br /&gt;
Avec la version 4, JUnit tente de rattraper son retard sur Testng tout en gardant la compatibilité avec JUnit3x ainsi qu'une parfaite intégration aux éditeurs Eclipse, Netbeans, ...
&lt;br /&gt;
Avec les lanceurs de spring, les tests deviennent plus attrayants. Spring encourage ainsi à adopter l'approche TDD &quot;Test Driven Design&quot; ou &quot;Test-First Developpment&quot;. &lt;br /&gt;
Notez que le jdk5+ est nécessaire pour certaines parties de code Java. Les commentaires dans le code java le mentionnent au bon endroit.
&lt;br /&gt;&lt;/p&gt;    &lt;p&gt;Le framework JUnit est l'oeuvre conjointe de Kent Beck (créateur de XP) et Erich Gamma (auteur des Design Patterns).&lt;br /&gt;
Avec la version 4, JUnit tente de rattraper son retard sur Testng tout en gardant la compatibilité avec JUnit3x ainsi qu'une parfaite intégration aux éditeurs Eclipse, Netbeans, ...
&lt;br /&gt;
&lt;br /&gt;
La pratique des tests unitaires est l'un des principes des méthodes agiles. Il semble que tous les nouveaux frameworks renforcent le principe de testabilité de toutes les couches applicatives.
&lt;br /&gt;
Avec JUnit4 et Spring, les tests, en particulier d'intégration, deviennent aisés. Ceux ayant pratiqués les tests savent bien les efforts nécessaires afin de tester certaines couches( par exemple, la couche de persistance ou &lt;a href=&quot;http://blog.netapsys.fr/index.php/tag/DAO&quot;&gt;DAO&lt;/a&gt;).
&lt;br /&gt;
Citons au passage, qu' un critère majeur permettant de juger de la suffisance des tests peut être&amp;nbsp;:
&lt;br /&gt;
&lt;em&gt;L'investissement fait en tests doit être égal à celui passé sur le design. Et si le design répond facilement au changement alors les tests sont suffisants&lt;/em&gt;.
&lt;br /&gt;
L'un des avantages des tests est d'avoir un retour (feedback) rapide et beaucoup moins cher sur les réglages à apporter au logiciel et ainsi d'anticiper les anomalies.
&lt;br /&gt;
Le second avantage des tests (unitaires et d'intégration) est de limiter le nombre d'itérations (en phase recette/production) de mise en conformité du logiciel.&lt;br /&gt;
Et, par conséquent, de réduire son coût total. Signalons qu'en phase de mise en recette/production les personnes impliquées sont de diverses compétences d'où le coût économique élevé d'une itération à ce stade!
&lt;br /&gt;
La figure suivante résume les objectifs des différents types de tests pour un projet. &lt;img src=&quot;http://blog.netapsys.fr/public/images/.fig1_schems-tests_s.jpg&quot; alt=&quot;tests-synthese&quot; style=&quot;display:block; margin:0 auto;&quot; /&gt;
&lt;br /&gt;
La bonne compréhension de ce billet nécessite d'avoir certains pré-requis énoncés plus loin. A défaut, au préalable, lire &lt;a href=&quot;http://blog.netapsys.fr/index.php/post/2008/04/13/Introduction-A-Spring-MVC&quot; hreflang=&quot;fr&quot;&gt;article&lt;/a&gt; sur le blog &lt;a href=&quot;http://blog.netapsys.fr/index.php/tag/Netapsys&quot;&gt;Netapsys &lt;/a&gt;. Par contre, l'utilisation de &lt;a href=&quot;http://blog.netapsys.fr/index.php/tag/Spring&quot;&gt;Spring&lt;/a&gt; avec JUnit4 n'exige en aucun cas de maîtriser &lt;a href=&quot;http://blog.netapsys.fr/index.php/tag/Spring&quot;&gt;Spring&lt;/a&gt;.
&lt;br /&gt;
&lt;br /&gt;
Dans l'exemple détaillé plus loin, Spring 2.5 allège considérablement la configuration XML. &lt;br /&gt;
De plus, les principes &quot;ZERO CONFIGURATION&quot; et/ou &quot;CONVENTION OVER CONFIGURATION&quot; permettent d'alléger plus les fichiers de configuration xml.
&lt;br /&gt;
La présentation de ce billet est divisée en trois grandes parties:
&lt;br /&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Créer une application Web &lt;a href=&quot;http://blog.netapsys.fr/index.php/tag/Java&quot;&gt;Java&lt;/a&gt; &lt;a href=&quot;http://blog.netapsys.fr/index.php/tag/JEE&quot;&gt;JEE&lt;/a&gt; avec Maven2, &lt;a href=&quot;http://blog.netapsys.fr/index.php/tag/SpringMVC&quot;&gt;SpringMVC&lt;/a&gt; et ses annotations (en particulier &lt;a href=&quot;http://blog.netapsys.fr/index.php/tag/%40Controller&quot;&gt;@Controller&lt;/a&gt;) (Voir &lt;a href=&quot;http://blog.netapsys.fr/index.php/post/2008/04/13/Introduction-A-Spring-MVC&quot; hreflang=&quot;fr&quot;&gt;article&lt;/a&gt; sur le blog &lt;a href=&quot;http://blog.netapsys.fr/index.php/tag/Netapsys&quot;&gt;Netapsys &lt;/a&gt; pour les étapes de création d’un projet sous eclipse avec maven2)&amp;nbsp;;&lt;/li&gt;
&lt;li&gt;Mettre en place, via le &lt;a href=&quot;http://blog.netapsys.fr/index.php/tag/framework&quot;&gt;framework&lt;/a&gt; &lt;a href=&quot;http://blog.netapsys.fr/index.php/tag/JUnit4&quot;&gt;JUnit4&lt;/a&gt;.x, des &lt;a href=&quot;http://blog.netapsys.fr/index.php/tag/tests%20unitaires&quot;&gt;tests unitaires&lt;/a&gt; et des &lt;a href=&quot;http://blog.netapsys.fr/index.php/tag/tests%20dint%C3%A9gration&quot;&gt;tests d'intégration&lt;/a&gt; couvrant l'ensemble des couches applicatives (couches Dao, Service et Web en SpringMVC)&amp;nbsp;;&lt;/li&gt;
&lt;li&gt;Enfin,  exécution des tests en mode &lt;a href=&quot;http://blog.netapsys.fr/index.php/tag/transaction&quot;&gt;transaction&lt;/a&gt;nel. Les codes sources présentés sont disponibles en annexe&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;PREREQUIS&lt;/strong&gt;
&lt;br /&gt;
&lt;br /&gt;
Les pré-requis suivants aideront à lire facilement ce billet. Mais tous ne sont pas nécessaires à sa compréhension.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Connaissance des applications Web dans le monde JEE (servlet, jsp..)&amp;nbsp;;&lt;/li&gt;
&lt;li&gt;Connaissance sommaire de &lt;a href=&quot;http://blog.netapsys.fr/index.php/tag/Spring&quot;&gt;Spring&lt;/a&gt;, &lt;a href=&quot;http://blog.netapsys.fr/index.php/tag/Spring%20MVC&quot;&gt;Spring MVC&lt;/a&gt; avec ses &lt;a href=&quot;http://blog.netapsys.fr/index.php/tag/annotations&quot;&gt;annotations&lt;/a&gt;&amp;nbsp;;&lt;/li&gt;
&lt;li&gt;Connaissance sommaire de &lt;a href=&quot;http://blog.netapsys.fr/index.php/tag/JUnit4.x&quot;&gt;JUnit4.x&lt;/a&gt; avec ses annotations&amp;nbsp;;&lt;/li&gt;
&lt;li&gt;Connaissance sommaire de la notion de transaction.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;ETAPE 1. Application Web avec Spring MVC&lt;/strong&gt;
&lt;br /&gt;
&lt;br /&gt;
Pour toute la suite, l’application Web exemple sera nommée «spring-mvc-webapp». C’est le nom de la servlet frontale dans le fichier web.xml.
&lt;br /&gt;
Commençons par configurer le fichier &lt;em&gt;web.xml&lt;/em&gt; dont voici le contenu (certaines lignes peuvent encore être simplifiées mais sont laissées ici pour une meilleure compréhension)&amp;nbsp;:
&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;xml&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;web-app&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; 
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;context-param&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; 
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;param-name&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;contextConfigLocation&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/param-name&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;param-value&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
/WEB-INF/spring-mvc-webapp-servlet.xml, classpath:/spring.xml
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/param-value&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/context-param&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; 
&amp;nbsp;
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;listener&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; 
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;listener-class&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;org.springframework.web.context.ContextLoaderListener&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/listener-class&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/listener&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; 
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!-- déclare la servlet frontal --&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;servlet&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; 
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;servlet-name&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;spring-mvc-webapp&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/servlet-name&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;servlet-class&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;org.springframework.web.servlet.DispatcherServlet&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/servlet-class&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;load-on-startup&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;1&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/load-on-startup&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/servlet&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; 
 &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!-- les requêtes se terminant par .html sont servies par cette servlet --&amp;gt;&lt;/span&gt;&lt;/span&gt; 
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;servlet-mapping&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; 
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;servlet-name&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;spring-mvc-webapp&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/servlet-name&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;url-pattern&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;*.html&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/url-pattern&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/servlet-mapping&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; 
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/web-app&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;&lt;br /&gt;
&lt;br /&gt;Notons que l'arborescence du projet sera donnée dans l'annexe de ce billet.
&lt;br /&gt;
La partie 'contextConfigLocation' sera explicitée plus loin&amp;nbsp;: on reviendra en détail sur les fichiers spring*.xml.
&lt;br /&gt;
Le «listener» permet de configurer le contexte du Spring MVC.
&lt;br /&gt;
Le bloc &quot;&amp;lt;servlet&amp;gt;...&amp;lt;/servlet&amp;gt;&quot; permet d'identifier la servlet frontale de Spring MVC chargée de répondre à toutes les requêtes (*.html) d'un client de l’application Web.
&lt;br /&gt;
La section suivante détaille le fichier «spring-mvc-webapp-servlet.xml», nommé ainsi conformément à la convention.&lt;/p&gt;


&lt;p&gt;&lt;strong&gt;ETAPE 2. Configuration de Spring MVC&lt;/strong&gt;&lt;/p&gt;


&lt;p&gt;Le fichier «spring-mvc-webapp-servlet.xml» doit contenir ces lignes&amp;nbsp;:
&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;xml&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;?xml&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;version&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;1.0&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;encoding&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;UTF-8&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!-- Fichier de conf du contexte d'application pour Spring (fichier nommé spring-mvc-webapp-servlet.xml selon la convention. --&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;beans&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;xmlns&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;http://www.springframework.org/schema/beans&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;xmlns:xsi&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;http://www.w3.org/2001/XMLSchema-instance&amp;quot;&lt;/span&gt;
		&lt;span style=&quot;color: #000066;&quot;&gt;xmlns:p&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;http://www.springframework.org/schema/p&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;xmlns:context&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;http://www.springframework.org/schema/context&amp;quot;&lt;/span&gt;
		&lt;span style=&quot;color: #000066;&quot;&gt;xsi:schemaLocation&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
				http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd&amp;quot;&lt;/span&gt;
				&lt;span style=&quot;color: #000066;&quot;&gt;default-autowire&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;byName&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!-- - Tous les controlleurs sont automatiquement détectés grâce à l'annotation @Controller.
		- On définit ici dans quel package le post processor doit chercher ces beans annotés.	--&amp;gt;&lt;/span&gt;&lt;/span&gt;
&amp;nbsp;
  	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;context:component-scan&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;base-package&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;com.netapsys.fr.springmvc.web&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;	  	
&amp;nbsp;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!-- Activates various annotations to be detected in bean classes: Spring's
		@Required and @Autowired, as well as JSR 250's @PostConstruct,@PreDestroy and 
		@Resource (if available) and JPA's @PersistenceContext &amp;amp; @PersistenceUnit.
	--&amp;gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;context:annotation-config&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!--
		- Les controlleurs de cette application fournissent une annotation @RequestMapping 
		- Ils peuvent être déclarés de deux manière différentes:
		-  Au niveau de la classe : 
		-      par exemple @RequestMapping(&amp;quot;/addVisit.html&amp;quot;)
		-      Pour ce type de controlleurs on peut annoter les méthodes pour une requete Post ou Get,
		- Au niveau de chaque méthode. Différents exemples seront fournis.
	--&amp;gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;bean&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;class&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!--
		Ceci est le view resolver, il permet de définir la technologie de vue utilisée et comment
		sélectionner une vue. On prendra ici la solution la plus simple : elle permet de mapper 
		le nom de la vue retournée avec la sélection d'une jsp. Ex. : si le nom de la vue retournée est &amp;quot;hello&amp;quot; alors on utilisera le fichier
		WEB-INF/jsp/hello.jsp pour construire la vue. 
	--&amp;gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;bean&lt;/span&gt; 
	 &lt;span style=&quot;color: #000066;&quot;&gt;class&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;org.springframework.web.servlet.view.InternalResourceViewResolver&amp;quot;&lt;/span&gt; 
	 &lt;span style=&quot;color: #000066;&quot;&gt;p:prefix&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;/WEB-INF/jsp/&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;p:suffix&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;.jsp&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/beans&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
En dehors des commentaires et explications, ce fichier contient peu de lignes. Et même si le projet continue à grossir, ce fichier de configuration n'évolue que très peu.
&lt;br /&gt;
Soulignons que l’emploi des namespaces (par exemple mlns:context) réduit énormément la verbosité de la configuration XML de Spring.
&lt;br /&gt;
La dernière ligne définit la vue retournée en réponse à une requête http.
&lt;br /&gt;
&lt;em&gt;Remarque importante&lt;/em&gt;: dans le fichier web.xml déjà présenté, la variable «contextConfigLocation» pointe, entre autres, vers le fichier &quot;spring.xml&quot;. Et ceci afin que le contexte de l’application Web charge aussi d’autres beans nécessaires. Attention, en l'absence de cette indication, vous seriez en face d’exceptions difficiles à déchiffrer&amp;nbsp;!
&lt;br /&gt;
La classe du &quot;controller de SpringMVC&quot; est nommée &quot;ClientControllerSpringMVC.java&quot;. Le controller se charge de traiter les requêtes transmises par la servlet dispatcher de SpringMVC en réponse aux requêtes http du client de l'application web.
&lt;br /&gt;&lt;/p&gt;


&lt;p&gt;&lt;strong&gt;Controller de spring MVC&lt;/strong&gt;
&lt;br /&gt;
Le code de la classe multi-controller Spring mVC &quot;ClientControllerSpringMVC.java&quot; est comme suit:
&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;java&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;package&lt;/span&gt; com.&lt;span style=&quot;color: #006600;&quot;&gt;netapsys&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;fr&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;springmvc&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;web&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import org.apache.log4j.Logger;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import org.springframework.beans.factory.annotation.Autowired;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import org.springframework.stereotype.Controller;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import org.springframework.ui.ModelMap;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import org.springframework.validation.BindingResult;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import org.springframework.web.bind.annotation.ModelAttribute;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import org.springframework.web.bind.annotation.RequestMapping;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import org.springframework.web.bind.annotation.RequestMethod;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import org.springframework.web.bind.annotation.RequestParam;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import org.springframework.web.bind.support.SessionStatus;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import com.netapsys.fr.springmcv.entites.Client;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import com.netapsys.fr.springmvc.exceptions.MyException;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import com.netapsys.fr.springmvc.service.MyService;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import com.netapsys.fr.springmvc.tb.constants.Constants;&lt;/span&gt;
&amp;nbsp;
@Controller&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;clientControllerSpring&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt; ClientControllerSpringMVC &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;private&lt;/span&gt; MyService myService&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	@Autowired
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;void&lt;/span&gt; setMyService&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;MyService myService&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;myService&lt;/span&gt; = myService&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;final&lt;/span&gt; Logger logger=Logger.&lt;span style=&quot;color: #006600;&quot;&gt;getLogger&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;getClass&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;getName&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/**
	 * Handler de la méthode Get pour l'URL /getClientSpringMVC.html. 
	 * @param nom le nom du theme affiché dans la vue.
	 * @param prenom 
	 * @param model une map de toutes les données qui seront utilisables dans la vue 
	 * @return le &amp;lt;code&amp;gt;Constants.SUCCESS or Constants.ECHEC&amp;lt;/code&amp;gt; nom de la vue qu'il faudra utiliser.
	 */&lt;/span&gt;
	@RequestMapping&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;value=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;/getClient.html&amp;quot;&lt;/span&gt;,method = RequestMethod.&lt;span style=&quot;color: #006600;&quot;&gt;GET&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt;  &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; getClient&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;@RequestParam&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;value=Constants.&lt;span style=&quot;color: #006600;&quot;&gt;ATTRIBUTE_NAME&lt;/span&gt;,required=&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; nom,
			@RequestParam&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;value=Constants.&lt;span style=&quot;color: #006600;&quot;&gt;ATTRIBUTE_LASTNAME&lt;/span&gt;,required=&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; prenom,ModelMap model&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		Client client=myService.&lt;span style=&quot;color: #006600;&quot;&gt;getClient&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;nom, prenom&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		&lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;client&lt;span style=&quot;color: #66cc66;&quot;&gt;!&lt;/span&gt;=&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;null&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;  &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
			logger.&lt;span style=&quot;color: #006600;&quot;&gt;info&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&amp;gt;&amp;gt;Client '&amp;quot;&lt;/span&gt;+prenom+&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot; &amp;quot;&lt;/span&gt;+nom+&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;'  existe.&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
			model.&lt;span style=&quot;color: #006600;&quot;&gt;addAttribute&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;client&amp;quot;&lt;/span&gt;,client&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
			&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;return&lt;/span&gt; Constants.&lt;span style=&quot;color: #006600;&quot;&gt;SUCCESS&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt; 
		&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #b1b100;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
			model.&lt;span style=&quot;color: #006600;&quot;&gt;addAttribute&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;errorMsg&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Client '&amp;quot;&lt;/span&gt;+prenom+&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot; &amp;quot;&lt;/span&gt;+nom+&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;' inexistant&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
			&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;return&lt;/span&gt; Constants.&lt;span style=&quot;color: #006600;&quot;&gt;ECHEC&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
	@RequestMapping&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;value=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;/createClient.html&amp;quot;&lt;/span&gt;,method = RequestMethod.&lt;span style=&quot;color: #006600;&quot;&gt;GET&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; createClient&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;	@RequestParam&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;value=Constants.&lt;span style=&quot;color: #006600;&quot;&gt;ATTRIBUTE_NAME&lt;/span&gt;,required=&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; nom,
			@RequestParam&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;value=Constants.&lt;span style=&quot;color: #006600;&quot;&gt;ATTRIBUTE_LASTNAME&lt;/span&gt;,required=&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; prenom,	ModelMap model&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		Client client=&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;null&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;try&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
			client=myService.&lt;span style=&quot;color: #006600;&quot;&gt;createClient&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt; nom, prenom&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;catch&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;MyException e&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;e.&lt;span style=&quot;color: #006600;&quot;&gt;printStackTrace&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;			
		model.&lt;span style=&quot;color: #006600;&quot;&gt;addAttribute&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;client&amp;quot;&lt;/span&gt;,client&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		logger.&lt;span style=&quot;color: #006600;&quot;&gt;info&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;client created=&amp;quot;&lt;/span&gt;+client&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;return&lt;/span&gt; Constants.&lt;span style=&quot;color: #006600;&quot;&gt;SUCCESS&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
	@RequestMapping&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;value=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;/updateClient.html&amp;quot;&lt;/span&gt;,method = RequestMethod.&lt;span style=&quot;color: #006600;&quot;&gt;POST&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; updateClient&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;	@ModelAttribute&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;client&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; Client client,BindingResult result, SessionStatus status&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		logger.&lt;span style=&quot;color: #006600;&quot;&gt;info&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Client to update &amp;quot;&lt;/span&gt;+client.&lt;span style=&quot;color: #006600;&quot;&gt;toString&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		myService.&lt;span style=&quot;color: #006600;&quot;&gt;updateClient&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;	client.&lt;span style=&quot;color: #006600;&quot;&gt;getCliId&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;, client.&lt;span style=&quot;color: #006600;&quot;&gt;getCliNom&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;,client.&lt;span style=&quot;color: #006600;&quot;&gt;getCliPrenom&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		status.&lt;span style=&quot;color: #006600;&quot;&gt;setComplete&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		logger.&lt;span style=&quot;color: #006600;&quot;&gt;info&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&amp;gt;&amp;gt;&amp;gt;Client update OK&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;null&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
Notez que la classe est annotée avec le stéréotype @Controller. Ainsi ses méthodes vont être analysées par la servlet dispatcher pour traiter toutes les requêtes(*.html). L'auto-détection de Spring2.5 va scanner, via &amp;lt;context:component-scan&amp;gt; du fichier spring-mvc-webapp-servlet.xml, les beans dans les packages mentionnés.
&lt;br /&gt;
Noter également la présence d'autres stéréotypes @repository ou @Service qui sont commentés dans le code java.
&lt;br /&gt;
Mises à part les annotations @RequestMapping et @RequestParam, le &quot;controller&quot; ne fait qu'appeler les méthodes de la couche service.
&lt;br /&gt;
Cette dernière couche est détaillée ci-après. Mais avant cela, la section suivante présente le contenu du fichier spring.xml.
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;ETAPE 3. Configuration Spring des beans des couches DAO et Service&lt;/strong&gt;
&lt;br /&gt;
&lt;br /&gt;
Le fichier de configuration Spring nommé spring.xml (pas de convention ici !) sert à déclarer les beans métier qui seront consommés par l’application Web.
Il indique les packages java à scanner pour l'auto-injection de ces beans. Enfin, il déclare une dataSource pour la couche DAO.&lt;/p&gt;

&lt;pre class=&quot;xml&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;?xml&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;version&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;1.0&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;encoding&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;UTF-8&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!-- spring.xml --&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;beans&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;xmlns&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;http://www.springframework.org/schema/beans&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;xmlns:xsi&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;http://www.w3.org/2001/XMLSchema-instance&amp;quot;&lt;/span&gt;
		&lt;span style=&quot;color: #000066;&quot;&gt;xmlns:p&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;http://www.springframework.org/schema/p&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;xmlns:context&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;http://www.springframework.org/schema/context&amp;quot;&lt;/span&gt;
		&lt;span style=&quot;color: #000066;&quot;&gt;xmlns:tx&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;http://www.springframework.org/schema/tx&amp;quot;&lt;/span&gt;
		&lt;span style=&quot;color: #000066;&quot;&gt;xmlns:aop&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;http://www.springframework.org/schema/aop&amp;quot;&lt;/span&gt;
		&lt;span style=&quot;color: #000066;&quot;&gt;xsi:schemaLocation&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
		http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
		http://www.springframework.org/schema/aop http://www.springframework.org/schema/tx/spring-aop-2.5.xsd
		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd&amp;quot;&lt;/span&gt;
		&lt;span style=&quot;color: #000066;&quot;&gt;__default-autowire__&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;byName&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!--
		Activates various annotations to be detected in bean classes: Spring's
		@Required and @Autowired, as well as JSR 250's @PostConstruct,
		@PreDestroy and @Resource (if available) and JPA's @PersistenceContext
		and @PersistenceUnit (if available).
	--&amp;gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;context:annotation-config&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;
&amp;nbsp;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;context:component-scan&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;base-package&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;com.netapsys.fr.springmvc.dao&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;
        &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;context:component-scan&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;base-package&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;com.netapsys.fr.springmvc.service&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;
&amp;nbsp;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;bean&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;dataSource&amp;quot;&lt;/span&gt; 
		&lt;span style=&quot;color: #000066;&quot;&gt;class&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;org.apache.commons.dbcp.BasicDataSource&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
		&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;property&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;name&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;driverClassName&amp;quot;&lt;/span&gt;
			&lt;span style=&quot;color: #000066;&quot;&gt;value&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;com.mysql.jdbc.Driver&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
		&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/property&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
		&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;property&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;name&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;url&amp;quot;&lt;/span&gt;
			&lt;span style=&quot;color: #000066;&quot;&gt;value&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;jdbc:mysql://localhost:3306/test&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
		&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/property&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
		&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;property&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;name&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;username&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;value&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;root&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/property&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
		&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;property&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;name&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;password&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;value&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;root&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/property&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/bean&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/beans&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;ETAPE 4. Classes DAO et Service &lt;/strong&gt;
&lt;br /&gt;
&lt;br /&gt;
- Couche DAO&amp;nbsp;:&lt;/p&gt;

&lt;pre&gt;Notez que cette couche utilise deux classes beans d'entités ( Client.java et Personne.java). Leurs codes, simples, sont donnés en annexe.&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
Le code de l'interface IDao.java contient&amp;nbsp;:
&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;java&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;package&lt;/span&gt; com.&lt;span style=&quot;color: #006600;&quot;&gt;netapsys&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;fr&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;springmvc&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;dao&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import com.netapsys.fr.springmcv.entites.Client;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import com.netapsys.fr.springmvc.exceptions.MyException;&lt;/span&gt;
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;interface&lt;/span&gt; IDao  &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
  &lt;span style=&quot;color: #993333;&quot;&gt;boolean&lt;/span&gt; isExistId&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; id&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
  &lt;span style=&quot;color: #993333;&quot;&gt;boolean&lt;/span&gt; findByName&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; nom&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
  Client getClient&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; nom&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
  Client getClient&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; nom,&lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; prenom&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
  Client getClient&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #993333;&quot;&gt;long&lt;/span&gt; id&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
  Client createClient&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; nom, &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; prenom&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;throws&lt;/span&gt; MyException&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
  Client updateClient&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #993333;&quot;&gt;long&lt;/span&gt; id,&lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; nom, &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; prenom&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
  &lt;span style=&quot;color: #993333;&quot;&gt;void&lt;/span&gt; deleteClient&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #993333;&quot;&gt;long&lt;/span&gt; id&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;&lt;br /&gt;
Et l'implémentation de cette interface est faite dans la classe DaoImpl.java qui contient les lignes suivantes&amp;nbsp;:
&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;java&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;package&lt;/span&gt; com.&lt;span style=&quot;color: #006600;&quot;&gt;netapsys&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;fr&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;springmvc&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;dao&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import java.sql.ResultSet;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import java.sql.SQLException;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import javax.sql.DataSource;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import org.apache.log4j.Logger;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import org.springframework.beans.factory.annotation.Autowired;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import org.springframework.dao.DataAccessException;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import org.springframework.jdbc.core.simple.ParameterizedRowMapper;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import org.springframework.jdbc.core.simple.SimpleJdbcTemplate;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import org.springframework.stereotype.Repository;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import com.netapsys.fr.springmcv.entites.Client;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import com.netapsys.fr.springmvc.tb.constants.Constants;&lt;/span&gt;
@&lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;Repository&lt;/span&gt; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/** @Repository  un marqueur Spring pour, entre autres, auto-translater les exception de la couche de persistance.**/&lt;/span&gt;
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt; DaoImpl &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;implements&lt;/span&gt; IDao&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;final&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;private&lt;/span&gt; Logger logger = Logger.&lt;span style=&quot;color: #006600;&quot;&gt;getLogger&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;getClass&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;getName&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/**
	 * spring template for jdbc (jdk 5ou+)
	 */&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;private&lt;/span&gt; SimpleJdbcTemplate jt=&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;null&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;	
	@SuppressWarnings&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;unused&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;private&lt;/span&gt; DataSource dataSource&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	@Autowired
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;void&lt;/span&gt; setDataSource&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;DataSource dataSource&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//Recommandation de spring: Initialiser SimpleJdbcTemplate ici avec new lorsqu'une seule datasource est nécessaire!&lt;/span&gt;
		jt=&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; SimpleJdbcTemplate&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;dataSource&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
	&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/* (non-Javadoc)
	 * @see com.netapsys.springmvc.metier.IService#getClient(java.lang.String)
	 */&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; Client getClient&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; nom&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;return&lt;/span&gt; getClient&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;nom,&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;null&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; Client getClient&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #993333;&quot;&gt;long&lt;/span&gt; id&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;return&lt;/span&gt; getClient&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;valueOf&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;id&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;  &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;	
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;	
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; Client getClient&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; nom, &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; prenom&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		&lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; sql=Constants.&lt;span style=&quot;color: #006600;&quot;&gt;SQL_REQUETE_CLIENT&lt;/span&gt; + &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;  WHERE upper(CLINOM)='&amp;quot;&lt;/span&gt;+nom.&lt;span style=&quot;color: #006600;&quot;&gt;toUpperCase&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;+&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;'&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		&lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;prenom&lt;span style=&quot;color: #66cc66;&quot;&gt;!&lt;/span&gt;=&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;null&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;!&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;equals&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;prenom&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; 
			sql+=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot; AND upper(CLIPRENOM)='&amp;quot;&lt;/span&gt;+prenom.&lt;span style=&quot;color: #006600;&quot;&gt;toUpperCase&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;+&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;'&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		&lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;!&lt;/span&gt;findByName&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;nom&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
			&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;Client&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;null&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;	&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//Si nom n existe pas dans bd renvoie null;&lt;/span&gt;
		&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
		ParameterizedRowMapper&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;lt;&lt;/span&gt;Client&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;gt;&lt;/span&gt;  mapper=&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; ParameterizedRowMapper&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;lt;&lt;/span&gt;Client&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
			&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; Client mapRow&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;ResultSet&lt;/span&gt; rs,&lt;span style=&quot;color: #993333;&quot;&gt;int&lt;/span&gt; rowNm&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;throws&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;SQLException&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;				
				&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;return&lt;/span&gt; populateClient&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;rs&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;				
			&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
		&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		Client client=jt.&lt;span style=&quot;color: #006600;&quot;&gt;queryForObject&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;sql, mapper&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		logger.&lt;span style=&quot;color: #006600;&quot;&gt;info&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;get Client = &amp;quot;&lt;/span&gt;+client&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;return&lt;/span&gt; client&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;private&lt;/span&gt; Client populateClient&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;final&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;ResultSet&lt;/span&gt; rs&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;throws&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;SQLException&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		&lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;rs==&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;null&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;null&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		Client client=&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; Client&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		client.&lt;span style=&quot;color: #006600;&quot;&gt;setCliId&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;  rs.&lt;span style=&quot;color: #006600;&quot;&gt;getLong&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;cliId&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;      &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		client.&lt;span style=&quot;color: #006600;&quot;&gt;setNom&lt;/span&gt;   &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;  rs.&lt;span style=&quot;color: #006600;&quot;&gt;getString&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;cliNom&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;   &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		client.&lt;span style=&quot;color: #006600;&quot;&gt;setPrenom&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt; rs.&lt;span style=&quot;color: #006600;&quot;&gt;getString&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;cliPrenom&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;return&lt;/span&gt; client&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
	&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/* (non-Javadoc)
	 * @see com.netapsys.springmvc.metier.IDao#createClient(long, java.lang.String, java.lang.String)
	 */&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; Client createClient&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; nom, &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; prenom&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		Client client=&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; Client&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		client.&lt;span style=&quot;color: #006600;&quot;&gt;setNom&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;nom&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		client.&lt;span style=&quot;color: #006600;&quot;&gt;setPrenom&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;prenom&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;try&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;			
			jt.&lt;span style=&quot;color: #006600;&quot;&gt;update&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt; Constants.&lt;span style=&quot;color: #006600;&quot;&gt;SQL_REQUETE_INSERT_CLIENT&lt;/span&gt;+ &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;'&amp;quot;&lt;/span&gt;+nom+ &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;' , '&amp;quot;&lt;/span&gt;+prenom+&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;'&amp;quot;&lt;/span&gt; +&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;)&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
			&lt;span style=&quot;color: #993333;&quot;&gt;long&lt;/span&gt; id=jt.&lt;span style=&quot;color: #006600;&quot;&gt;queryForLong&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;select LAST_INSERT_ID()&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt; 			&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//Mysql retrieve the last id inserted&lt;/span&gt;
			client.&lt;span style=&quot;color: #006600;&quot;&gt;setCliId&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;id&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
			&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;return&lt;/span&gt; client&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;catch&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;DataAccessException e&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
			logger.&lt;span style=&quot;color: #006600;&quot;&gt;error&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt; e.&lt;span style=&quot;color: #006600;&quot;&gt;getMessage&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
			&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;null&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
	&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/* 
	 * @see com.netapsys.springmvc.metier.IService#exist(java.lang.String)
	 */&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;boolean&lt;/span&gt; isExistId&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; id&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;final&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; sql = Constants.&lt;span style=&quot;color: #006600;&quot;&gt;SQL_REQUETE_COUNT_CLIENT&lt;/span&gt;+&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot; WHERE cliId='&amp;quot;&lt;/span&gt; +id + &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;'&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		&lt;span style=&quot;color: #993333;&quot;&gt;int&lt;/span&gt; count = jt.&lt;span style=&quot;color: #006600;&quot;&gt;queryForInt&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;sql&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;return&lt;/span&gt; count &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;?&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;true&lt;/span&gt; : &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;boolean&lt;/span&gt; findByName&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; nom&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;		
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;return&lt;/span&gt; findByName&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;nom,&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;null&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;boolean&lt;/span&gt; findByName&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;final&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; nom,&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;final&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; prenom&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;		
&amp;nbsp;
		&lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; sql = Constants.&lt;span style=&quot;color: #006600;&quot;&gt;SQL_REQUETE_COUNT_CLIENT&lt;/span&gt;+
				&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot; WHERE UPPER(cliNom)='&amp;quot;&lt;/span&gt; +nom.&lt;span style=&quot;color: #006600;&quot;&gt;toUpperCase&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; + &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;'&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		&lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;prenom&lt;span style=&quot;color: #66cc66;&quot;&gt;!&lt;/span&gt;=&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;null&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;!&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;equals&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;prenom&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
			sql+=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot; AND UPPER(CLIPRENOM)='&amp;quot;&lt;/span&gt;+prenom.&lt;span style=&quot;color: #006600;&quot;&gt;toUpperCase&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; + &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;'&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		&lt;span style=&quot;color: #993333;&quot;&gt;int&lt;/span&gt; count = jt.&lt;span style=&quot;color: #006600;&quot;&gt;queryForInt&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;sql&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;return&lt;/span&gt; count &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;?&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;true&lt;/span&gt; : &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;void&lt;/span&gt; deleteClient&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #993333;&quot;&gt;long&lt;/span&gt; id&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;final&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; sql=Constants.&lt;span style=&quot;color: #006600;&quot;&gt;SQL_DELETE_ALL_CLIENT&lt;/span&gt;+&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot; WHERE cliId='&amp;quot;&lt;/span&gt;+ id + &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;'&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;		
		jt.&lt;span style=&quot;color: #006600;&quot;&gt;update&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;sql&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; Client updateClient&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #993333;&quot;&gt;long&lt;/span&gt; id, &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; nom, &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; prenom&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		Client client=&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; Client&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		client.&lt;span style=&quot;color: #006600;&quot;&gt;setCliId&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;id&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		client.&lt;span style=&quot;color: #006600;&quot;&gt;setCliNom&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;nom&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		client.&lt;span style=&quot;color: #006600;&quot;&gt;setCliPrenom&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;prenom&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;final&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; sql=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;update Client set clinom='&amp;quot;&lt;/span&gt;+
				nom+&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;', cliprenom='&amp;quot;&lt;/span&gt;+prenom+&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;' WHERE cliId='&amp;quot;&lt;/span&gt;+id+&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;'&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		logger.&lt;span style=&quot;color: #006600;&quot;&gt;info&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;nb rows updated=&amp;quot;&lt;/span&gt;+jt.&lt;span style=&quot;color: #006600;&quot;&gt;update&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;sql&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;return&lt;/span&gt; client&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
&lt;br /&gt;
- Couche service&amp;nbsp;:
&lt;br /&gt;
&lt;br /&gt;
Enfin, la couche service contient, en dehors de son interface identique à celle de IDao, la classe d'implémentation nommée &lt;em&gt;MyService.java&lt;/em&gt; dont voici son code:
&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;java&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;package&lt;/span&gt; com.&lt;span style=&quot;color: #006600;&quot;&gt;netapsys&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;fr&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;springmvc&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;service&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import org.springframework.beans.factory.annotation.Autowired;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import org.springframework.stereotype.Service;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import com.netapsys.fr.springmcv.entites.Client;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import com.netapsys.fr.springmvc.dao.DaoImpl;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import com.netapsys.fr.springmvc.exceptions.MyException;&lt;/span&gt;
@Service&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt; MyService &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;implements&lt;/span&gt; IService&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;final&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;long&lt;/span&gt; serialVersionUID = 1L&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/**	 * @see com.netapsys.fr.springmvc.dao.DaoImpl	 */&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;private&lt;/span&gt; DaoImpl daoImpl&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	@Autowired
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;void&lt;/span&gt; setDaoImpl&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;DaoImpl daoImpl&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;daoImpl&lt;/span&gt; = daoImpl&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; Client getClient&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; nom, &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; prenom&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;return&lt;/span&gt; daoImpl.&lt;span style=&quot;color: #006600;&quot;&gt;getClient&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;nom, prenom&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;boolean&lt;/span&gt; isExistId&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; id&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;	
		&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// Valider les regles de gestion .....if id is not int/long...&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;return&lt;/span&gt; daoImpl.&lt;span style=&quot;color: #006600;&quot;&gt;isExistId&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;id&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;boolean&lt;/span&gt; findByName&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; nom&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;return&lt;/span&gt; daoImpl.&lt;span style=&quot;color: #006600;&quot;&gt;findByName&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;nom&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; Client getClient&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; nom&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;return&lt;/span&gt; daoImpl.&lt;span style=&quot;color: #006600;&quot;&gt;getClient&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;nom&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; Client createClient&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; nom, &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; prenom&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;throws&lt;/span&gt; MyException &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;return&lt;/span&gt; daoImpl.&lt;span style=&quot;color: #006600;&quot;&gt;createClient&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt; nom, prenom&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;void&lt;/span&gt; deleteClient&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #993333;&quot;&gt;long&lt;/span&gt; id&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;		
		 daoImpl.&lt;span style=&quot;color: #006600;&quot;&gt;deleteClient&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;id&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; Client getClient&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #993333;&quot;&gt;long&lt;/span&gt; id&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;return&lt;/span&gt; daoImpl.&lt;span style=&quot;color: #006600;&quot;&gt;getClient&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;id&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; Client updateClient&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #993333;&quot;&gt;long&lt;/span&gt; id, &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; nom, &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; prenom&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;return&lt;/span&gt; daoImpl.&lt;span style=&quot;color: #006600;&quot;&gt;updateClient&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;id, nom, prenom&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
&lt;br /&gt;
La couche service est là pour appeler les méthodes de la couche DAO. Et c'est dans la couche service que l'on gère l'aspect transactionnel mais également les règles métier spécifiques. On peut faire de même pour tous les apsects transverses tels que les logs et les mesures de temps d'exécution.
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;ETAPE 5. Fichiers jsp &lt;/strong&gt;
&lt;br /&gt;&lt;/p&gt;


&lt;p&gt;Le fichier index.jsp ne fait que rediriger la requête vers l'url  /createClient.html.&lt;/p&gt;


&lt;p&gt;&lt;br /&gt;
La requête /createClient.html est interceptée par la servlet frontale de SpringMVC, qui à son tour décide de l'action (méthode) à appeler dans le &quot;controller&quot; nommé &quot;ClientControllerSpringMVC&quot; et qui décide ensuite de la vue à rendre en réponse à cette requête. Dans notre cas, c'est la méthode &quot;public String createClient&quot; de la classe &quot;ClientControllerSpringMVC.java&quot; qui sera appelée. Celle-ci, en cas de succès renvoie la chaîne &quot;success&quot; stockée dans Constants.SUCCESS de la classe utilitaire Constants. C'est cette chaîne qui permet de traduire la vue gérant la présentation de la réponse, dans notre cas &quot;success.jsp&quot;.
&lt;br /&gt;
&lt;br /&gt;
Voici donc les quelques lignes de index.jsp:
&lt;br /&gt;&lt;/p&gt;
&lt;pre&gt;[jsp]
&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
&amp;lt;title&amp;gt;Spring mvc sample&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
&amp;lt;%
    final String urlAction=&amp;quot;/createClient.html?&amp;quot;;
	final String nom = request.getParameter(&amp;quot;name&amp;quot;);
	final String prenom = request.getParameter(&amp;quot;lastName&amp;quot;);
	if (nom != null &amp;amp;&amp;amp; !&amp;quot;&amp;quot;.equals(nom))
		response.sendRedirect(request.getContextPath()
				+ urlAction+&amp;quot;name=&amp;quot; + nom + &amp;quot;&amp;amp;lastName&amp;quot;
				+ prenom);
	else
		response
				.sendRedirect(request.getContextPath()
						+ urlAction+&amp;quot;name=nom007&amp;amp;lastName=prenom007&amp;quot;);
%&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
Le fichier success.jsp:
&lt;br /&gt;&lt;/p&gt;
&lt;pre&gt;[jsp]
&amp;lt;body&amp;gt;
&amp;lt;h2&amp;gt;Edition de la fiche client créé   &amp;lt;/h2&amp;gt;&amp;lt;br /&amp;gt;
&amp;lt;% final String url=request.getContextPath()+&amp;quot;/updateClient.html&amp;quot;;%&amp;gt;
&amp;lt;form:form commandName=&amp;quot;client&amp;quot; action=&amp;quot;&amp;lt;%=url %&amp;gt;&amp;quot; method=&amp;quot;post&amp;quot;&amp;gt;
&amp;lt;table&amp;gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;&amp;lt;form:hidden  path=&amp;quot;cliId&amp;quot; /&amp;gt;&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Nom:&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;&amp;lt;form:input tabindex=&amp;quot;1&amp;quot; autocomplete=&amp;quot;true&amp;quot;  path=&amp;quot;cliNom&amp;quot; /&amp;gt;&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Prénom:&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;&amp;lt;form:input tabindex=&amp;quot;2&amp;quot; autocomplete=&amp;quot;true&amp;quot;  path=&amp;quot;cliPrenom&amp;quot; /&amp;gt;&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;tr&amp;lt;td colspan=&amp;quot;2&amp;quot;&amp;gt;
&amp;lt;input type=&amp;quot;submit&amp;quot; value=&amp;quot;Valider&amp;quot; /&amp;gt;
&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;/table&amp;gt;
&amp;lt;/form:form&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;


&lt;p&gt;Enfin, la source du fichier error.jsp:
&lt;br /&gt;&lt;/p&gt;

&lt;pre&gt;[jsp]
&amp;lt;body&amp;gt;
&amp;lt;%  String msgError=(String)request.getAttribute(&amp;quot;errorMsg&amp;quot;); %&amp;gt;
&amp;lt;br /&amp;gt;&amp;lt;h2&amp;gt; &amp;lt;/h2&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;b&amp;gt;&amp;lt;%=msgError%&amp;gt;&amp;lt;/b&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
&lt;br /&gt;
Dans success.jsp, l'action du tag &quot;&amp;lt;form:from&quot; pointe sur /updateClient.html avec la méthode http &quot;POST&quot;. La méthode &quot;public String updateClient&quot; du &quot;controller&quot; renvoie constamment &quot;null&quot;. Ainsi, la vue utilisée dans ce cas est /WEB-INF/jsp/updateClient.jsp conformément aux déclarations du fichier spring-mvc-webapp-servlet.xml.
&lt;br /&gt;
Le fichier updateClient.jsp  contient ces lignes:
&lt;br /&gt;&lt;/p&gt;
&lt;pre&gt;[jsp]
&amp;lt;body&amp;gt;
&amp;lt;h2&amp;gt;Page Modification client&amp;lt;/h2&amp;gt;&amp;lt;br/&amp;gt;
&amp;lt;% 
    final String path=request.getContextPath();
    final String urlAction=path+&amp;quot;/updateClient.html&amp;quot;;
%&amp;gt;
&amp;lt;form:form commandName=&amp;quot;client&amp;quot; action=&amp;quot;&amp;lt;%=urlAction %&amp;gt;&amp;quot; method=&amp;quot;post&amp;quot;&amp;gt;
&amp;lt;table border=0&amp;gt;
&amp;lt;tr&amp;gt;
&amp;lt;td colspan=&amp;quot;2&amp;quot;&amp;gt;&amp;lt;form:hidden  path=&amp;quot;cliId&amp;quot; id=&amp;quot;id&amp;quot;/&amp;gt;&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;tr&amp;gt;
&amp;lt;td&amp;gt;Nom:&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;&amp;lt;form:input  autocomplete=&amp;quot;true&amp;quot;  path=&amp;quot;cliNom&amp;quot; /&amp;gt;&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;tr&amp;gt;
&amp;lt;td&amp;gt;Prénom:&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;&amp;lt;form:input  autocomplete=&amp;quot;true&amp;quot;  path=&amp;quot;cliPrenom&amp;quot; /&amp;gt;&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;tr&amp;gt;
&amp;lt;td colspan=&amp;quot;2&amp;quot;&amp;gt;
&amp;lt;input type=&amp;quot;submit&amp;quot; value=&amp;quot;Valider&amp;quot; /&amp;gt;
&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;/table&amp;gt;
&amp;lt;/form:form&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;ETAPE 6. Tests de l'application web &lt;/strong&gt;
&lt;br /&gt;
Pour tester l'application web ainsi complétée, nous allons lancer une console dos, puis se positionner dans le répertoire du projet et lancer la commande&amp;nbsp;:
&lt;br /&gt;&lt;/p&gt;
&lt;pre&gt;[sh]
mvn jetty:run
&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
S'assurer que la base Mysql nommée test (contenant une table client avec trois champs cliId, cliNom et cliPrenom) est en service.
&lt;br /&gt;Puis lancer le navigateur web avec l'url &quot;http://localhost:8080/spring-mvc-webapp/index.jsp&quot;.
&lt;br /&gt;
Vous devez obtenir la figure ci-contre &lt;img src=&quot;http://blog.netapsys.fr/public/code/JUnit4EtSpringMVC/resultat-index.PNG&quot; alt=&quot;capture-indexjsp&quot; /&gt; .
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;ETAPE 7. Classe de test du controlleur SpringMVC &lt;/strong&gt;
&lt;br /&gt;
&lt;br /&gt;
La classe JUnit4, nommée &quot;ClientControllerSpringMVCTest.java&quot;, permet de tester le &quot;controller&quot; de SpringMVC. Elle est constituée des lignes suivantes&amp;nbsp;:
&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;java&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/*-- Attention, les puristes de Junit ne verront pas les assert ici!!!!!! */&lt;/span&gt; 
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;package&lt;/span&gt; com.&lt;span style=&quot;color: #006600;&quot;&gt;netapsys&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;tests&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;springmvc&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;web&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;tests&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import org.apache.log4j.Logger;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import org.junit.After;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import org.junit.AfterClass;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import org.junit.Before;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import org.junit.BeforeClass;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import org.junit.Test;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import org.junit.runner.RunWith;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import org.springframework.beans.factory.annotation.Autowired;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import org.springframework.test.context.ContextConfiguration;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import org.springframework.ui.ModelMap;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import com.netapsys.fr.springmvc.tb.constants.Constants;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import com.netapsys.fr.springmvc.web.ClientControllerSpringMVC;&lt;/span&gt;
@ContextConfiguration&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;locations=&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;classpath:/config/spring-mvc-webapp-tests.xml&amp;quot;&lt;/span&gt;,&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;classpath:/config/spring-test.xml&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
@RunWith&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt; SpringJUnit4ClassRunner.&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//to activate autowiring injection dependence&lt;/span&gt;
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt; ClientControllerSpringMVCTest  &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;final&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;static&lt;/span&gt; Logger logger =Logger.&lt;span style=&quot;color: #006600;&quot;&gt;getLogger&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;ClientControllerSpringMVCTest.&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;getClass&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;getName&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/**
	 * Attribute in url, ex. &amp;quot;/getClient.html?name=Agent007
	 */&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;final&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; NAME2TEST=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Agent007&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;final&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; LASTNAME2TEST=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;007&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;static&lt;/span&gt; ModelMap model&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;protected&lt;/span&gt;  ClientControllerSpringMVC clientControllerSpring&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/**
	 * auto dependency injection par spring du controller dans les tests
	 */&lt;/span&gt;
	@Autowired
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;void&lt;/span&gt; setClientControllerSpring&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;ClientControllerSpringMVC clientControllerSpring&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;clientControllerSpring&lt;/span&gt; = clientControllerSpring&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
	@BeforeClass&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; 	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;void&lt;/span&gt; testAvantTout&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;	model = &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; ModelMap&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
	@AfterClass&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;void&lt;/span&gt; apresTousLesTests&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;	model.&lt;span style=&quot;color: #006600;&quot;&gt;clear&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
	@Before &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;void&lt;/span&gt; initAvant&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		&lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;clientControllerSpring&lt;span style=&quot;color: #66cc66;&quot;&gt;!&lt;/span&gt;=&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;null&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;	&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/** testons que spring injection est ok*/&lt;/span&gt;
		logger.&lt;span style=&quot;color: #006600;&quot;&gt;info&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\t&lt;/span&gt;clientControllerSpring is correctly initialized!&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
	@After &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt;  &lt;span style=&quot;color: #993333;&quot;&gt;void&lt;/span&gt; testApres&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
	@Test
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;void&lt;/span&gt; testGetClient&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;	
		&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//create or get client with given nom. if not exist create it with nom &amp;amp; prenom &lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;final&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; str=clientControllerSpring.&lt;span style=&quot;color: #006600;&quot;&gt;getClient&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;NAME2TEST, LASTNAME2TEST, model&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		&lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;Constants.&lt;span style=&quot;color: #006600;&quot;&gt;SUCCESS&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;equals&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;str&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;	logger.&lt;span style=&quot;color: #006600;&quot;&gt;info&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt; model.&lt;span style=&quot;color: #006600;&quot;&gt;get&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;client&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;		
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
Les parties importantes pour la compréhension des lanceurs de spring (annotés par @RunWith) sont bien documentées dans le code.
&lt;br /&gt;L'annotation @RunWith définit le lanceur spring qui enrichit considérablement les tests JUnit4 avec les fonctionnalités supplémentaires ( ex. l'auto-injection) offertes par Spring.
&lt;br /&gt;
Spring offre aussi des annotations inexistantes dans JUnit4 utiles à l'exécution de ces tests.
&lt;br /&gt;
Signalons que la ligne:&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;java&quot;&gt;@ContextConfiguration&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;locations=&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;classpath:/config/spring-mvc-webapp-tests.xml&amp;quot;&lt;/span&gt;,&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;classpath:/config/spring-test.xml&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
renvoie à deux fichiers de configuration de springMVC et de spring qui sont donnés en annexe. Ces deux fichiers sont identiques, à une déclaration près, aux fichiers spring-mvc-webapp-servlet.xml et spring.xml explicités auparavant.
La &lt;del&gt;seule différence &lt;/del&gt; est l'ajout de la déclaration de la transaction dans spring-test.xml:&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;xml&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!-- transaction --&amp;gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;bean&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;transactionManager&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;class&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;org.springframework.jdbc.datasource.DataSourceTransactionManager&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
	 &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;property&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;name&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;dataSource&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;ref&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;dataSource&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/bean&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
Ainsi, avec le bean &quot;transactionManager&quot; les tests en mode transactionnel ci-après deviennent possibles comme illustré à l'étape suivante.
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;ETAPE 8.Classe de test en mode transactionnel &lt;/strong&gt;
&lt;br /&gt;
&lt;br /&gt;
Les deux figures suivantes donnent le code de la classe MyServiceTest.java. Cette classe comporte toutes les indications pour excéuter les méthodes en mode transactionnel&amp;nbsp;:
&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;java&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;package&lt;/span&gt; com.&lt;span style=&quot;color: #006600;&quot;&gt;netapsys&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;tests&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;springmvc&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;web&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;tests&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import java.util.Random;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import org.apache.log4j.Logger;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import org.junit.*;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import org.junit.runner.RunWith;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import org.springframework.beans.factory.annotation.Autowired;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import org.springframework.test.context.ContextConfiguration;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import org.springframework.test.context.transaction.AfterTransaction;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import org.springframework.test.context.transaction.BeforeTransaction;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import org.springframework.test.context.transaction.TransactionConfiguration;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import org.springframework.transaction.annotation.Propagation;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import org.springframework.transaction.annotation.Transactional;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import com.netapsys.fr.springmcv.entites.Client;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import com.netapsys.fr.springmcv.entites.Personne;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import com.netapsys.fr.springmvc.exceptions.MyException;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import com.netapsys.fr.springmvc.service.MyService;&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/** * *******************************************************************
 * NOTE IMPORTANTE: defaultRollback à true ANNULE TOUTES LES ACTIONS DANS LA BASE!
 * ******************************************************************** */&lt;/span&gt;
@ContextConfiguration&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;locations=&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;classpath:/config/spring-mvc-webapp-tests.xml&amp;quot;&lt;/span&gt;,&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;classpath:/config/spring-test.xml&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
@RunWith&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt; value=SpringJUnit4ClassRunner.&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//indispensable&lt;/span&gt;
@TransactionConfiguration&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;transactionManager=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;transactionManager&amp;quot;&lt;/span&gt;,defaultRollback=&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt; MyServiceTest  &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;final&lt;/span&gt; Logger logger = Logger.&lt;span style=&quot;color: #006600;&quot;&gt;getLogger&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;getClass&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;getName&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/**	 * AUTO INJECTION PAR SPRING    */&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;private&lt;/span&gt;  MyService myService&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	@Autowired 	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;void&lt;/span&gt; setMyService&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;MyService myService&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;myService&lt;/span&gt; = myService&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
	@BeforeClass	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;void&lt;/span&gt; beforeClasse&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
	@Before&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;void&lt;/span&gt; avantChaqueTest&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		&lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;myService==&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;null&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; logger.&lt;span style=&quot;color: #006600;&quot;&gt;error&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Y a vraiment un probleme avec spring&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//verifie que l'auto injection de spring est ok&lt;/span&gt;
		logger.&lt;span style=&quot;color: #006600;&quot;&gt;info&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&amp;gt;&amp;gt;&amp;gt;Before test...(this is in transaction scope)&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;	
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
	@After&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;void&lt;/span&gt; apresChaqueTest&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;	logger.&lt;span style=&quot;color: #006600;&quot;&gt;info&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&amp;gt;&amp;gt;&amp;gt;After test...(this is in transaction scope)&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
	@BeforeTransaction&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; 
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;void&lt;/span&gt; avantTransaction&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;	logger.&lt;span style=&quot;color: #006600;&quot;&gt;info&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&amp;gt;&amp;gt;&amp;gt;Avant chaque transaction&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
	@AfterTransaction &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;void&lt;/span&gt; apresTransac&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt; logger.&lt;span style=&quot;color: #006600;&quot;&gt;info&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&amp;gt;&amp;gt;&amp;gt;Apres chaque transaction&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
	&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/** *  PREMIER TEST  ****/&lt;/span&gt;
	@Test @Transactional &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;propagation=Propagation.&lt;span style=&quot;color: #006600;&quot;&gt;REQUIRED&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;void&lt;/span&gt; testCreateClient&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;final&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; nom =giveRandomName&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Agent007test&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;final&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; prenom=giveRandomName&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;007test&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		Client client=&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;null&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;try&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
			client=myService.&lt;span style=&quot;color: #006600;&quot;&gt;getClient&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;nom,prenom&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
			&lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;client&lt;span style=&quot;color: #66cc66;&quot;&gt;!&lt;/span&gt;=&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;null&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
				logger.&lt;span style=&quot;color: #006600;&quot;&gt;warn&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;client &amp;quot;&lt;/span&gt;+client +&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot; existe donc ne sera pas créé&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
				&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; MyException&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Client existe!&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
			&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
			client=myService.&lt;span style=&quot;color: #006600;&quot;&gt;createClient&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt; nom, prenom&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
			&lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;client&lt;span style=&quot;color: #66cc66;&quot;&gt;!&lt;/span&gt;=&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;null&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;logger.&lt;span style=&quot;color: #006600;&quot;&gt;info&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\n&lt;/span&gt;&amp;gt;&amp;gt;&amp;gt;Client :'&amp;quot;&lt;/span&gt;+client.&lt;span style=&quot;color: #006600;&quot;&gt;toString&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;+&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;' is created!&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;catch&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;MyException se&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
			logger.&lt;span style=&quot;color: #006600;&quot;&gt;error&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&amp;gt;&amp;gt;&amp;gt;Client exist!&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\t&lt;/span&gt;&amp;quot;&lt;/span&gt;+se.&lt;span style=&quot;color: #006600;&quot;&gt;getMessage&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
	&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/**	 *  2eme test : 	 */&lt;/span&gt;
	@Ignore @Transactional&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;readOnly=&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; 
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;void&lt;/span&gt; testGetClient&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		logger.&lt;span style=&quot;color: #006600;&quot;&gt;info&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\n&lt;/span&gt;&amp;gt;&amp;gt;&amp;gt;3eme test getClient.&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;final&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; NAME=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;nom007nnn&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;final&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; LASTNAME=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;prenom007nnn&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		Personne client=myService.&lt;span style=&quot;color: #006600;&quot;&gt;getClient&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;NAME,LASTNAME&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		&lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;client&lt;span style=&quot;color: #66cc66;&quot;&gt;!&lt;/span&gt;=&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;null&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
			logger.&lt;span style=&quot;color: #006600;&quot;&gt;info&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;quot;&lt;/span&gt;+client.&lt;span style=&quot;color: #006600;&quot;&gt;toString&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		&lt;span style=&quot;color: #b1b100;&quot;&gt;else&lt;/span&gt; 
			logger.&lt;span style=&quot;color: #006600;&quot;&gt;info&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Client '&amp;quot;&lt;/span&gt;+NAME+&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;' not exist!&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; giveRandomName&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;final&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; prefix&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;final&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;Random&lt;/span&gt; random=&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;Random&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;		
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;return&lt;/span&gt; prefix+random.&lt;span style=&quot;color: #006600;&quot;&gt;nextInt&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
Pour tester ces différentes classes, lancer la commande &quot;mvn test&quot;. &lt;br /&gt;
Les commentaires du code et les traces de log4j à  retrouver après l'exécution sont très explicites.
Ils permettent de voir qu'en positionnant le &quot;defaultRollback&quot; de l'annotation spring &quot;@TransactionConfiguration&quot; à true, ces tests simulent la création d'un client dans la base.
&lt;br /&gt;
C'est à dire, qu'un rollback est fait à chaque test. On peut modifier le paramètre &quot;defaultRollback=false&quot;, et les transactions insèrent bien des clients dans la base.
&lt;br /&gt;
Mais généralement, en mode test, le defaultRollback est positionné à true.
&lt;br /&gt;
L'annotation de Spring @Autowired gère fort bien l'auto-injection si on observe la règle suivante&amp;nbsp;: Annoter, avec les @Autowired, toujours les méthodes setters/getters et positionner dans les fichiers de configuration de spring le defaut-autowired à byName afin d'anticiper sur des exceptions indéchiffrables.
&lt;br /&gt;
C'est là que l'on prend conscience de l'apport de Spring au framework de test JUnit. Juste  quelques annotations en plus et les tests deviennent transactionnels.
&lt;br /&gt;
Les retours bénéfiques de ces tests sont considérables.
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;ETAPE 9. Conclusion &lt;/strong&gt;
&lt;br /&gt;
&lt;br /&gt;
Combiner Spring 2.5+ et JUnit4 permet d'avoir sous la main un framework de test puissant facilitant la mise en place des tests unitaires et d'intégration. Bien que l'apprentissage exige un léger effort, une fois ces deux frameworks maîtrisés, l'efficacité et le gain économique sont énormes.&lt;br /&gt;
Enfin, la qualité du livrable au client ne sera que meilleure.
&lt;br /&gt;
Observons, en particulier, dans les classes de tests en mode transactionnel, le confort qu'apporte Spring à JUnit4.&lt;br /&gt;
Les annotations Spring @TransactionConfiguration et @Transactional rendent les transactions à la portée de tout le monde.
&lt;br /&gt;
Dans un prochain billet, je reviendrai sur les tests paramétrés dans Spring.
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;ETAPE 10. Annexes (pom et codes sources) &lt;/strong&gt;
&lt;br /&gt;&lt;br /&gt;
La figure ci-après illustre l'arborescence du projet&lt;br /&gt; &lt;img src=&quot;http://blog.netapsys.fr/public/code/JUnit4EtSpringMVC/Arborescence_projet.PNG&quot; alt=&quot;arbo_projetJunit4SpringMVC&quot; /&gt;.
&lt;br /&gt;
&lt;br /&gt;
Le fichier zip contenant le projet ainsi que les détails du pom.xml sont joints à ce billet.
&lt;br /&gt;&lt;/p&gt;</description>
    
          <enclosure url="http://blog.netapsys.fr/public/code/JUnit4EtSpringMVC/spring-mvc-webapp_blog220309.zip"
      length="117475" type="application/zip" />
    
    
          <comments>http://blog.netapsys.fr/index.php/post/2009/01/08/Tests-Unitaires-et-dintegration-avec-Junit4-et-Spring-MVC-en-mode-transactionnel#comment-form</comments>
      <wfw:comment>http://blog.netapsys.fr/index.php/post/2009/01/08/Tests-Unitaires-et-dintegration-avec-Junit4-et-Spring-MVC-en-mode-transactionnel#comment-form</wfw:comment>
      <wfw:commentRss>http://blog.netapsys.fr/index.php/feed/rss2/comments/58</wfw:commentRss>
      </item>
    
</channel>
</rss>