r259 - in trunk: . jredmine-domain jredmine-domain/src jredmine-domain/src/main jredmine-domain/src/main/java jredmine-domain/src/main/java/org jredmine-domain/src/main/java/org/nuiton jredmine-domain/src/main/java/org/nuiton/jredmine jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3 jredmine-domain/src/main/resources jredmine-domain/src/main/resources/META-INF jredmine-domain/src/main/resources/META-INF/services jredmine-domain/src/site jredmine-domain/src/site/apt jredmine
Author: tchemit Date: 2012-07-12 12:14:14 +0200 (Thu, 12 Jul 2012) New Revision: 259 Url: http://nuiton.org/repositories/revision/jredmine/259 Log: add a domain module (will contains only model) Added: trunk/jredmine-domain/ trunk/jredmine-domain/LICENSE.txt trunk/jredmine-domain/README.txt trunk/jredmine-domain/changelog.txt trunk/jredmine-domain/pom.xml trunk/jredmine-domain/src/ trunk/jredmine-domain/src/license/ trunk/jredmine-domain/src/main/ trunk/jredmine-domain/src/main/java/ trunk/jredmine-domain/src/main/java/org/ trunk/jredmine-domain/src/main/java/org/nuiton/ trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/ trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/ trunk/jredmine-domain/src/main/resources/ trunk/jredmine-domain/src/main/resources/META-INF/ trunk/jredmine-domain/src/main/resources/META-INF/services/ trunk/jredmine-domain/src/main/resources/META-INF/services/org.nuiton.io.xpp3.Xpp3Reader trunk/jredmine-domain/src/site/ trunk/jredmine-domain/src/site/apt/ trunk/jredmine-domain/src/site/apt/index.apt trunk/jredmine-domain/src/site/site_fr.xml trunk/jredmine-domain/src/test/ trunk/jredmine-domain/src/test/java/ trunk/jredmine-domain/src/test/java/org/ trunk/jredmine-domain/src/test/java/org/nuiton/ trunk/jredmine-domain/src/test/java/org/nuiton/jredmine/ trunk/jredmine-domain/src/test/java/org/nuiton/jredmine/RedmineFixtures.java trunk/jredmine-domain/src/test/java/org/nuiton/jredmine/model/ trunk/jredmine-domain/src/test/java/org/nuiton/jredmine/model/io/ trunk/jredmine-domain/src/test/java/org/nuiton/jredmine/model/io/xpp3/ trunk/jredmine-domain/src/test/java/org/nuiton/jredmine/model/io/xpp3/RedmineXpp3HelperTest.java trunk/jredmine-domain/src/test/resources/ trunk/jredmine-domain/src/test/resources/log4j.properties trunk/jredmine-domain/src/test/resources/org/ trunk/jredmine-domain/src/test/resources/org/nuiton/ trunk/jredmine-domain/src/test/resources/org/nuiton/jredmine/ trunk/jredmine-domain/src/test/resources/org/nuiton/jredmine/model/ trunk/jredmine-domain/src/test/resources/org/nuiton/jredmine/model/io/ trunk/jredmine-domain/src/test/resources/org/nuiton/jredmine/model/io/xpp3/ Removed: trunk/jredmine-domain/src/test/java/org/nuiton/jredmine/model/io/RedmineXpp3HelperTest.java Modified: trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3/RedmineXpp3Helper.java Property changes on: trunk/jredmine-domain ___________________________________________________________________ Added: svn:ignore + target *.ipr *.iws *.iml .idea .project .classpath .settings Added: trunk/jredmine-domain/LICENSE.txt =================================================================== --- trunk/jredmine-domain/LICENSE.txt (rev 0) +++ trunk/jredmine-domain/LICENSE.txt 2012-07-12 10:14:14 UTC (rev 259) @@ -0,0 +1,166 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. + Property changes on: trunk/jredmine-domain/LICENSE.txt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/jredmine-domain/README.txt =================================================================== --- trunk/jredmine-domain/README.txt (rev 0) +++ trunk/jredmine-domain/README.txt 2012-07-12 10:14:14 UTC (rev 259) @@ -0,0 +1,2 @@ +To deploy new version of pom: mvn deploy +To install localy: mvn install Property changes on: trunk/jredmine-domain/README.txt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/jredmine-domain/changelog.txt =================================================================== --- trunk/jredmine-domain/changelog.txt (rev 0) +++ trunk/jredmine-domain/changelog.txt 2012-07-12 10:14:14 UTC (rev 259) @@ -0,0 +1,5 @@ +maven-redmine-plugin (1.0.0-SNAPSHOT) stable; urgency=low + + * //TODO_FILL_ME + + -- author -- date -R Property changes on: trunk/jredmine-domain/changelog.txt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/jredmine-domain/pom.xml =================================================================== --- trunk/jredmine-domain/pom.xml (rev 0) +++ trunk/jredmine-domain/pom.xml 2012-07-12 10:14:14 UTC (rev 259) @@ -0,0 +1,224 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + #%L + JRedmine :: Client + + $HeadURL: http://svn.nuiton.org/svn/jredmine/trunk/jredmine-client/pom.xml $ + %% + Copyright (C) 2009 - 2010 Tony Chemit, CodeLutin + %% + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Lesser Public License for more details. + + You should have received a copy of the GNU General Lesser Public + License along with this program. If not, see + <http://www.gnu.org/licenses/lgpl-3.0.html>. + #L% + --> + +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + + <modelVersion>4.0.0</modelVersion> + + <!-- ************************************************************* --> + <!-- *** POM Relationships *************************************** --> + <!-- ************************************************************* --> + + <parent> + <groupId>org.nuiton</groupId> + <artifactId>jredmine</artifactId> + <version>1.4-SNAPSHOT</version> + </parent> + + <groupId>org.nuiton.jredmine</groupId> + <artifactId>jredmine-domain</artifactId> + + <dependencies> + + <dependency> + <groupId>com.sun.jersey</groupId> + <artifactId>jersey-client</artifactId> + </dependency> + + <dependency> + <groupId>com.sun.jersey.contribs</groupId> + <artifactId>jersey-apache-client4</artifactId> + </dependency> + + <dependency> + <groupId>com.sun.jersey.contribs</groupId> + <artifactId>jersey-multipart</artifactId> + </dependency> + + <dependency> + <groupId>org.nuiton</groupId> + <artifactId>helper-maven-plugin</artifactId> + <scope>compile</scope> + <exclusions> + <exclusion> + <groupId>velocity</groupId> + <artifactId>velocity</artifactId> + </exclusion> + </exclusions> + </dependency> + + <dependency> + <groupId>commons-codec</groupId> + <artifactId>commons-codec</artifactId> + <scope>runtime</scope> + </dependency> + + <dependency> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + </dependency> + + <dependency> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + </dependency> + + <dependency> + <groupId>commons-httpclient</groupId> + <artifactId>commons-httpclient</artifactId> + </dependency> + + <dependency> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpclient</artifactId> + </dependency> + + <dependency> + <groupId>org.codehaus.plexus</groupId> + <artifactId>plexus-utils</artifactId> + </dependency> + + <dependency> + <groupId>log4j</groupId> + <artifactId>log4j</artifactId> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + </dependency> + + </dependencies> + + <name>JRedmine :: Client</name> + <description>The JRedmine client</description> + + <properties> + <!-- extra files to include in release --> + <redmine.releaseFiles> + target/${project.artifactId}-${project.version}-jredmine_rails.zip, + ${redmine.libReleaseFiles} + </redmine.releaseFiles> + </properties> + + <build> + + <plugins> + <!-- expose new plexus components --> + <plugin> + <groupId>org.codehaus.plexus</groupId> + <artifactId>plexus-component-metadata</artifactId> + <executions> + <execution> + <goals> + <goal>generate-metadata</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + + </build> + + <reporting> + <excludeDefaults>true</excludeDefaults> + </reporting> + + <profiles> + + <profile> + <id>reporting</id> + <activation> + <property> + <name>performRelease</name> + <value>true</value> + </property> + </activation> + + <reporting> + <plugins> + <plugin> + <groupId>org.codehaus.plexus</groupId> + <artifactId>plexus-maven-plugin</artifactId> + <version>${plexusPluginVersion}</version> + </plugin> + + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>cobertura-maven-plugin</artifactId> + <version>${coberturaPluginVersion}</version> + </plugin> + + </plugins> + </reporting> + + </profile> + <profile> + <id>release-assembly-profile</id> + <activation> + <property> + <name>performRelease</name> + <value>true</value> + </property> + </activation> + <build> + <plugins> + + <!-- launch in a release the assembly, but not attach it to project --> + + <plugin> + <artifactId>maven-assembly-plugin</artifactId> + <executions> + <execution> + <id>create-assemblies</id> + <phase>verify</phase> + <goals> + <goal>single</goal> + </goals> + </execution> + </executions> + <configuration> + <attach>false</attach> + <descriptorRefs> + <descriptorRef>deps</descriptorRef> + <descriptorRef>full</descriptorRef> + </descriptorRefs> + <descriptors> + <descriptor>src/main/assembly/jredmine_rails.xml</descriptor> + </descriptors> + </configuration> + </plugin> + + </plugins> + + </build> + </profile> + + </profiles> + +</project> Property changes on: trunk/jredmine-domain/pom.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Modified: trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3/RedmineXpp3Helper.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/io/xpp3/RedmineXpp3Helper.java 2012-05-30 14:37:21 UTC (rev 258) +++ trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3/RedmineXpp3Helper.java 2012-07-12 10:14:14 UTC (rev 259) @@ -31,7 +31,6 @@ import org.codehaus.plexus.util.xml.pull.XmlPullParserException; import org.nuiton.io.xpp3.Xpp3Helper; import org.nuiton.io.xpp3.Xpp3Reader; -import org.nuiton.jredmine.model.RedmineModelEnum; import java.io.ByteArrayInputStream; import java.io.File; @@ -101,7 +100,7 @@ InputStream stream, boolean strict) throws IOException, XmlPullParserException { - RedmineModelEnum.safeValueOf(klass); +// RedmineModelEnum.safeValueOf(klass); O result = readObject(klass, ReaderFactory.newXmlReader(stream), @@ -115,7 +114,7 @@ InputStream stream, boolean strict) throws IOException, XmlPullParserException { - RedmineModelEnum.safeValueOf(klass); +// RedmineModelEnum.safeValueOf(klass); O[] results = readObjects(klass, ReaderFactory.newXmlReader(stream), Copied: trunk/jredmine-domain/src/main/resources/META-INF/services/org.nuiton.io.xpp3.Xpp3Reader (from rev 258, trunk/jredmine-client/src/main/resources/META-INF/services/org.nuiton.io.xpp3.Xpp3Reader) =================================================================== --- trunk/jredmine-domain/src/main/resources/META-INF/services/org.nuiton.io.xpp3.Xpp3Reader (rev 0) +++ trunk/jredmine-domain/src/main/resources/META-INF/services/org.nuiton.io.xpp3.Xpp3Reader 2012-07-12 10:14:14 UTC (rev 259) @@ -0,0 +1,12 @@ +org.nuiton.jredmine.model.io.xpp3.AttachmentXpp3Reader +org.nuiton.jredmine.model.io.xpp3.IssueXpp3Reader +org.nuiton.jredmine.model.io.xpp3.IssueCategoryXpp3Reader +org.nuiton.jredmine.model.io.xpp3.IssuePriorityXpp3Reader +org.nuiton.jredmine.model.io.xpp3.IssueStatusXpp3Reader +org.nuiton.jredmine.model.io.xpp3.NewsXpp3Reader +org.nuiton.jredmine.model.io.xpp3.ProjectXpp3Reader +org.nuiton.jredmine.model.io.xpp3.TrackerXpp3Reader +org.nuiton.jredmine.model.io.xpp3.UserXpp3Reader +org.nuiton.jredmine.model.io.xpp3.VersionXpp3Reader +org.nuiton.jredmine.model.io.xpp3.TimeEntryXpp3Reader +org.nuiton.jredmine.model.io.xpp3.CustomFieldXpp3Reader Property changes on: trunk/jredmine-domain/src/main/resources/META-INF/services/org.nuiton.io.xpp3.Xpp3Reader ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/jredmine-domain/src/site/apt/index.apt =================================================================== --- trunk/jredmine-domain/src/site/apt/index.apt (rev 0) +++ trunk/jredmine-domain/src/site/apt/index.apt 2012-07-12 10:14:14 UTC (rev 259) @@ -0,0 +1,122 @@ +~~~ +~~ #%L +~~ JRedmine :: Client +~~ +~~ $Id$ +~~ $HeadURL: http://svn.nuiton.org/svn/jredmine/trunk/jredmine-client/src/site/apt/index.... $ +~~ %% +~~ Copyright (C) 2009 - 2010 Tony Chemit, CodeLutin +~~ %% +~~ This program is free software: you can redistribute it and/or modify +~~ it under the terms of the GNU Lesser General Public License as +~~ published by the Free Software Foundation, either version 3 of the +~~ License, or (at your option) any later version. +~~ +~~ This program is distributed in the hope that it will be useful, +~~ but WITHOUT ANY WARRANTY; without even the implied warranty of +~~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +~~ GNU General Lesser Public License for more details. +~~ +~~ You should have received a copy of the GNU General Lesser Public +~~ License along with this program. If not, see +~~ <http://www.gnu.org/licenses/lgpl-3.0.html>. +~~ #L% +~~~ +---- +JRedmine-client +---- +---- +2009-09-15 +---- + + Ce module contient un plugin <rails> qui permet d'ouvrir l'api de redmine au + protocole <REST>, ainsi q'un client <Java> pour interroger les services <REST>. + + +Plugin <rails> JRedmine + + Le but de ce plugin est de pouvoir accéder aux données d'un serveur Redmine en + utilisant le protocole <REST>, mais aussi d'effectuer des tâches de + maintenance sur le serveur. + + La page {{{./rails_api.html}API}} détaille l'ensemble des services disponibles + depuis le serveur Redmine. + +* Source du plugin + + Les sources du plugin <rails> sont sont dans le répertoire <<src/main/redmine>> + +-------------------------------------------------------------------------------- + +src/main/redmine/ +`-- jredmine + |-- README.rdoc + |-- app + | |-- controllers + | | `-- jredmine_controller.rb + | |-- helpers + | |-- models + | `-- views + |-- assets + | |-- images + | |-- javascripts + | `-- stylesheets + |-- config + | `-- routes.rb + |-- db + | `-- migrate + |-- init.rb + |-- lang + | `-- en.yml + |-- lib + | `-- tasks + `-- test + `-- functional +-------------------------------------------------------------------------------- + +* Récupération d'une version packagée + + Il est possible de récupérer une version zippée du plugin (voir la section des + téléchargements). + +* Installation du plugin sur le serveur Redmine + + * récupération du zip du plugin + + * dézippage dans le répertoire vendor/plugins + + * relancer votre instance de redmine (ou apache). + +* Configuration des permissions du plugin dans le serveur Redmine + + Le plugin est activable par projet et par rôle. + + Pour rendre accessible le plugin pour un projet donné, il faut donc ajouter + le module JRedmine sur le projet dans l'onglet de configuration des modules + du projet. + + Pour rendre accessible le plugin pour un rôle, il faut lui ajouter la + permission <<allow_jredmine>> dans la page des permissions du rôle. + +* Tester le plugin + + Une fois la configuration des permissions réalisées, vous pouvez tester le + plugin dans un navigateur web. + + Pour cela, loggez-vous en web sur redmine, puis lancer (dans un autre onglet) + l'url suivante : (remplacer <XX> par le chemin d'accès à votre redmine + et <YY> par le nom d'un de vos projet). + +-------------------------------------------------------------------------------- +http://XX/jredmine/get_project/YY +-------------------------------------------------------------------------------- + + Vous devez obtenir en retour la description xml du projet demandé. + +Client java + + Le client java qui interroge le plugin rails se base sur l'api du plugin rails + et transforme les données retournées en xml en objets java. + + La {{{./redmine_service.html}page suivante}} détaille les services disponibles + en java. Property changes on: trunk/jredmine-domain/src/site/apt/index.apt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/jredmine-domain/src/site/site_fr.xml =================================================================== --- trunk/jredmine-domain/src/site/site_fr.xml (rev 0) +++ trunk/jredmine-domain/src/site/site_fr.xml 2012-07-12 10:14:14 UTC (rev 259) @@ -0,0 +1,117 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + #%L + JRedmine :: Client + + $Id$ + $HeadURL: http://svn.nuiton.org/svn/jredmine/trunk/jredmine-client/src/site/site_fr.xm... $ + %% + Copyright (C) 2009 - 2010 Tony Chemit, CodeLutin + %% + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Lesser Public License for more details. + + You should have received a copy of the GNU General Lesser Public + License along with this program. If not, see + <http://www.gnu.org/licenses/lgpl-3.0.html>. + #L% + --> + +<project name="${project.name}"> + + <bannerLeft> + <name>${project.name}</name> + <href>index.html</href> + </bannerLeft> + + <bannerRight> + <src>http://www.codelutin.com/images/lutinorange-codelutin.png</src> + <href>http://www.codelutin.com</href> + </bannerRight> + + <skin> + <groupId>org.apache.maven.skins</groupId> + <artifactId>maven-fluido-skin</artifactId> + <version>1.2.1</version> + </skin> + + <custom> + <fluidoSkin> + <topBarEnabled>true</topBarEnabled> + <googleSearch/> + <sideBarEnabled>false</sideBarEnabled> + <searchEnabled>true</searchEnabled> + <sourceLineNumbersEnabled>true</sourceLineNumbersEnabled> + </fluidoSkin> + </custom> + + <publishDate position="right" format="dd/MM/yyyy"/> + <version position="right"/> + + <body> + + <breadcrumbs> + <item name="${project.name}" href="index.html"/> + </breadcrumbs> + + <links> + <item name="nuiton.org" href="http://www.nuiton.org"/> + <item name="CodeLutin" href="http://codelutin.com"/> + <item name="Libre-Entreprise" href="http://www.libre-entreprise.org/"/> + </links> + + <menu ref="parent"/> + + <menu name="Utilisateur"> + <item name="Introduction" href="index.html"/> + <item name="JRedmine rails API" href="rails_api.html"/> + <item name="JRedmine java service" href="redmine_service.html"/> + </menu> + + <menu name="Téléchargement"> + <item href="http://nuiton.org/projects/list_files/jredmine" name="Sources bundles"/> + + <item href="${repository.home.url}/org/nuiton/jredmine/jredmine-client/${project.version}/${project.build.finalName}.jar" + name="Librairie (jar)"/> + <item href="${repository.home.url}/org/nuiton/jredmine/jredmine-client/${project.version}/${project.build.finalName}-javadoc.jar" + name="Javadoc (jar)"/> + <item href="${repository.home.url}/org/nuiton/jredmine/jredmine-client/${project.version}/${project.build.finalName}-sources.jar" + name="Sources (jar)"/> + <item href="${repository.home.url}/org/nuiton/jredmine/jredmine-client/${project.version}/${project.build.finalName}-tests.jar" + name="Test Librairie (jar)"/> + <item href="${repository.home.url}/org/nuiton/jredmine/jredmine-client/${project.version}/${project.build.finalName}-test-javadoc.jar" + name="Test Javadoc (jar)"/> + <item href="${repository.home.url}/org/nuiton/jredmine/jredmine-client/${project.version}/${project.build.finalName}-test-sources.jar" + name="Test Sources (jar)"/> + </menu> + + <menu ref="reports"/> + + <footer> + + <script type="text/javascript" + src="http://maven-site.nuiton.org/public/js/maven-site-nuiton.org.js"> + </script> + + <div id='projectMetas' + projectversion='${project.version}' + platform='${project.platform}' + projectid='${project.projectId}' + scm='${project.scm.connection}' + scmwebeditorenabled='${project.scmwebeditorEnabled}' + scmwebeditorurl='${project.scmwebeditorUrl}' + siteSourcesType='${project.siteSourcesType}' + piwikEnabled='${project.piwikEnabled}' + piwikId='${project.piwikId}'> + </div> + </footer> + + </body> +</project> Property changes on: trunk/jredmine-domain/src/site/site_fr.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/jredmine-domain/src/test/java/org/nuiton/jredmine/RedmineFixtures.java =================================================================== --- trunk/jredmine-domain/src/test/java/org/nuiton/jredmine/RedmineFixtures.java (rev 0) +++ trunk/jredmine-domain/src/test/java/org/nuiton/jredmine/RedmineFixtures.java 2012-07-12 10:14:14 UTC (rev 259) @@ -0,0 +1,551 @@ +package org.nuiton.jredmine; + +import com.google.common.collect.ArrayListMultimap; +import org.apache.commons.io.FileUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.nuiton.jredmine.model.Attachment; +import org.nuiton.jredmine.model.Issue; +import org.nuiton.jredmine.model.IssueCategory; +import org.nuiton.jredmine.model.IssuePriority; +import org.nuiton.jredmine.model.IssueStatus; +import org.nuiton.jredmine.model.News; +import org.nuiton.jredmine.model.Project; +import org.nuiton.jredmine.model.TimeEntry; +import org.nuiton.jredmine.model.Tracker; +import org.nuiton.jredmine.model.User; +import org.nuiton.jredmine.model.Version; +import org.nuiton.jredmine.model.io.xpp3.RedmineDataConverter; + +import java.io.File; +import java.io.IOException; +import java.util.Date; +import java.util.List; + +/** + * fixtures of redmine model. + * + * @author tchemit <chemit@codelutin.com> + * @since 1.4 + */ +public class RedmineFixtures { + + /** Logger. */ + private static final Log log = LogFactory.getLog(RedmineFixtures.class); + + public static final String FILE_TO_UPLOAD_CONTENT = "Fichier à uploader"; + + public static final String PROJECT_NAME = "jredmine"; + + public static final String VERSION_NAME = "1.3"; + + public static final String ISSUE_ID = "2030"; + + private Project JRedmineProject; + + private ArrayListMultimap<Class<?>, Object> model; + + public List<Attachment> getAttachments() { + return get(Attachment.class); + } + + public List<Issue> getIssues() { + return get(Issue.class); + } + + public List<Project> getProjects() { + return get(Project.class); + } + + public List<Tracker> getTrackers() { + return get(Tracker.class); + } + + public List<User> getUsers() { + return get(User.class); + } + + public List<Version> getVersions() { + return get(Version.class); + } + + public <T> List<T> get(Class<T> modelType) { + if (model == null) { + try { + loadModel(); + } catch (Exception ex) { + throw new RuntimeException(ex); + } + } + return (List<T>) model.get(modelType); + } + + public <T> T get(Class<T> type, int pos) { + List<T> ts = get(type); + return ts.get(pos); + } + + public Project getJRedmineProject() { + if (JRedmineProject == null) { + JRedmineProject = new Project(); + JRedmineProject.setName("jredmine"); + JRedmineProject.setIdentifier("jredmine"); + JRedmineProject.setIsPublic(true); + JRedmineProject.setHomepage("http://maven-site.nuiton.org/jredmine"); + JRedmineProject.setDescription( + "Permet de communiquer en java avec un serveur " + "redmine qui a installé le plugin rails jredmine"); + JRedmineProject.setId(36); + JRedmineProject.setStatus(1); + } + return JRedmineProject; + } + + + public static final String VERSION_TO_CREATE_NAME = "do_not_use_me"; + + public Version getVersion() { + Version version = new Version(); + version.setName(VERSION_TO_CREATE_NAME); + version.setDescription("Une version créée par les tests de jredmine," + " ne pas utiliser,et modifier"); + return version; + } + + private void loadModel() + throws Exception { + model = ArrayListMultimap.create(); + + Attachment tempA; + tempA = new Attachment(); + tempA.setAuthorId((Integer) RedmineDataConverter.Integer.convert("4")); + tempA.setContainerId((Integer) RedmineDataConverter.Integer.convert("1")); + tempA.setId((Integer) RedmineDataConverter.Integer.convert("1")); + tempA.setFilesize((Integer) RedmineDataConverter.Integer.convert("411")); + tempA.setDownloads((Integer) RedmineDataConverter.Integer.convert("0")); + tempA.setCreatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-05T12:56:41+02:00")); + tempA.setContainerType((String) RedmineDataConverter.Text.convert("Version")); + tempA.setContentType((String) RedmineDataConverter.Text.convert("application/json")); + tempA.setDigest((String) RedmineDataConverter.Text.convert("6ea84342c7475c05fb077b4aca832f9a")); + tempA.setDiskFilename((String) RedmineDataConverter.Text.convert("090905125641_get_issue.json")); + tempA.setFilename((String) RedmineDataConverter.Text.convert("get_issue.json")); + model.put(Attachment.class, tempA); + tempA = new Attachment(); + tempA.setAuthorId((Integer) RedmineDataConverter.Integer.convert("4")); + tempA.setContainerId((Integer) RedmineDataConverter.Integer.convert("1")); + tempA.setId((Integer) RedmineDataConverter.Integer.convert("1")); + tempA.setFilesize((Integer) RedmineDataConverter.Integer.convert("411")); + tempA.setDownloads((Integer) RedmineDataConverter.Integer.convert("0")); + tempA.setCreatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-05T12:56:41+02:00")); + tempA.setContainerType((String) RedmineDataConverter.Text.convert("Version")); + tempA.setContentType((String) RedmineDataConverter.Text.convert("application/json")); + tempA.setDigest((String) RedmineDataConverter.Text.convert("6ea84342c7475c05fb077b4aca832f9a")); + tempA.setDiskFilename((String) RedmineDataConverter.Text.convert("090905125641_get_issue.json2")); + tempA.setFilename((String) RedmineDataConverter.Text.convert("get_issue.json2")); + model.put(Attachment.class, tempA); + + Issue tempI; + tempI = new Issue(); + tempI.setAuthorId((Integer) RedmineDataConverter.Integer.convert("5")); + tempI.setCategoryId((Integer) RedmineDataConverter.Integer.convert("2")); + tempI.setDoneRatio((Integer) RedmineDataConverter.Integer.convert("0")); + tempI.setLockVersion((Integer) RedmineDataConverter.Integer.convert("7")); + tempI.setPriorityId((Integer) RedmineDataConverter.Integer.convert("4")); + tempI.setProjectId((Integer) RedmineDataConverter.Integer.convert("1")); + tempI.setStatusId((Integer) RedmineDataConverter.Integer.convert("3")); + tempI.setTrackerId((Integer) RedmineDataConverter.Integer.convert("1")); + tempI.setFixedVersionId((Integer) RedmineDataConverter.Integer.convert("1")); + tempI.setId((Integer) RedmineDataConverter.Integer.convert("3")); + tempI.setParentId((Integer) RedmineDataConverter.Integer.convert("3")); + tempI.setRootId((Integer) RedmineDataConverter.Integer.convert("3")); + tempI.setLft((Integer) RedmineDataConverter.Integer.convert("1")); + tempI.setRgt((Integer) RedmineDataConverter.Integer.convert("2")); + tempI.setCreatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-04T20:11:52+02:00")); + tempI.setUpdatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-06T00:37:40+02:00")); + tempI.setStartDate((Date) RedmineDataConverter.Date.convert("2009-09-04")); + tempI.setDescription((String) RedmineDataConverter.Text.convert("avec une description !")); + tempI.setSubject((String) RedmineDataConverter.Text.convert("yes!")); + model.put(Issue.class, tempI); + tempI = new Issue(); + tempI.setAuthorId((Integer) RedmineDataConverter.Integer.convert("5")); + tempI.setCategoryId((Integer) RedmineDataConverter.Integer.convert("2")); + tempI.setDoneRatio((Integer) RedmineDataConverter.Integer.convert("0")); + tempI.setLockVersion((Integer) RedmineDataConverter.Integer.convert("7")); + tempI.setPriorityId((Integer) RedmineDataConverter.Integer.convert("4")); + tempI.setProjectId((Integer) RedmineDataConverter.Integer.convert("1")); + tempI.setStatusId((Integer) RedmineDataConverter.Integer.convert("3")); + tempI.setTrackerId((Integer) RedmineDataConverter.Integer.convert("1")); + tempI.setFixedVersionId((Integer) RedmineDataConverter.Integer.convert("1")); + tempI.setId((Integer) RedmineDataConverter.Integer.convert("4")); + tempI.setCreatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-04T20:11:52+02:00")); + tempI.setUpdatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-06T00:37:40+02:00")); + tempI.setStartDate((Date) RedmineDataConverter.Date.convert("2009-09-04")); + tempI.setDescription((String) RedmineDataConverter.Text.convert("avec une description !2")); + tempI.setSubject((String) RedmineDataConverter.Text.convert("yes!2")); + model.put(Issue.class, tempI); + + Project tempP; + tempP = new Project(); + tempP.setCreatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-04T18:11:54+02:00")); + tempP.setUpdatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-04T18:11:54+02:00")); + tempP.setIdentifier((String) RedmineDataConverter.Text.convert("one")); + tempP.setName((String) RedmineDataConverter.Text.convert("one")); + tempP.setId((Integer) RedmineDataConverter.Integer.convert("1")); + tempP.setLft((Integer) RedmineDataConverter.Integer.convert("1")); + tempP.setRgt((Integer) RedmineDataConverter.Integer.convert("2")); + tempP.setProjectsCount((Integer) RedmineDataConverter.Integer.convert("0")); + tempP.setStatus((Integer) RedmineDataConverter.Integer.convert("1")); + tempP.setIsPublic((Boolean) RedmineDataConverter.Boolean.convert("true")); + model.put(Project.class, tempP); + tempP = new Project(); + tempP.setCreatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-05T16:22:14+02:00")); + tempP.setUpdatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-05T16:22:29+02:00")); + tempP.setIdentifier((String) RedmineDataConverter.Text.convert("two")); + tempP.setName((String) RedmineDataConverter.Text.convert("two")); + tempP.setId((Integer) RedmineDataConverter.Integer.convert("2")); + tempP.setProjectsCount((Integer) RedmineDataConverter.Integer.convert("0")); + tempP.setStatus((Integer) RedmineDataConverter.Integer.convert("1")); + tempP.setIsPublic((Boolean) RedmineDataConverter.Boolean.convert("false")); + model.put(Project.class, tempP); + + Tracker tempT; + tempT = new Tracker(); + tempT.setId((Integer) RedmineDataConverter.Integer.convert("1")); + tempT.setProjectId((Integer) RedmineDataConverter.Integer.convert("1")); + tempT.setTrackerId((Integer) RedmineDataConverter.Integer.convert("1")); + tempT.setPosition((Integer) RedmineDataConverter.Integer.convert("1")); + tempT.setIsInChlog((Boolean) RedmineDataConverter.Boolean.convert("true")); + tempT.setIsInRoadmap((Boolean) RedmineDataConverter.Boolean.convert("false")); + tempT.setName((String) RedmineDataConverter.Text.convert("Anomalie")); + model.put(Tracker.class, tempT); + tempT = new Tracker(); + tempT.setId((Integer) RedmineDataConverter.Integer.convert("2")); + tempT.setIsInChlog((Boolean) RedmineDataConverter.Boolean.convert("true")); + tempT.setIsInRoadmap((Boolean) RedmineDataConverter.Boolean.convert("true")); + tempT.setName((String) RedmineDataConverter.Text.convert("Evolution")); + tempT.setPosition((Integer) RedmineDataConverter.Integer.convert("2")); + tempT.setProjectId((Integer) RedmineDataConverter.Integer.convert("1")); + tempT.setTrackerId((Integer) RedmineDataConverter.Integer.convert("2")); + model.put(Tracker.class, tempT); + tempT = new Tracker(); + tempT.setId((Integer) RedmineDataConverter.Integer.convert("3")); + tempT.setIsInChlog((Boolean) RedmineDataConverter.Boolean.convert("false")); + tempT.setIsInRoadmap((Boolean) RedmineDataConverter.Boolean.convert("false")); + tempT.setName((String) RedmineDataConverter.Text.convert("Assistance")); + tempT.setPosition((Integer) RedmineDataConverter.Integer.convert("3")); + tempT.setProjectId((Integer) RedmineDataConverter.Integer.convert("1")); + tempT.setTrackerId((Integer) RedmineDataConverter.Integer.convert("3")); + model.put(Tracker.class, tempT); + + User tempU; + tempU = new User(); + tempU.setCreatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-04T17:24:46+02:00")); + tempU.setUpdatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-06T01:23:59+02:00")); + tempU.setLastLoginOn((Date) RedmineDataConverter.Datetime.convert("2009-09-06T01:23:59+02:00")); + tempU.setId((Integer) RedmineDataConverter.Integer.convert("1")); + tempU.setMemberId((Integer) RedmineDataConverter.Integer.convert("5")); + tempU.setRoleId((Integer) RedmineDataConverter.Integer.convert("3")); + tempU.setStatus((Integer) RedmineDataConverter.Integer.convert("1")); + tempU.setAdmin((Boolean) RedmineDataConverter.Boolean.convert("true")); + tempU.setMailNotification((Boolean) RedmineDataConverter.Boolean.convert("true")); + tempU.setFirstname((String) RedmineDataConverter.Text.convert("Redmine")); + tempU.setHashedPassword( + (String) RedmineDataConverter.Text.convert("70c881d4a26984ddce795f6f71817c9cf4480e79")); + tempU.setLanguage((String) RedmineDataConverter.Text.convert("fr")); + tempU.setLastname((String) RedmineDataConverter.Text.convert("Admin")); + tempU.setLogin((String) RedmineDataConverter.Text.convert("admin")); + tempU.setMail((String) RedmineDataConverter.Text.convert("dummy@codelutin.com")); + tempU.setIdentityUrl((String) RedmineDataConverter.Text.convert("yo")); + model.put(User.class, tempU); + tempU = new User(); + tempU.setAdmin((Boolean) RedmineDataConverter.Boolean.convert("true")); + tempU.setCreatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-04T19:49:02+02:00")); + tempU.setFirstname((String) RedmineDataConverter.Text.convert("tony")); + tempU.setHashedPassword( + (String) RedmineDataConverter.Text.convert("8aed1322e5450badb078e1fb60a817a1df25a2ca")); + tempU.setId((Integer) RedmineDataConverter.Integer.convert("5")); + tempU.setLanguage((String) RedmineDataConverter.Text.convert("fr")); + tempU.setLastLoginOn((Date) RedmineDataConverter.Datetime.convert("2009-09-04T19:49:38+02:00")); + tempU.setLastname((String) RedmineDataConverter.Text.convert("chemit2")); + tempU.setLogin((String) RedmineDataConverter.Text.convert("tchemit2")); + tempU.setMail((String) RedmineDataConverter.Text.convert("chemit@codelutin.com")); + tempU.setMailNotification((Boolean) RedmineDataConverter.Boolean.convert("false")); + tempU.setMemberId((Integer) RedmineDataConverter.Integer.convert("4")); + tempU.setRoleId((Integer) RedmineDataConverter.Integer.convert("3")); + tempU.setStatus((Integer) RedmineDataConverter.Integer.convert("1")); + tempU.setUpdatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-04T19:49:38+02:00")); + model.put(User.class, tempU); + tempU = new User(); + tempU.setAdmin((Boolean) RedmineDataConverter.Boolean.convert("false")); + tempU.setCreatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-05T16:24:11+02:00")); + tempU.setFirstname((String) RedmineDataConverter.Text.convert("dev")); + tempU.setHashedPassword( + (String) RedmineDataConverter.Text.convert("70c881d4a26984ddce795f6f71817c9cf4480e79")); + tempU.setId((Integer) RedmineDataConverter.Integer.convert("7")); + tempU.setLanguage((String) RedmineDataConverter.Text.convert("fr")); + tempU.setLastLoginOn((Date) RedmineDataConverter.Datetime.convert("2009-09-06T16:34:39+02:00")); + tempU.setLastname((String) RedmineDataConverter.Text.convert("dev")); + tempU.setLogin((String) RedmineDataConverter.Text.convert("dev")); + tempU.setMail((String) RedmineDataConverter.Text.convert("dev3@ynot-home.info")); + tempU.setMailNotification((Boolean) RedmineDataConverter.Boolean.convert("false")); + tempU.setMemberId((Integer) RedmineDataConverter.Integer.convert("9")); + tempU.setRoleId((Integer) RedmineDataConverter.Integer.convert("4")); + tempU.setStatus((Integer) RedmineDataConverter.Integer.convert("1")); + tempU.setUpdatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-06T16:34:39+02:00")); + model.put(User.class, tempU); + + Version tempV; + tempV = new Version(); + tempV.setCreatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-06T02:47:39+02:00")); + tempV.setDescription((String) RedmineDataConverter.Text.convert("yo")); + tempV.setId((Integer) RedmineDataConverter.Integer.convert("9")); + tempV.setName((String) RedmineDataConverter.Text.convert("yor")); + tempV.setSharing((String) RedmineDataConverter.Text.convert("none")); + tempV.setStatus((String) RedmineDataConverter.Text.convert("open")); + tempV.setProjectId((Integer) RedmineDataConverter.Integer.convert("1")); + tempV.setUpdatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-06T02:50:49+02:00")); + model.put(Version.class, tempV); + tempV = new Version(); + tempV.setCreatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-06T03:05:09+02:00")); + tempV.setDescription((String) RedmineDataConverter.Text.convert("ysssoye")); + tempV.setId((Integer) RedmineDataConverter.Integer.convert("13")); + tempV.setName((String) RedmineDataConverter.Text.convert("rrrrrrrrrouuuuuua")); + tempV.setProjectId((Integer) RedmineDataConverter.Integer.convert("1")); + tempV.setUpdatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-06T03:05:09+02:00")); + model.put(Version.class, tempV); + tempV = new Version(); + tempV.setCreatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-06T03:07:58+02:00")); + tempV.setDescription((String) RedmineDataConverter.Text.convert("ysssoye")); + tempV.setId((Integer) RedmineDataConverter.Integer.convert("15")); + tempV.setName((String) RedmineDataConverter.Text.convert("aaaauuuuuua")); + tempV.setProjectId((Integer) RedmineDataConverter.Integer.convert("1")); + tempV.setUpdatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-06T03:07:58+02:00")); + model.put(Version.class, tempV); + tempV = new Version(); + tempV.setCreatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-06T04:12:25+02:00")); + tempV.setDescription((String) RedmineDataConverter.Text.convert("ysssoyeppppppppppppppppp")); + tempV.setId((Integer) RedmineDataConverter.Integer.convert("16")); + tempV.setName((String) RedmineDataConverter.Text.convert("aaaau")); + tempV.setProjectId((Integer) RedmineDataConverter.Integer.convert("1")); + tempV.setUpdatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-06T04:13:20+02:00")); + model.put(Version.class, tempV); + tempV = new Version(); + tempV.setCreatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-06T03:05:40+02:00")); + tempV.setDescription((String) RedmineDataConverter.Text.convert("ysssoye")); + tempV.setId((Integer) RedmineDataConverter.Integer.convert("14")); + tempV.setName((String) RedmineDataConverter.Text.convert("aaaaaaaaaarrrrrrrrrouuuuuua")); + tempV.setProjectId((Integer) RedmineDataConverter.Integer.convert("1")); + tempV.setUpdatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-06T03:05:40+02:00")); + model.put(Version.class, tempV); + tempV = new Version(); + tempV.setCreatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-05T00:39:15+02:00")); + tempV.setId((Integer) RedmineDataConverter.Integer.convert("5")); + tempV.setName((String) RedmineDataConverter.Text.convert("2")); + tempV.setProjectId((Integer) RedmineDataConverter.Integer.convert("1")); + tempV.setUpdatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-05T00:39:15+02:00")); + model.put(Version.class, tempV); + tempV = new Version(); + tempV.setCreatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-04T18:13:05+02:00")); + tempV.setId((Integer) RedmineDataConverter.Integer.convert("1")); + tempV.setName((String) RedmineDataConverter.Text.convert("1.0.0")); + tempV.setProjectId((Integer) RedmineDataConverter.Integer.convert("1")); + tempV.setUpdatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-04T18:13:05+02:00")); + model.put(Version.class, tempV); + tempV = new Version(); + tempV.setCreatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-06T03:00:12+02:00")); + tempV.setDescription((String) RedmineDataConverter.Text.convert("yoye")); + tempV.setEffectiveDate((Date) RedmineDataConverter.Date.convert("2009-09-06")); + tempV.setId((Integer) RedmineDataConverter.Integer.convert("11")); + tempV.setName((String) RedmineDataConverter.Text.convert("yaouuuuuua")); + tempV.setProjectId((Integer) RedmineDataConverter.Integer.convert("1")); + tempV.setUpdatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-06T03:00:12+02:00")); + model.put(Version.class, tempV); + tempV = new Version(); + tempV.setCreatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-06T02:50:59+02:00")); + tempV.setDescription((String) RedmineDataConverter.Text.convert("yoye")); + tempV.setEffectiveDate((Date) RedmineDataConverter.Date.convert("2009-09-06")); + tempV.setId((Integer) RedmineDataConverter.Integer.convert("10")); + tempV.setName((String) RedmineDataConverter.Text.convert("ya")); + tempV.setProjectId((Integer) RedmineDataConverter.Integer.convert("1")); + tempV.setUpdatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-06T02:54:16+02:00")); + model.put(Version.class, tempV); + tempV = new Version(); + tempV.setCreatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-06T03:00:37+02:00")); + tempV.setDescription((String) RedmineDataConverter.Text.convert("ysssoye")); + tempV.setEffectiveDate((Date) RedmineDataConverter.Date.convert("2009-09-06")); + tempV.setId((Integer) RedmineDataConverter.Integer.convert("12")); + tempV.setName((String) RedmineDataConverter.Text.convert("ouuuuuua")); + tempV.setProjectId((Integer) RedmineDataConverter.Integer.convert("1")); + tempV.setUpdatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-06T03:00:42+02:00")); + model.put(Version.class, tempV); + + IssueStatus tempIS; + tempIS = new IssueStatus(); + tempIS.setId(1); + tempIS.setName("Nouveau"); + tempIS.setPosition(1); + tempIS.setDefaultDoneRatio(10); + tempIS.setIsClosed(false); + tempIS.setIsDefault(true); + model.put(IssueStatus.class, tempIS); + tempIS = new IssueStatus(); + tempIS.setId(2); + tempIS.setName("Assigné"); + tempIS.setPosition(2); + tempIS.setIsClosed(false); + tempIS.setIsDefault(false); + model.put(IssueStatus.class, tempIS); + tempIS = new IssueStatus(); + tempIS.setId(3); + tempIS.setName("Résolu"); + tempIS.setPosition(3); + tempIS.setIsClosed(false); + tempIS.setIsDefault(false); + model.put(IssueStatus.class, tempIS); + tempIS = new IssueStatus(); + tempIS.setId(4); + tempIS.setName("Commentaire"); + tempIS.setPosition(4); + tempIS.setIsClosed(false); + tempIS.setIsDefault(false); + model.put(IssueStatus.class, tempIS); + tempIS = new IssueStatus(); + tempIS.setId(5); + tempIS.setName("Fermé"); + tempIS.setPosition(5); + tempIS.setIsClosed(true); + tempIS.setIsDefault(false); + model.put(IssueStatus.class, tempIS); + tempIS = new IssueStatus(); + tempIS.setId(6); + tempIS.setPosition(6); + tempIS.setName("Rejeté"); + tempIS.setIsClosed(true); + tempIS.setIsDefault(false); + model.put(IssueStatus.class, tempIS); + + IssuePriority tempIP; + tempIP = new IssuePriority(); + tempIP.setId(3); + tempIP.setParentId(1); + tempIP.setProjectId(2); + tempIP.setName("Bas"); + tempIP.setPosition(1); + tempIP.setOpt("IPRI"); + tempIP.setIsDefault(false); + tempIP.setActive(true); + model.put(IssuePriority.class, tempIP); + tempIP = new IssuePriority(); + tempIP.setId(4); + tempIP.setName("Normal"); + tempIP.setPosition(2); + tempIP.setOpt("IPRI"); + tempIP.setIsDefault(true); + model.put(IssuePriority.class, tempIP); + tempIP = new IssuePriority(); + tempIP.setId(5); + tempIP.setName("Haut"); + tempIP.setPosition(3); + tempIP.setOpt("IPRI"); + tempIP.setIsDefault(false); + model.put(IssuePriority.class, tempIP); + tempIP = new IssuePriority(); + tempIP.setId(6); + tempIP.setName("Urgent"); + tempIP.setPosition(4); + tempIP.setOpt("IPRI"); + tempIP.setIsDefault(false); + model.put(IssuePriority.class, tempIP); + tempIP = new IssuePriority(); + tempIP.setId(7); + tempIP.setName("Immédiat"); + tempIP.setPosition(5); + tempIP.setOpt("IPRI"); + tempIP.setIsDefault(false); + model.put(IssuePriority.class, tempIP); + + IssueCategory tempIC; + tempIC = new IssueCategory(); + tempIC.setId(1); + tempIC.setName("categorie one"); + tempIC.setProjectId(1); + model.put(IssueCategory.class, tempIC); + tempIC = new IssueCategory(); + tempIC.setId(2); + tempIC.setName("categorie two"); + tempIC.setProjectId(1); + model.put(IssueCategory.class, tempIC); + + News tempN; + tempN = new News(); + tempN.setId(85); + tempN.setCreatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-17T21:50:26+02:00")); + tempN.setProjectId(1); + tempN.setAuthorId(4); + tempN.setCommentsCount(0); + tempN.setDescription("description"); + tempN.setSummary("summary"); + tempN.setTitle("title"); + model.put(News.class, tempN); + tempN = new News(); + tempN.setId(86); + tempN.setCreatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-17T21:55:26+02:00")); + tempN.setProjectId(1); + tempN.setAuthorId(4); + tempN.setCommentsCount(0); + tempN.setDescription("description2"); + tempN.setSummary("summary2"); + tempN.setTitle("title2"); + model.put(News.class, tempN); + + TimeEntry tempE; + + tempE = new TimeEntry(); + tempE.setCreatedOn((Date) RedmineDataConverter.Datetime.convert("2009-12-31T23:02:02+01:00")); + tempE.setUpdatedOn((Date) RedmineDataConverter.Datetime.convert("2009-12-31T23:02:02+01:00")); + tempE.setSpentOn((Date) RedmineDataConverter.Date.convert("2009-12-31")); + tempE.setId(1); + tempE.setProjectId(1); + tempE.setUserId(4); + tempE.setIssueId(6); + tempE.setActivityId(8); + + tempE.setHours(1); + tempE.setTmonth(12); + tempE.setTyear(2009); + tempE.setTweek(53); + tempE.setComments("Test"); + model.put(TimeEntry.class, tempE); + + tempE = new TimeEntry(); + tempE.setCreatedOn((Date) RedmineDataConverter.Datetime.convert("2009-12-31T23:10:01+01:00")); + tempE.setUpdatedOn((Date) RedmineDataConverter.Datetime.convert("2009-12-31T23:10:01+01:00")); + tempE.setSpentOn((Date) RedmineDataConverter.Date.convert("2009-12-31")); + tempE.setId(2); + tempE.setProjectId(1); + tempE.setUserId(4); + tempE.setIssueId(6); + tempE.setActivityId(9); + + tempE.setHours(2); + tempE.setTmonth(12); + tempE.setTyear(2009); + tempE.setTweek(53); + tempE.setComments("deuxième temps"); + model.put(TimeEntry.class, tempE); + } + + + public Attachment getAttachment() { + Attachment result = new Attachment(); + File fileToUpload = null; + try { + fileToUpload = File.createTempFile("toupload", ".txt"); + FileUtils.write(fileToUpload, FILE_TO_UPLOAD_CONTENT); + result.setToUpload(fileToUpload); + result.setDescription("attachment description..."); + return result; + } catch (IOException e) { + throw new RuntimeException("Could not create temp file", e); + } + + } +} Property changes on: trunk/jredmine-domain/src/test/java/org/nuiton/jredmine/RedmineFixtures.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Deleted: trunk/jredmine-domain/src/test/java/org/nuiton/jredmine/model/io/RedmineXpp3HelperTest.java =================================================================== --- trunk/jredmine-client/src/test/java/org/nuiton/jredmine/model/io/xpp3/RedmineXpp3HelperTest.java 2012-05-30 14:37:21 UTC (rev 258) +++ trunk/jredmine-domain/src/test/java/org/nuiton/jredmine/model/io/RedmineXpp3HelperTest.java 2012-07-12 10:14:14 UTC (rev 259) @@ -1,356 +0,0 @@ -/* - * #%L - * JRedmine :: Client - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2010 Tony Chemit, CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ -package org.nuiton.jredmine.model.io.xpp3; - -import com.google.common.base.Preconditions; -import com.google.common.base.Supplier; -import com.google.common.collect.Lists; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.nuiton.jredmine.TestHelper; -import org.nuiton.jredmine.model.Attachment; -import org.nuiton.jredmine.model.Issue; -import org.nuiton.jredmine.model.IssueCategory; -import org.nuiton.jredmine.model.IssuePriority; -import org.nuiton.jredmine.model.IssueStatus; -import org.nuiton.jredmine.model.News; -import org.nuiton.jredmine.model.Project; -import org.nuiton.jredmine.model.TimeEntry; -import org.nuiton.jredmine.model.Tracker; -import org.nuiton.jredmine.model.User; -import org.nuiton.jredmine.model.Version; - -import java.beans.Introspector; -import java.io.Closeable; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -/** - * @author tchemit <chemit@codelutin.com> - * @since 1.0.0 - */ -@RunWith(Parameterized.class) -public class RedmineXpp3HelperTest<T> { - - @Parameterized.Parameters - public static List<Object[]> data() { - return Arrays.asList(new Object[][]{ - {"single", Attachment.class, newSingleData(Attachment.class)}, - {"single", Issue.class, newSingleData(Issue.class)}, - {"single", IssueCategory.class, newSingleData(IssueCategory.class)}, - {"single", IssuePriority.class, newSingleData(IssuePriority.class)}, - {"single", IssueStatus.class, newSingleData(IssueStatus.class)}, - {"single", News.class, newSingleData(News.class)}, - {"single", Project.class, newSingleData(Project.class)}, - {"single", TimeEntry.class, newSingleData(TimeEntry.class)}, - {"single", Tracker.class, newSingleData(Tracker.class)}, - {"single", User.class, newSingleData(User.class)}, - {"single", Version.class, newSingleData(Version.class)}, - {"single2", Issue.class, new SingleDataSupplier<Issue>(Issue.class) { - - @Override - public Issue get() { - Issue issue = super.get(); - issue.setIsPrivate(true); - return issue; - } - - @Override - public void close() throws IOException { - super.close(); - Issue issue = get(); - issue.setIsPrivate(false); - } - }}, - {"single2", User.class, new SingleDataSupplier<User>(User.class) { - - @Override - public User get() { - User user = super.get(); - user.setSalt("38006729a049cd820aafd6c2bb3b193f"); - return user; - } - - @Override - public void close() throws IOException { - super.close(); - User issue = get(); - issue.setSalt(null); - } - }}, - - {"array-empty", Attachment.class, newEmptyListData(Attachment.class)}, - {"array-empty", Issue.class, newEmptyListData(Issue.class)}, - {"array-empty", IssueCategory.class, newEmptyListData(Attachment.class)}, - {"array-empty", IssuePriority.class, newEmptyListData(IssuePriority.class)}, - {"array-empty", IssueStatus.class, newEmptyListData(IssueStatus.class)}, - {"array-empty", News.class, newEmptyListData(News.class)}, - {"array-empty", Project.class, newEmptyListData(Project.class)}, - {"array-empty", TimeEntry.class, newEmptyListData(TimeEntry.class)}, - {"array-empty", Tracker.class, newEmptyListData(Tracker.class)}, - {"array-empty", User.class, newEmptyListData(User.class)}, - {"array-empty", Version.class, newEmptyListData(Version.class)}, - - {"array-empty2", Attachment.class, newEmptyListData(Attachment.class)}, - {"array-empty2", Issue.class, newEmptyListData(Issue.class)}, - {"array-empty2", IssueCategory.class, newEmptyListData(IssueCategory.class)}, - {"array-empty2", IssuePriority.class, newEmptyListData(IssuePriority.class)}, - {"array-empty2", IssueStatus.class, newEmptyListData(IssueStatus.class)}, - {"array-empty2", News.class, newEmptyListData(News.class)}, - {"array-empty2", Project.class, newEmptyListData(Project.class)}, - {"array-empty2", TimeEntry.class, newEmptyListData(TimeEntry.class)}, - {"array-empty2", Tracker.class, newEmptyListData(Tracker.class)}, - {"array-empty2", User.class, newEmptyListData(User.class)}, - {"array-empty2", Version.class, newEmptyListData(Version.class)}, - - - {"array-singleton", Attachment.class, newSingletonListData(Attachment.class)}, - {"array-singleton", Issue.class, newSingletonListData(Issue.class)}, - {"array-singleton", IssueCategory.class, newSingletonListData(IssueCategory.class)}, - {"array-singleton", IssuePriority.class, newSingletonListData(IssuePriority.class)}, - {"array-singleton", IssueStatus.class, newSingletonListData(IssueStatus.class)}, - {"array-singleton", News.class, newSingletonListData(News.class)}, - {"array-singleton", Project.class, newSingletonListData(Project.class)}, - {"array-singleton", TimeEntry.class, newSingletonListData(TimeEntry.class)}, - {"array-singleton", Tracker.class, newSingletonListData(Tracker.class)}, - {"array-singleton", User.class, newSingletonListData(User.class)}, - {"array-singleton", Version.class, newSingletonListData(Version.class)}, - - {"array-multi", Attachment.class, newMultiListData(Attachment.class)}, - {"array-multi", Issue.class, newMultiListData(Issue.class)}, - {"array-multi", IssueCategory.class, newMultiListData(IssueCategory.class)}, - {"array-multi", IssuePriority.class, newMultiListData(IssuePriority.class)}, - {"array-multi", IssueStatus.class, newMultiListData(IssueStatus.class)}, - {"array-multi", News.class, newMultiListData(News.class)}, - {"array-multi", Project.class, newMultiListData(Project.class)}, - {"array-multi", TimeEntry.class, newMultiListData(TimeEntry.class)}, - {"array-multi", Tracker.class, newMultiListData(Tracker.class)}, - {"array-multi", User.class, newMultiListData(User.class)}, - {"array-multi", Version.class, newMultiListData(Version.class)}, - }); - } - - protected static File testDir; - - protected static RedmineXpp3Helper builder; - - private final Class<T> type; - - private final Supplier<?> result; - - protected final String resourcePath; - - public RedmineXpp3HelperTest(String path, - Class<T> type, - Supplier<?> result) { - Preconditions.checkNotNull(path); - Preconditions.checkNotNull(type); - Preconditions.checkNotNull(result); - this.type = type; - this.result = result; - resourcePath = "/" + getClass().getPackage().getName().replaceAll("\\.", "/") + "/" + path + "/" + Introspector.decapitalize(type.getSimpleName()) + ".xml"; - } - - @BeforeClass - public static void setUpClass() throws Exception { - - testDir = TestHelper.getTestDir(RedmineXpp3HelperTest.class.getPackage().getName(), "target" + File.separator + "test-classes"); - - builder = new RedmineXpp3Helper(); - - // setup memory model - TestHelper.loadMemoryModel(); - } - - @AfterClass - public static void tearDownClass() throws Exception { - testDir = null; - builder = null; - } - - @After - public void tearDown() throws IOException { - if (result instanceof Closeable) { - ((Closeable) result).close(); - } - - } - - /** - * Test the method {@code read} of class ModelBuilder. - * - * @throws Exception for any exceptions - */ - @Test - public void testRead() throws Exception { - - Object expected = result.get(); - - InputStream stream = getClass().getResourceAsStream(resourcePath); - try { - - if (expected instanceof List<?>) { - - testForListData(stream, (List<T>) expected); - - } else { - - testForSingleData(stream, (T) expected); - } - } finally { - if (stream != null) { - stream.close(); - } - } - } - - protected void testForSingleData(InputStream stream, T expected) throws Exception { - - T actual; - - // test from file - - try { - actual = builder.readObject(type, stream, true); - } catch (Exception e) { - throw new IllegalStateException("Could not read from resource " + resourcePath, e); - } - TestHelper.assertMyEquals(type, expected, actual); - - } - - protected void testForListData(InputStream stream, List<T> expected) throws Exception { - - T[] actual; - - // test from file - - try { - actual = builder.readObjects(type, stream, true); - } catch (Exception e) { - throw new IllegalStateException("Could not read " + resourcePath, e); - } - TestHelper.assertMyListEquals(type, expected, actual); - } - - static class SingleDataSupplier<T> implements Supplier<T>, Closeable { - - protected final Class<T> type; - - SingleDataSupplier(Class<T> type) { - this.type = type; - } - - @Override - public T get() { - return TestHelper.getModel(type, 0); - } - - @Override - public void close() throws IOException { - } - } - - static class EmptyListDataSupplier<T> implements Supplier<List<T>>, Closeable { - - protected final Class<T> type; - - EmptyListDataSupplier(Class<T> type) { - this.type = type; - } - - @Override - public List<T> get() { - return Collections.emptyList(); - } - - @Override - public void close() throws IOException { - } - } - - static class SingletonListDataSupplier<T> implements Supplier<List<T>>, Closeable { - - protected final Class<T> type; - - SingletonListDataSupplier(Class<T> type) { - this.type = type; - } - - @Override - public List<T> get() { - T model = TestHelper.getModel(type, 0); - List<T> result = Lists.newArrayList(); - result.add(model); - return result; - } - - @Override - public void close() throws IOException { - } - } - - static class MultiListDataSupplier<T> implements Supplier<List<T>>, Closeable { - - protected final Class<T> type; - - MultiListDataSupplier(Class<T> type) { - this.type = type; - } - - @Override - public List<T> get() { - return TestHelper.getModel(type); - } - - @Override - public void close() throws IOException { - } - } - - public static <T> SingleDataSupplier<T> newSingleData(Class<T> type) { - return new SingleDataSupplier<T>(type); - } - - public static <T> EmptyListDataSupplier<T> newEmptyListData(Class<T> type) { - return new EmptyListDataSupplier<T>(type); - } - - public static <T> SingletonListDataSupplier<T> newSingletonListData(Class<T> type) { - return new SingletonListDataSupplier<T>(type); - } - - public static <T> MultiListDataSupplier<T> newMultiListData(Class<T> type) { - return new MultiListDataSupplier<T>(type); - } -} Added: trunk/jredmine-domain/src/test/java/org/nuiton/jredmine/model/io/xpp3/RedmineXpp3HelperTest.java =================================================================== --- trunk/jredmine-domain/src/test/java/org/nuiton/jredmine/model/io/xpp3/RedmineXpp3HelperTest.java (rev 0) +++ trunk/jredmine-domain/src/test/java/org/nuiton/jredmine/model/io/xpp3/RedmineXpp3HelperTest.java 2012-07-12 10:14:14 UTC (rev 259) @@ -0,0 +1,378 @@ +/* + * #%L + * JRedmine :: Client + * + * $Id: RedmineXpp3HelperTest.java 252 2012-03-25 14:37:37Z tchemit $ + * $HeadURL: http://svn.nuiton.org/svn/jredmine/trunk/jredmine-client/src/test/java/org/n... $ + * %% + * Copyright (C) 2009 - 2010 Tony Chemit, CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ +package org.nuiton.jredmine.model.io.xpp3; + +import com.google.common.base.Preconditions; +import com.google.common.base.Supplier; +import com.google.common.collect.Lists; +import junit.framework.Assert; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.nuiton.io.xpp3.AbstractXpp3Reader; +import org.nuiton.io.xpp3.PropertyMapper; +import org.nuiton.io.xpp3.Xpp3Helper; +import org.nuiton.jredmine.RedmineFixtures; +import org.nuiton.jredmine.model.Attachment; +import org.nuiton.jredmine.model.Issue; +import org.nuiton.jredmine.model.IssueCategory; +import org.nuiton.jredmine.model.IssuePriority; +import org.nuiton.jredmine.model.IssueStatus; +import org.nuiton.jredmine.model.News; +import org.nuiton.jredmine.model.Project; +import org.nuiton.jredmine.model.TimeEntry; +import org.nuiton.jredmine.model.Tracker; +import org.nuiton.jredmine.model.User; +import org.nuiton.jredmine.model.Version; + +import java.beans.Introspector; +import java.io.Closeable; +import java.io.IOException; +import java.io.InputStream; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +/** + * @author tchemit <chemit@codelutin.com> + * @since 1.0.0 + */ +@RunWith(Parameterized.class) +public class RedmineXpp3HelperTest<T> { + + @Parameterized.Parameters + public static List<Object[]> data() { + return Arrays.asList(new Object[][]{ + {"single", Attachment.class, newSingleData(Attachment.class)}, + {"single", Issue.class, newSingleData(Issue.class)}, + {"single", IssueCategory.class, newSingleData(IssueCategory.class)}, + {"single", IssuePriority.class, newSingleData(IssuePriority.class)}, + {"single", IssueStatus.class, newSingleData(IssueStatus.class)}, + {"single", News.class, newSingleData(News.class)}, + {"single", Project.class, newSingleData(Project.class)}, + {"single", TimeEntry.class, newSingleData(TimeEntry.class)}, + {"single", Tracker.class, newSingleData(Tracker.class)}, + {"single", User.class, newSingleData(User.class)}, + {"single", Version.class, newSingleData(Version.class)}, + {"single2", Issue.class, new SingleDataSupplier<Issue>(Issue.class) { + + @Override + public List<Issue> get() { + List<Issue> issues = super.get(); + issues.get(0).setIsPrivate(true); + return issues; + } + + @Override + public void close() throws IOException { + super.close(); + List<Issue> issues = super.get(); + issues.get(0).setIsPrivate(false); + } + }}, + {"single2", User.class, new SingleDataSupplier<User>(User.class) { + + @Override + public List<User> get() { + List<User> users = super.get(); + users.get(0).setSalt("38006729a049cd820aafd6c2bb3b193f"); + return users; + } + + @Override + public void close() throws IOException { + super.close(); + List<User> users = get(); + users.get(0).setSalt(null); + } + }}, + + {"array-empty", Attachment.class, newEmptyListData(Attachment.class)}, + {"array-empty", Issue.class, newEmptyListData(Issue.class)}, + {"array-empty", IssueCategory.class, newEmptyListData(Attachment.class)}, + {"array-empty", IssuePriority.class, newEmptyListData(IssuePriority.class)}, + {"array-empty", IssueStatus.class, newEmptyListData(IssueStatus.class)}, + {"array-empty", News.class, newEmptyListData(News.class)}, + {"array-empty", Project.class, newEmptyListData(Project.class)}, + {"array-empty", TimeEntry.class, newEmptyListData(TimeEntry.class)}, + {"array-empty", Tracker.class, newEmptyListData(Tracker.class)}, + {"array-empty", User.class, newEmptyListData(User.class)}, + {"array-empty", Version.class, newEmptyListData(Version.class)}, + + {"array-empty2", Attachment.class, newEmptyListData(Attachment.class)}, + {"array-empty2", Issue.class, newEmptyListData(Issue.class)}, + {"array-empty2", IssueCategory.class, newEmptyListData(IssueCategory.class)}, + {"array-empty2", IssuePriority.class, newEmptyListData(IssuePriority.class)}, + {"array-empty2", IssueStatus.class, newEmptyListData(IssueStatus.class)}, + {"array-empty2", News.class, newEmptyListData(News.class)}, + {"array-empty2", Project.class, newEmptyListData(Project.class)}, + {"array-empty2", TimeEntry.class, newEmptyListData(TimeEntry.class)}, + {"array-empty2", Tracker.class, newEmptyListData(Tracker.class)}, + {"array-empty2", User.class, newEmptyListData(User.class)}, + {"array-empty2", Version.class, newEmptyListData(Version.class)}, + + + {"array-singleton", Attachment.class, newSingletonListData(Attachment.class)}, + {"array-singleton", Issue.class, newSingletonListData(Issue.class)}, + {"array-singleton", IssueCategory.class, newSingletonListData(IssueCategory.class)}, + {"array-singleton", IssuePriority.class, newSingletonListData(IssuePriority.class)}, + {"array-singleton", IssueStatus.class, newSingletonListData(IssueStatus.class)}, + {"array-singleton", News.class, newSingletonListData(News.class)}, + {"array-singleton", Project.class, newSingletonListData(Project.class)}, + {"array-singleton", TimeEntry.class, newSingletonListData(TimeEntry.class)}, + {"array-singleton", Tracker.class, newSingletonListData(Tracker.class)}, + {"array-singleton", User.class, newSingletonListData(User.class)}, + {"array-singleton", Version.class, newSingletonListData(Version.class)}, + + {"array-multi", Attachment.class, newMultiListData(Attachment.class)}, + {"array-multi", Issue.class, newMultiListData(Issue.class)}, + {"array-multi", IssueCategory.class, newMultiListData(IssueCategory.class)}, + {"array-multi", IssuePriority.class, newMultiListData(IssuePriority.class)}, + {"array-multi", IssueStatus.class, newMultiListData(IssueStatus.class)}, + {"array-multi", News.class, newMultiListData(News.class)}, + {"array-multi", Project.class, newMultiListData(Project.class)}, + {"array-multi", TimeEntry.class, newMultiListData(TimeEntry.class)}, + {"array-multi", Tracker.class, newMultiListData(Tracker.class)}, + {"array-multi", User.class, newMultiListData(User.class)}, + {"array-multi", Version.class, newMultiListData(Version.class)}, + }); + } + + private static RedmineXpp3Helper builder; + + private static RedmineFixtures fixtures; + + private final Class<T> type; + + private final Supplier<List<T>> result; + + private final String resourcePath; + + public RedmineXpp3HelperTest(String path, + Class<T> type, + Supplier<List<T>> result) { + Preconditions.checkNotNull(path); + Preconditions.checkNotNull(type); + Preconditions.checkNotNull(result); + this.type = type; + this.result = result; + String dotPath = "." + getClass().getPackage().getName() + + "." + path + + "." + Introspector.decapitalize(type.getSimpleName()); + resourcePath = dotPath.replaceAll("\\.", "/") + ".xml"; + } + + @BeforeClass + public static void setUpClass() throws Exception { + + builder = new RedmineXpp3Helper(); + + // setup memory model + fixtures = new RedmineFixtures(); + } + + @AfterClass + public static void tearDownClass() throws Exception { + builder = null; + fixtures = null; + } + + @After + public void tearDown() throws IOException { + if (result instanceof Closeable) { + ((Closeable) result).close(); + } + } + + /** + * Test the method {@code read} of class ModelBuilder. + * + * @throws Exception for any exceptions + */ + @Test + public void testRead() throws Exception { + + List<T> expected = result.get(); + + InputStream stream = getClass().getResourceAsStream(resourcePath); + try { + + if (result instanceof SingleDataSupplier<?>) { + + T actual = builder.readObject(type, stream, true); + assertMyEquals(type, expected.get(0), actual); + + } else { + + T[] actual = builder.readObjects(type, stream, true); + assertMyListEquals(type, expected, actual); + } + } catch (Exception e) { + throw new IllegalStateException( + "Could not read from resource " + resourcePath, e); + } finally { + if (stream != null) { + stream.close(); + } + } + } + + static class SingleDataSupplier<T> implements Supplier<List<T>>, Closeable { + + protected final Class<T> type; + + SingleDataSupplier(Class<T> type) { + this.type = type; + } + + @Override + public List<T> get() { + T t = fixtures.get(type, 0); + List<T> result = Lists.newArrayList(); + result.add(t); + return result; + } + + @Override + public void close() throws IOException { + } + } + + static class EmptyListDataSupplier<T> implements Supplier<List<T>>, Closeable { + + protected final Class<T> type; + + EmptyListDataSupplier(Class<T> type) { + this.type = type; + } + + @Override + public List<T> get() { + return Collections.emptyList(); + } + + @Override + public void close() throws IOException { + } + } + + static class SingletonListDataSupplier<T> implements Supplier<List<T>>, Closeable { + + protected final Class<T> type; + + SingletonListDataSupplier(Class<T> type) { + this.type = type; + } + + @Override + public List<T> get() { + T model = fixtures.get(type, 0); + List<T> result = Lists.newArrayList(); + result.add(model); + return result; + } + + @Override + public void close() throws IOException { + } + } + + static class MultiListDataSupplier<T> implements Supplier<List<T>>, Closeable { + + protected final Class<T> type; + + MultiListDataSupplier(Class<T> type) { + this.type = type; + } + + @Override + public List<T> get() { + return fixtures.get(type); + } + + @Override + public void close() throws IOException { + } + } + + public static <T> SingleDataSupplier<T> newSingleData(Class<T> type) { + return new SingleDataSupplier<T>(type); + } + + public static <T> EmptyListDataSupplier<T> newEmptyListData(Class<T> type) { + return new EmptyListDataSupplier<T>(type); + } + + public static <T> SingletonListDataSupplier<T> newSingletonListData(Class<T> type) { + return new SingletonListDataSupplier<T>(type); + } + + public static <T> MultiListDataSupplier<T> newMultiListData(Class<T> type) { + return new MultiListDataSupplier<T>(type); + } + + public static <T> void assertMyListEquals(Class<T> type, List<T> expecteds, T[] actuals) + throws Exception { + + Assert.assertNotNull(actuals); + Assert.assertEquals(expecteds.size(), actuals.length); + for (int i = 0, j = expecteds.size(); i < j; i++) { + T actual = actuals[i]; + T expected = expecteds.get(i); + assertMyEquals(type, expected, actual); + } + + } + + public static void assertMyEquals(Class<?> type, Object expected, Object actual, String... mapperNames) + throws Exception { + + Assert.assertNotNull(expected); + Assert.assertNotNull(actual); + AbstractXpp3Reader<?> reader = (AbstractXpp3Reader<?>) Xpp3Helper.getReader(type); + Map<String, PropertyMapper> mappers = reader.getMappers(type); + List<String> mappersIncludes; + if (mapperNames != null && mapperNames.length > 0) { + mappersIncludes = Lists.newArrayList(mapperNames); + } else { + mappersIncludes = null; + } + for (PropertyMapper m : mappers.values()) { + + if (mappersIncludes == null || mappersIncludes.contains(m.getPropertyName())) { + + Object expectedValue = m.getDescriptor().getReadMethod().invoke(expected); + Object actualValue = m.getDescriptor().getReadMethod().invoke(actual); + + Assert.assertEquals("error in attribute " + m.getPropertyName() + " for " + expected, expectedValue, + actualValue); + } + } + } +} Added: trunk/jredmine-domain/src/test/resources/log4j.properties =================================================================== --- trunk/jredmine-domain/src/test/resources/log4j.properties (rev 0) +++ trunk/jredmine-domain/src/test/resources/log4j.properties 2012-07-12 10:14:14 UTC (rev 259) @@ -0,0 +1,51 @@ +### +# #%L +# JRedmine :: Client +# +# $Id: log4j.properties 186 2011-05-20 12:32:08Z tchemit $ +# $HeadURL: http://svn.nuiton.org/svn/jredmine/trunk/jredmine-client/src/test/resources/... $ +# %% +# Copyright (C) 2009 - 2010 CodeLutin +# %% +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Lesser Public License for more details. +# +# You should have received a copy of the GNU General Lesser Public +# License along with this program. If not, see +# <http://www.gnu.org/licenses/lgpl-3.0.html>. +# #L% +### +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +log4j.rootCategory=WARN, stdout + +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=[%p] (%c{1}:%L) - %m%n + +log4j.logger.org.nuiton.jredmine=INFO +log4j.logger.org.nuiton.io.rest=INFO +#log4j.logger.org.nuiton.io.xpp3.Xpp3Helper=DEBUG +log4j.logger.org.apache.commons.httpclient.HttpClient=INFO
participants (1)
-
tchemit@users.nuiton.org