r292 - in trunk: . jredmine-client-1.x/src/main/assembly jredmine-client-1.x/src/main/java/org/nuiton/jredmine/v1_x jredmine-client-2.x jredmine-client-2.x/src jredmine-client-2.x/src/main jredmine-client-2.x/src/main/java jredmine-client-2.x/src/main/java/org jredmine-client-2.x/src/main/java/org/nuiton jredmine-client-2.x/src/main/java/org/nuiton/jredmine jredmine-client-2.x/src/main/java/org/nuiton/jredmine/v2_x jredmine-client-2.x/src/site jredmine-client-2.x/src/site/apt jredmine-cli
Author: tchemit Date: 2012-07-13 19:44:33 +0200 (Fri, 13 Jul 2012) New Revision: 292 Url: http://nuiton.org/repositories/revision/jredmine/292 Log: add jredmine-cleint 2.x (to be continued\!) Added: trunk/jredmine-client-1.x/src/main/assembly/jredmine_rails-1.x.xml trunk/jredmine-client-2.x/ trunk/jredmine-client-2.x/LICENSE.txt trunk/jredmine-client-2.x/README.txt trunk/jredmine-client-2.x/changelog.txt trunk/jredmine-client-2.x/pom.xml trunk/jredmine-client-2.x/src/ trunk/jredmine-client-2.x/src/license/ trunk/jredmine-client-2.x/src/main/ trunk/jredmine-client-2.x/src/main/java/ trunk/jredmine-client-2.x/src/main/java/org/ trunk/jredmine-client-2.x/src/main/java/org/nuiton/ trunk/jredmine-client-2.x/src/main/java/org/nuiton/jredmine/ trunk/jredmine-client-2.x/src/main/java/org/nuiton/jredmine/v2_x/ trunk/jredmine-client-2.x/src/main/java/org/nuiton/jredmine/v2_x/RedmineAnonymousServiceImpl.java trunk/jredmine-client-2.x/src/main/java/org/nuiton/jredmine/v2_x/RedmineRequestFactoryImpl.java trunk/jredmine-client-2.x/src/main/java/org/nuiton/jredmine/v2_x/RedmineRestClient.java trunk/jredmine-client-2.x/src/main/java/org/nuiton/jredmine/v2_x/RedmineServiceImpl.java trunk/jredmine-client-2.x/src/main/java/org/nuiton/jredmine/v2_x/RedmineServiceImplementorImpl.java trunk/jredmine-client-2.x/src/main/java/org/nuiton/jredmine/v2_x/RedmineServiceProviderImpl.java trunk/jredmine-client-2.x/src/main/resources/ trunk/jredmine-client-2.x/src/site/ trunk/jredmine-client-2.x/src/site/apt/ trunk/jredmine-client-2.x/src/site/apt/index.apt trunk/jredmine-client-2.x/src/site/apt/rails_api.apt trunk/jredmine-client-2.x/src/site/apt/redmine_service.apt trunk/jredmine-client-2.x/src/site/site_fr.xml trunk/jredmine-client-2.x/src/test/ trunk/jredmine-client-2.x/src/test/java/ trunk/jredmine-client-2.x/src/test/java/org/ trunk/jredmine-client-2.x/src/test/java/org/nuiton/ trunk/jredmine-client-2.x/src/test/java/org/nuiton/jredmine/ trunk/jredmine-client-2.x/src/test/java/org/nuiton/jredmine/v2_x/ trunk/jredmine-client-2.x/src/test/java/org/nuiton/jredmine/v2_x/RedmineAnonymousServiceTest.java trunk/jredmine-client-2.x/src/test/java/org/nuiton/jredmine/v2_x/RedmineFixtures.java trunk/jredmine-client-2.x/src/test/java/org/nuiton/jredmine/v2_x/RedmineServer.java trunk/jredmine-client-2.x/src/test/java/org/nuiton/jredmine/v2_x/RedmineServiceAsAnonymousTest.java trunk/jredmine-client-2.x/src/test/java/org/nuiton/jredmine/v2_x/RedmineServiceTest.java trunk/jredmine-client-2.x/src/test/resources/ trunk/jredmine-client-2.x/src/test/resources/log4j.properties trunk/jredmine-client-2.x/src/test/resources/test-config.properties Removed: trunk/jredmine-client-1.x/src/main/assembly/jredmine_rails-1.3.x.xml Modified: trunk/jredmine-client-1.x/src/main/java/org/nuiton/jredmine/v1_x/RedmineServiceProviderImpl.java trunk/jredmine-maven-plugin/pom.xml trunk/pom.xml Deleted: trunk/jredmine-client-1.x/src/main/assembly/jredmine_rails-1.3.x.xml =================================================================== --- trunk/jredmine-client-1.x/src/main/assembly/jredmine_rails-1.3.x.xml 2012-07-13 17:16:17 UTC (rev 291) +++ trunk/jredmine-client-1.x/src/main/assembly/jredmine_rails-1.3.x.xml 2012-07-13 17:44:33 UTC (rev 292) @@ -1,40 +0,0 @@ -<!-- - #%L - JRedmine :: Client - - $Id$ - $HeadURL: http://svn.nuiton.org/svn/jredmine/trunk/jredmine-client/src/main/assembly/j... $ - %% - 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% - --> -<assembly> - <id>jredmine_rails-1.3.x</id> - <formats> - <format>zip</format> - </formats> - <includeBaseDirectory>false</includeBaseDirectory> - <fileSets> - <fileSet> - <directory>src/main/redmine/jredmine</directory> - <outputDirectory>jredmine</outputDirectory> - <includes> - <include>**/*</include> - </includes> - </fileSet> - </fileSets> -</assembly> \ No newline at end of file Copied: trunk/jredmine-client-1.x/src/main/assembly/jredmine_rails-1.x.xml (from rev 290, trunk/jredmine-client-1.x/src/main/assembly/jredmine_rails-1.3.x.xml) =================================================================== --- trunk/jredmine-client-1.x/src/main/assembly/jredmine_rails-1.x.xml (rev 0) +++ trunk/jredmine-client-1.x/src/main/assembly/jredmine_rails-1.x.xml 2012-07-13 17:44:33 UTC (rev 292) @@ -0,0 +1,40 @@ +<!-- + #%L + JRedmine :: Client + + $Id$ + $HeadURL: http://svn.nuiton.org/svn/jredmine/trunk/jredmine-client/src/main/assembly/j... $ + %% + 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% + --> +<assembly> + <id>jredmine_rails-1.3.x</id> + <formats> + <format>zip</format> + </formats> + <includeBaseDirectory>false</includeBaseDirectory> + <fileSets> + <fileSet> + <directory>src/main/redmine/jredmine</directory> + <outputDirectory>jredmine</outputDirectory> + <includes> + <include>**/*</include> + </includes> + </fileSet> + </fileSets> +</assembly> \ No newline at end of file Property changes on: trunk/jredmine-client-1.x/src/main/assembly/jredmine_rails-1.x.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Modified: trunk/jredmine-client-1.x/src/main/java/org/nuiton/jredmine/v1_x/RedmineServiceProviderImpl.java =================================================================== --- trunk/jredmine-client-1.x/src/main/java/org/nuiton/jredmine/v1_x/RedmineServiceProviderImpl.java 2012-07-13 17:16:17 UTC (rev 291) +++ trunk/jredmine-client-1.x/src/main/java/org/nuiton/jredmine/v1_x/RedmineServiceProviderImpl.java 2012-07-13 17:44:33 UTC (rev 292) @@ -39,7 +39,7 @@ @Override public String getRedmineVersion() { - return "1.3.x"; + return "1"; } @Override Property changes on: trunk/jredmine-client-2.x ___________________________________________________________________ Added: svn:ignore + target *.ipr *.iws *.iml .idea .project .classpath .settings Added: trunk/jredmine-client-2.x/LICENSE.txt =================================================================== --- trunk/jredmine-client-2.x/LICENSE.txt (rev 0) +++ trunk/jredmine-client-2.x/LICENSE.txt 2012-07-13 17:44:33 UTC (rev 292) @@ -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-client-2.x/LICENSE.txt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/jredmine-client-2.x/README.txt =================================================================== --- trunk/jredmine-client-2.x/README.txt (rev 0) +++ trunk/jredmine-client-2.x/README.txt 2012-07-13 17:44:33 UTC (rev 292) @@ -0,0 +1,2 @@ +To deploy new version of pom: mvn deploy +To install localy: mvn install Property changes on: trunk/jredmine-client-2.x/README.txt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/jredmine-client-2.x/changelog.txt =================================================================== --- trunk/jredmine-client-2.x/changelog.txt (rev 0) +++ trunk/jredmine-client-2.x/changelog.txt 2012-07-13 17:44:33 UTC (rev 292) @@ -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-client-2.x/changelog.txt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/jredmine-client-2.x/pom.xml =================================================================== --- trunk/jredmine-client-2.x/pom.xml (rev 0) +++ trunk/jredmine-client-2.x/pom.xml 2012-07-13 17:44:33 UTC (rev 292) @@ -0,0 +1,177 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + #%L + JRedmine :: Client 2.x + %% + 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-client-2.x</artifactId> + + <dependencies> + + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>jredmine-client-api</artifactId> + <version>${project.version}</version> + </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.commons</groupId> + <artifactId>commons-lang3</artifactId> + </dependency> + + <dependency> + <groupId>com.google.guava</groupId> + <artifactId>guava</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 2.x</name> + <description>The JRedmine client for redmine 2.x series</description> + + <properties> + <!-- extra files to include in release --> + <redmine.releaseFiles> + ${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> + + </profiles> + +</project> Property changes on: trunk/jredmine-client-2.x/pom.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/jredmine-client-2.x/src/main/java/org/nuiton/jredmine/v2_x/RedmineAnonymousServiceImpl.java =================================================================== --- trunk/jredmine-client-2.x/src/main/java/org/nuiton/jredmine/v2_x/RedmineAnonymousServiceImpl.java (rev 0) +++ trunk/jredmine-client-2.x/src/main/java/org/nuiton/jredmine/v2_x/RedmineAnonymousServiceImpl.java 2012-07-13 17:44:33 UTC (rev 292) @@ -0,0 +1,289 @@ +package org.nuiton.jredmine.v2_x; +/* + * #%L + * JRedmine :: Client 2.x + * $Id$ + * $HeadURL:$ + * %% + * Copyright (C) 2009 - 2012 CodeLutin, Tony Chemit + * %% + * 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% + */ + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.nuiton.io.rest.RestClient; +import org.nuiton.jredmine.RedmineAnonymousService; +import org.nuiton.jredmine.RedmineServiceConfiguration; +import org.nuiton.jredmine.RedmineServiceException; +import org.nuiton.jredmine.RedmineServiceImplementor; +import org.nuiton.jredmine.RedmineServiceLoginException; +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.ModelHelper; +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; + +/** + * Default implementation of {@link RedmineAnonymousService}. + * <p/> + * This implementation just make sure that the rest client is anonnymous. + * <p/> + * Created: 2 janv. 2010 + * + * @author tchemit <chemit@codelutin.com> + * @see RedmineServiceConfiguration#isAnonymous() + * @since 1.0.3 + */ +public class RedmineAnonymousServiceImpl implements RedmineServiceImplementor, RedmineAnonymousService { + + /** Logger. */ + private static final Log log = + LogFactory.getLog(RedmineAnonymousServiceImpl.class); + + protected RedmineServiceImplementor delegateImplementor; + + public RedmineAnonymousServiceImpl() { + delegateImplementor = new RedmineServiceImplementorImpl(); + } + + /////////////////////////////////////////////////////////////////////////// + /// RedmineAnonymousService implementation + /////////////////////////////////////////////////////////////////////////// + + @Override + public IssueStatus[] getIssueStatuses() throws RedmineServiceException { + return getDatas(ModelHelper.GET_ALL_ISSUE_STATUS_REQUEST_NAME, + IssueStatus.class + ); + } + + @Override + public IssuePriority[] getIssuePriorities() throws RedmineServiceException { + return getDatas(ModelHelper.GET_ALL_ISSUE_PRIORITY_REQUEST_NAME, + IssuePriority.class + ); + } + + @Override + public Project[] getProjects() throws RedmineServiceException { + return getDatas(ModelHelper.GET_ALL_PROJECT_REQUEST_NAME, Project.class); + } + + @Override + public IssueCategory[] getIssueCategories(String projectName) throws RedmineServiceException { + return getDatas(ModelHelper.GET_ALL_ISSUE_CATEGORY_REQUEST_NAME, + IssueCategory.class, + projectName + ); + } + + @Override + public Project getProject(String projectName) throws RedmineServiceException { + return getData(ModelHelper.GET_PROJECT_REQUEST_NAME, + Project.class, + projectName + ); + } + + @Override + public Tracker[] getTrackers(String projectName) throws RedmineServiceException { + return getDatas(ModelHelper.GET_ALL_TRACKER_REQUEST_NAME, + Tracker.class, + projectName + ); + } + + @Override + public News[] getNews(String projectName) throws RedmineServiceException { + return getDatas(ModelHelper.GET_ALL_NEWS_REQUEST_NAME, + News.class, + projectName + ); + } + + @Override + public User[] getProjectMembers(String projectName) throws RedmineServiceException { + return getDatas(ModelHelper.GET_ALL_USER_REQUEST_NAME, + User.class, + projectName + ); + } + + @Override + public Version[] getVersions(String projectName) throws RedmineServiceException { + return getDatas(ModelHelper.GET_ALL_VERSION_REQUEST_NAME, + Version.class, + projectName + ); + } + + @Override + public Version getVersion(String projectName, + String versionName) throws RedmineServiceException { + return getData(ModelHelper.GET_VERSION_REQUEST_NAME, + Version.class, + projectName, + versionName + ); + } + + @Override + public Attachment[] getAttachments(String projectName, + String versionName) throws RedmineServiceException { + return getDatas(ModelHelper.GET_ALL_ATTACHMENTS_REQUEST_NAME, + Attachment.class, + projectName, + versionName + ); + } + + @Override + public Issue[] getIssues(String projectName, + String versionName) throws RedmineServiceException { + return getDatas(ModelHelper.GET_ALL_ISSUES_REQUEST_NAME, + Issue.class, + projectName, + versionName + ); + } + + @Override + public TimeEntry[] getIssueTimeEntries(String projectName, + String issueId) throws RedmineServiceException { + return getDatas(ModelHelper.GET_ALL_ISSUE_TIME_ENTRY_REQUEST_NAME, + TimeEntry.class, + projectName, + issueId + ); + } + + @Override + public Issue[] getIssues(String projectName) throws RedmineServiceException { + Issue[] result = getDatas(ModelHelper.GET_ALL_PROJECT_ISSUES_REQUEST_NAME, + Issue.class, + projectName + ); + return result; + } + + @Override + public Issue[] getOpenedIssues(String projectName) throws RedmineServiceException { + Issue[] result = getDatas(ModelHelper.GET_ALL_PROJECT_OPENED_ISSUES_REQUEST_NAME, + Issue.class, + projectName + ); + return result; + } + + @Override + public Issue[] getClosedIssues(String projectName) throws RedmineServiceException { + Issue[] result = getDatas(ModelHelper.GET_ALL_PROJECT_CLOSED_ISSUES_REQUEST_NAME, + Issue.class, + projectName + ); + return result; + } + + /////////////////////////////////////////////////////////////////////////// + /// RedmineServiceImplementor implementation + /////////////////////////////////////////////////////////////////////////// + @Override + public RedmineServiceImplementor init(RedmineServiceConfiguration configuration) throws RedmineServiceException { + // Force to not be loggued + configuration.setAnonymous(true); + if (log.isDebugEnabled()) { + log.debug("init configuration for " + this); + } + return delegateImplementor.init(configuration); + } + + @Override + public RestClient getSession() { + return delegateImplementor.getSession(); + } + + @Override + public int ping() { + return delegateImplementor.ping(); + } + + @Override + public void login() throws RedmineServiceLoginException { + delegateImplementor.login(); + } + + @Override + public void logout() throws RedmineServiceLoginException { + delegateImplementor.logout(); + } + + @Override + public <T> T getData(String requestName, + Class<T> type, + Object... args) throws RedmineServiceException { + return delegateImplementor.getData(requestName, type, args); + } + + @Override + public <T> T[] getDatas(String requestName, + Class<T> type, + Object... args) throws RedmineServiceException { + return delegateImplementor.getDatas(requestName, type, args); + } + + @Override + public <T> T sendData(String requestName, + Class<T> type, + Object... args) throws RedmineServiceException { + return delegateImplementor.sendData(requestName, type, args); + } + + @Override + public <T> T[] sendDatas(String requestName, + Class<T> type, + Object... args) throws RedmineServiceException { + return delegateImplementor.sendDatas(requestName, type, args); + } + + @Override + public boolean isInit() { + return delegateImplementor.isInit(); + } + + @Override + public boolean isLoggued() { + return delegateImplementor.isLoggued(); + } + + @Override + public void destroy() throws RedmineServiceException { + delegateImplementor.destroy(); + } + + @Override + public void checkLoggued() throws IllegalStateException, RedmineServiceLoginException, NullPointerException { + delegateImplementor.checkLoggued(); + } + +} Property changes on: trunk/jredmine-client-2.x/src/main/java/org/nuiton/jredmine/v2_x/RedmineAnonymousServiceImpl.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/jredmine-client-2.x/src/main/java/org/nuiton/jredmine/v2_x/RedmineRequestFactoryImpl.java =================================================================== --- trunk/jredmine-client-2.x/src/main/java/org/nuiton/jredmine/v2_x/RedmineRequestFactoryImpl.java (rev 0) +++ trunk/jredmine-client-2.x/src/main/java/org/nuiton/jredmine/v2_x/RedmineRequestFactoryImpl.java 2012-07-13 17:44:33 UTC (rev 292) @@ -0,0 +1,232 @@ +package org.nuiton.jredmine.v2_x; +/* + * #%L + * JRedmine :: Client 2.x + * $Id$ + * $HeadURL:$ + * %% + * Copyright (C) 2009 - 2012 CodeLutin, Tony Chemit + * %% + * 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% + */ + +import com.google.common.base.Strings; +import org.nuiton.io.rest.AbstractRequestFactory; +import org.nuiton.io.rest.RestMethod; +import org.nuiton.io.rest.RestRequest; +import org.nuiton.jredmine.model.Attachment; +import org.nuiton.jredmine.model.ModelHelper; +import org.nuiton.jredmine.model.News; +import org.nuiton.jredmine.model.TimeEntry; +import org.nuiton.jredmine.model.Version; +import org.nuiton.jredmine.model.VersionStatusEnum; +import org.nuiton.jredmine.request.DefaultRedmineRequestBuilder; +import org.nuiton.jredmine.request.IssueScopeRedmineRequestBuilder; +import org.nuiton.jredmine.request.ProjectScopeRedmineRequestBuilder; +import org.nuiton.jredmine.request.VersionScopeRedmineRequestBuilder; + +import java.io.File; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +/** + * Factory of {@link RestRequest}. + * + * @author tchemit <chemit@codelutin.com> + * @since 1.4 + */ +public class RedmineRequestFactoryImpl extends AbstractRequestFactory { + + @Override + public void addDefaultRequests() { + + // misc requests + + addRequestBuilder(new DefaultRedmineRequestBuilder(ModelHelper.PING_REQUEST_NAME, RestMethod.GET, "projects")); + addRequestBuilder(new DefaultRedmineRequestBuilder(ModelHelper.LOGOUT_REQUEST_NAME, RestMethod.GET, "logout")); + addRequestBuilder(new DefaultRedmineRequestBuilder(ModelHelper.LOGIN_REQUEST_NAME, RestMethod.POST, "login") { + + private static final long serialVersionUID = 1L; + + @Override + public String[] getParameters(Object... args) { + String login = (String) args[0]; + String password = (String) args[1]; + return new String[]{"username", login, "password", password}; + } + }); + + // data with no scope requests + + addRequestBuilder(new DefaultRedmineRequestBuilder(ModelHelper.GET_ALL_PROJECT_REQUEST_NAME, RestMethod.GET, "projects.xml")); + addRequestBuilder(new DefaultRedmineRequestBuilder(ModelHelper.GET_USER_PROJECTS_REQUEST_NAME, RestMethod.GET, "jredmine", "get_user_projects.xml")); + addRequestBuilder(new DefaultRedmineRequestBuilder(ModelHelper.GET_ALL_ISSUE_STATUS_REQUEST_NAME, RestMethod.GET, "jredmine", "get_issue_statuses.xml")); + addRequestBuilder(new DefaultRedmineRequestBuilder(ModelHelper.GET_ALL_ISSUE_PRIORITY_REQUEST_NAME, RestMethod.GET, "jredmine", "get_issue_priorities.xml")); + + // data with project scope requests + + addRequestBuilder(new ProjectScopeRedmineRequestBuilder(ModelHelper.GET_PROJECT_REQUEST_NAME, RestMethod.GET, "projects")); // projectName.xml + addRequestBuilder(new ProjectScopeRedmineRequestBuilder(ModelHelper.GET_ALL_PROJECT_ISSUES_REQUEST_NAME, RestMethod.GET, "issues.xml")); // ?project_id=10&limit=10000 + addRequestBuilder(new ProjectScopeRedmineRequestBuilder(ModelHelper.GET_ALL_PROJECT_OPENED_ISSUES_REQUEST_NAME, RestMethod.GET, "jredmine", "get_project_opened_issues.xml")); //project_id=10&status_id=open&limit=10000 + addRequestBuilder(new ProjectScopeRedmineRequestBuilder(ModelHelper.GET_ALL_PROJECT_CLOSED_ISSUES_REQUEST_NAME, RestMethod.GET, "jredmine", "get_project_closed_issues.xml")); //project_id=10&status_id=closed&limit=10000 + addRequestBuilder(new ProjectScopeRedmineRequestBuilder(ModelHelper.GET_ALL_VERSION_REQUEST_NAME, RestMethod.GET, "projects", "versions.xml")); // projectName + addRequestBuilder(new ProjectScopeRedmineRequestBuilder(ModelHelper.GET_ALL_ISSUE_CATEGORY_REQUEST_NAME, RestMethod.GET, "jredmine", "get_issue_categories.xml")); + addRequestBuilder(new ProjectScopeRedmineRequestBuilder(ModelHelper.GET_ALL_TRACKER_REQUEST_NAME, RestMethod.GET, "jredmine", "get_project_trackers.xml")); + addRequestBuilder(new ProjectScopeRedmineRequestBuilder(ModelHelper.GET_ALL_USER_REQUEST_NAME, RestMethod.GET, "jredmine", "get_project_users.xml")); + addRequestBuilder(new ProjectScopeRedmineRequestBuilder(ModelHelper.GET_ALL_NEWS_REQUEST_NAME, RestMethod.GET, "projects", "news.xml")); // projectName middle + + addRequestBuilder(new ProjectScopeRedmineRequestBuilder(ModelHelper.ADD_VERSION_REQUEST_NAME, RestMethod.POST, "jredmine", "add_version.xml") { + private static final long serialVersionUID = 1L; + + @Override + public String[] getParameters(Object... args) { + Version version = (Version) args[1]; + String date = getVersionEffectiveDate(version); + String status = getVersionStatus(version); + return new String[]{ + "version[name]", version.getName(), + "version[description]", version.getDescription(), + "version[effective_date]", date, + "version[status]", status + }; + } + }); + + addRequestBuilder(new ProjectScopeRedmineRequestBuilder(ModelHelper.UPDATE_VERSION_REQUEST_NAME, RestMethod.POST, "jredmine", "update_version.xml") { + private static final long serialVersionUID = 1L; + + @Override + public String[] getParameters(Object... args) { + Version version = (Version) args[1]; + String date = getVersionEffectiveDate(version); + String status = getVersionStatus(version); + return new String[]{ + "version[name]", version.getName(), + "version[description]", version.getDescription(), + "version[effective_date]", date, + "version[status]", status + }; + } + }); + + addRequestBuilder(new ProjectScopeRedmineRequestBuilder(ModelHelper.NEXT_VERSION_REQUEST_NAME, RestMethod.POST, "jredmine", "next_version.xml") { + private static final long serialVersionUID = 1L; + + @Override + public String[] getParameters(Object... args) { + + + Version version = (Version) args[1]; + String date = getVersionEffectiveDate(version); + String status = getVersionStatus(version); + String oldVersionName = (String) args[2]; + return new String[]{ + "oldVersionName", oldVersionName, + "version[name]", version.getName(), + "version[description]", version.getDescription(), + "version[effective_date]", date, + "version[status]", status + }; + } + }); + + addRequestBuilder(new ProjectScopeRedmineRequestBuilder(ModelHelper.ADD_NEWS_REQUEST_NAME, RestMethod.POST, "jredmine", "add_news.xml") { + private static final long serialVersionUID = 1L; + + @Override + public String[] getParameters(Object... args) { + News news = (News) args[1]; + return new String[]{ + "news[title]", news.getTitle(), + "news[summary]", news.getSummary(), + "news[description]", news.getDescription() + }; + } + }); + + // version scope requests + + addRequestBuilder(new VersionScopeRedmineRequestBuilder(ModelHelper.GET_VERSION_REQUEST_NAME, RestMethod.GET, "versions")); + addRequestBuilder(new VersionScopeRedmineRequestBuilder(ModelHelper.GET_ALL_ISSUES_REQUEST_NAME, RestMethod.GET, "jredmine", "get_version_issues.xml")); + addRequestBuilder(new VersionScopeRedmineRequestBuilder(ModelHelper.GET_ALL_ATTACHMENTS_REQUEST_NAME, RestMethod.GET, "jredmine", "get_version_attachments.xml")); + addRequestBuilder(new VersionScopeRedmineRequestBuilder(ModelHelper.ADD_ATTACHMENT_REQUEST_NAME, RestMethod.POST, "jredmine", "add_version_attachment.xml") { + private static final long serialVersionUID = 1L; + + @Override + public String[] getParameters(Object... args) { + String versionId = (String) args[1]; + Attachment attachment = (Attachment) args[2]; + return new String[]{ + "version_name", versionId, + "attachment[description]", attachment.getDescription() + }; + } + + @Override + public Map<String, File> getAttachments(Object... args) { + Map<String, File> upload = new HashMap<String, File>(); + Attachment attachment = (Attachment) args[2]; + upload.put("attachment[file]", attachment.getToUpload()); + return upload; + } + }); + + // issue scope requests + + addRequestBuilder(new IssueScopeRedmineRequestBuilder(ModelHelper.GET_ALL_ISSUE_TIME_ENTRY_REQUEST_NAME, RestMethod.GET, "jredmine", "get_issue_times.xml")); + + addRequestBuilder(new IssueScopeRedmineRequestBuilder(ModelHelper.ADD_ISSUE_TIME_ENTRY_REQUEST_NAME, RestMethod.POST, "jredmine", "add_issue_time.xml") { + private static final long serialVersionUID = 1L; + + @Override + public String[] getParameters(Object... args) { + String issueId = (String) args[1]; + TimeEntry timeEntry = (TimeEntry) args[2]; + Date d = timeEntry.getSpentOn(); + if (d == null) { + d = new Date(); + } + String date = DATE_FORMAT.format(d); + return new String[]{ + "issue_id", issueId, + //"timeEntry[issue_id]", issueId, + "time_entry[activity_id]", timeEntry.getActivityId() + "", + "time_entry[spent_on]", date, + "time_entry[hours]", timeEntry.getHours() + "", + "time_entry[comments]", timeEntry.getComments() == null ? "" : timeEntry.getComments() + }; + } + }); + } + + protected static String getVersionStatus(Version version) { + String status = version.getStatus(); + if (Strings.isNullOrEmpty(status)) { + + // use default open status + status = VersionStatusEnum.open.name(); + } + return status; + } + + protected static String getVersionEffectiveDate(Version version) { + return version.getEffectiveDate() == null ? "" : + DATE_FORMAT.format(version.getEffectiveDate()); + } + + +} Property changes on: trunk/jredmine-client-2.x/src/main/java/org/nuiton/jredmine/v2_x/RedmineRequestFactoryImpl.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/jredmine-client-2.x/src/main/java/org/nuiton/jredmine/v2_x/RedmineRestClient.java =================================================================== --- trunk/jredmine-client-2.x/src/main/java/org/nuiton/jredmine/v2_x/RedmineRestClient.java (rev 0) +++ trunk/jredmine-client-2.x/src/main/java/org/nuiton/jredmine/v2_x/RedmineRestClient.java 2012-07-13 17:44:33 UTC (rev 292) @@ -0,0 +1,175 @@ +package org.nuiton.jredmine.v2_x; +/* + * #%L + * JRedmine :: Client 2.x + * $Id$ + * $HeadURL:$ + * %% + * Copyright (C) 2009 - 2012 CodeLutin, Tony Chemit + * %% + * 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% + */ + +import org.apache.commons.httpclient.HttpMethod; +import org.apache.commons.httpclient.HttpStatus; +import org.apache.commons.httpclient.StatusLine; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.codehaus.plexus.util.StringUtils; +import org.nuiton.io.rest.RequestFactory; +import org.nuiton.io.rest.RestClient; +import org.nuiton.io.rest.RestRequest; +import org.nuiton.io.rest.RestSession; +import org.nuiton.jredmine.model.ModelHelper; +import org.nuiton.jredmine.model.Version; +import org.nuiton.jredmine.model.VersionStatusEnum; + +import java.io.IOException; +import java.text.DateFormat; +import java.text.SimpleDateFormat; + +/** + * Implementation of a {@link RestClient} to access a Redmine server via the + * {@code redmine_rest} rails plugin. + * + * @author tchemit <chemit@codelutin.com> + * @since 1.0.0 + */ +public class RedmineRestClient extends RestClient { + + private static final Log log = LogFactory.getLog(RedmineRestClient.class); + + /** + * To obtain redmine requests. + * + * @since 1.4 + */ + protected RequestFactory requestFactory; + + public final DateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd"); + + public RedmineRestClient() { + requestFactory = new RedmineRequestFactoryImpl(); + } + + @Override + public RequestFactory getRequestFactory() { + return requestFactory; + } + + @Override + protected void open(RestSession session) throws IOException { + + ping(session); + + if (!configuration.isAnonymous()) { + login(session); + } + } + + @Override + protected void close(RestSession session) throws IOException { + + if (session != null) { + + try { + RestRequest request = getRequest(ModelHelper.LOGOUT_REQUEST_NAME); + session.setOpen(false); + session.doRequest(request); + } finally { + session.close(); + } + } + } + + public int ping(RestSession session) throws IOException { + + try { + + RestRequest request = getRequest(ModelHelper.PING_REQUEST_NAME); + HttpMethod gm = session.doRequest(request); + + StatusLine sl = gm.getStatusLine(); + int statusCode = sl.getStatusCode(); + if (log.isDebugEnabled()) { + log.debug("status code " + statusCode + " for " + gm.getPath()); + } + + if (statusCode != HttpStatus.SC_OK) { + gm.releaseConnection(); + throw new IOException( + "Got error code <" + statusCode + ":" + + sl.getReasonPhrase() + "> on " + gm.getPath()); + } + +// String content = gm.getResponseBodyAsString(); +// +// boolean ok = "ping".equals(content); +// if (!ok) { +// throw new IOException( +// "can not connect to " + configuration.getRestUrl()); +// } + return statusCode; + } catch (IOException ex) { + throw ex; + } catch (Exception ex) { + throw new IOException( + "could not ping " + configuration.getRestUrl() + + " for reason " + ex.getMessage(), ex); + } + } + + public void login(RestSession session) throws IOException { + + RestRequest request = getRequest(ModelHelper.LOGIN_REQUEST_NAME, + configuration.getRestUsername(), + configuration.getRestPassword()); + + HttpMethod gm = session.doRequest(request); + + StatusLine sl = gm.getStatusLine(); + int statusCode = sl.getStatusCode(); + if (log.isDebugEnabled()) { + log.debug("status code " + statusCode + " for " + gm.getPath()); + } + + if (statusCode != HttpStatus.SC_OK && + statusCode != HttpStatus.SC_MOVED_TEMPORARILY) { + gm.releaseConnection(); + throw new IOException( + "Got error code <" + statusCode + ":" + + sl.getReasonPhrase() + "> on " + gm.getPath()); + } + + // ok session is logged in + + } + + protected String getVersionStatus(Version version) { + String status = version.getStatus(); + if (StringUtils.isEmpty(status)) { + + // use default open status + status = VersionStatusEnum.open.name(); + } + return status; + } + + protected String getVersionEffectiveDate(Version version) { + return version.getEffectiveDate() == null ? "" : + DATE_FORMAT.format(version.getEffectiveDate()); + } +} Property changes on: trunk/jredmine-client-2.x/src/main/java/org/nuiton/jredmine/v2_x/RedmineRestClient.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/jredmine-client-2.x/src/main/java/org/nuiton/jredmine/v2_x/RedmineServiceImpl.java =================================================================== --- trunk/jredmine-client-2.x/src/main/java/org/nuiton/jredmine/v2_x/RedmineServiceImpl.java (rev 0) +++ trunk/jredmine-client-2.x/src/main/java/org/nuiton/jredmine/v2_x/RedmineServiceImpl.java 2012-07-13 17:44:33 UTC (rev 292) @@ -0,0 +1,151 @@ +package org.nuiton.jredmine.v2_x; +/* + * #%L + * JRedmine :: Client 2.x + * $Id$ + * $HeadURL:$ + * %% + * Copyright (C) 2009 - 2012 CodeLutin, Tony Chemit + * %% + * 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% + */ + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.nuiton.io.rest.RestClient; +import org.nuiton.jredmine.RedmineService; +import org.nuiton.jredmine.RedmineServiceConfiguration; +import org.nuiton.jredmine.RedmineServiceException; +import org.nuiton.jredmine.RedmineServiceImplementor; +import org.nuiton.jredmine.model.Attachment; +import org.nuiton.jredmine.model.ModelHelper; +import org.nuiton.jredmine.model.News; +import org.nuiton.jredmine.model.Project; +import org.nuiton.jredmine.model.TimeEntry; +import org.nuiton.jredmine.model.Version; + +/** + * Default {@link RedmineService} implementation based on a {@link RestClient} + * + * @author tchemit <chemit@codelutin.com> + * @since 1.0.0 + */ +public class RedmineServiceImpl extends RedmineAnonymousServiceImpl implements RedmineService { + + protected static final Log log = LogFactory.getLog(RedmineServiceImpl.class); + + /////////////////////////////////////////////////////////////////////////// + /// RedmineServiceImplementor implementation + /////////////////////////////////////////////////////////////////////////// + + @Override + public RedmineServiceImplementor init(RedmineServiceConfiguration configuration) throws RedmineServiceException { + return delegateImplementor.init(configuration); + } + + /////////////////////////////////////////////////////////////////////////// + /// RedmineLogguedService implementation + /////////////////////////////////////////////////////////////////////////// + + @Override + public Project[] getUserProjects() throws RedmineServiceException { + checkLoggued(); + Project[] result = getDatas(ModelHelper.GET_USER_PROJECTS_REQUEST_NAME, Project.class); + return result; + } + + @Override + public Version addVersion(String projectName, + Version version) throws RedmineServiceException { + + // send data and obtain created version + Version result = sendData(ModelHelper.ADD_VERSION_REQUEST_NAME, + Version.class, + projectName, + version + ); + return result; + } + + @Override + public Version updateVersion(String projectName, + Version version) throws RedmineServiceException { + + // send data and obtain updated version + Version result = sendData(ModelHelper.UPDATE_VERSION_REQUEST_NAME, + Version.class, + projectName, + version + ); + return result; + } + + @Override + public Version nextVersion(String projectName, + String oldVersionName, + Version newVersion) throws RedmineServiceException { + + // send data and obtain updated or created new version + Version result = sendData(ModelHelper.NEXT_VERSION_REQUEST_NAME, + Version.class, + projectName, + newVersion, + oldVersionName + ); + return result; + } + + @Override + public Attachment addAttachment(String projectName, + String versionName, + Attachment attachement) throws RedmineServiceException { + + // send data and obtain created attachment + Attachment result = sendData(ModelHelper.ADD_ATTACHMENT_REQUEST_NAME, + Attachment.class, + projectName, + versionName, + attachement + ); + return result; + } + + @Override + public News addNews(String projectName, + News news) throws RedmineServiceException { + // send data and obtain created news + News result = sendData(ModelHelper.ADD_NEWS_REQUEST_NAME, + News.class, + projectName, + news + ); + return result; + } + + @Override + public TimeEntry addIssueTimeEntry(String projectName, + String issueId, + TimeEntry entry) throws RedmineServiceException { + // send data and obtain updated version + TimeEntry result = sendData(ModelHelper.ADD_ISSUE_TIME_ENTRY_REQUEST_NAME, + TimeEntry.class, + projectName, + issueId, + entry + ); + return result; + } +} Property changes on: trunk/jredmine-client-2.x/src/main/java/org/nuiton/jredmine/v2_x/RedmineServiceImpl.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/jredmine-client-2.x/src/main/java/org/nuiton/jredmine/v2_x/RedmineServiceImplementorImpl.java =================================================================== --- trunk/jredmine-client-2.x/src/main/java/org/nuiton/jredmine/v2_x/RedmineServiceImplementorImpl.java (rev 0) +++ trunk/jredmine-client-2.x/src/main/java/org/nuiton/jredmine/v2_x/RedmineServiceImplementorImpl.java 2012-07-13 17:44:33 UTC (rev 292) @@ -0,0 +1,317 @@ +package org.nuiton.jredmine.v2_x; +/* + * #%L + * JRedmine :: Client 2.x + * $Id$ + * $HeadURL:$ + * %% + * Copyright (C) 2009 - 2012 CodeLutin, Tony Chemit + * %% + * 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% + */ + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.nuiton.io.rest.RestClient; +import org.nuiton.io.rest.RestException; +import org.nuiton.io.rest.RestRequest; +import org.nuiton.jredmine.RedmineServiceConfiguration; +import org.nuiton.jredmine.RedmineServiceException; +import org.nuiton.jredmine.RedmineServiceImplementor; +import org.nuiton.jredmine.RedmineServiceLoginException; +import org.nuiton.jredmine.model.io.xpp3.DefaultRedmineXpp3Helper; +import org.nuiton.jredmine.model.io.xpp3.RedmineXpp3Helper; + +import java.io.IOException; +import java.io.InputStream; + +/** + * Default Redmine technical service implementation. + * <p/> + * Created: 2 janv. 2010 + * + * @author tchemit <chemit@codelutin.com> + * @see RedmineServiceImplementor + * @since 1.0.3 + */ +public class RedmineServiceImplementorImpl implements RedmineServiceImplementor { + + /** Logger */ + private static final Log log = + LogFactory.getLog(RedmineServiceImplementorImpl.class); + + /** Client Rest. */ + protected final RedmineRestClient session; + + /** xpp3 xpp3Helper to transform xml stream to pojo. */ + protected final RedmineXpp3Helper xpp3Helper; + + /** internal state to known if service was init */ + protected boolean init; + + /** internal state to known if service was opened */ + protected boolean open; + + public RedmineServiceImplementorImpl() { + if (log.isDebugEnabled()) { + log.debug("new " + this); + } + session = new RedmineRestClient(); + xpp3Helper = new DefaultRedmineXpp3Helper(); + } + + /////////////////////////////////////////////////////////////////////////// + /// RedmineServiceImplementor implementation + /////////////////////////////////////////////////////////////////////////// + + + public RedmineRestClient getSession() { + return session; + } + + @Override + public boolean isInit() { + return init; + } + + @Override + public boolean isLoggued() { + return session.isOpen(); + } + + @Override + public RedmineServiceImplementor init(RedmineServiceConfiguration configuration) throws RedmineServiceException { + session.setConfiguration(configuration); + session.requestFactory.addDefaultRequests(); + RedmineServiceImplementor result = init(session); + return result; + } + + public RedmineServiceImplementor init(RedmineRestClient session) throws RedmineServiceException { + if (open) { + throw new IllegalStateException( + "the client " + this + " was already opened!"); + } + try { + + if (!session.isOpen()) { + session.open(); + } + + init = true; + } catch (Exception e) { + throw new RedmineServiceException( + "could not init service for reason " + e.getMessage(), e); + } + return this; + } + + @Override + public int ping() { + + try { + return session.ping(session.getSession()); + } catch (IOException e) { + if (log.isErrorEnabled()) { + log.error("Could not ping ", e); + } + return -1; + } + } + + @Override + public void login() { + } + + @Override + public void logout() { + } + + @Override + public void destroy() throws RedmineServiceException { + checkInit(); + try { + if (session.isOpen()) { + try { + session.close(); + } catch (RestException ex) { + throw new RedmineServiceException( + "has problem while closing Rest client " + + ex.getMessage(), ex); + } + } + } finally { + // can't remove the reference since plexus injects it +// if (session != null) { +// session = null; +// } + init = false; + } + } + + @Override + public <T> T getData(String requestName, + Class<T> type, + Object... args) throws RedmineServiceException { + checkInit(); + InputStream stream = askDataStream(requestName, args); + T result = getDataFromStream(type, stream); + return result; + } + + @Override + public <T> T[] getDatas(String requestName, + Class<T> type, + Object... args) throws RedmineServiceException { + checkInit(); + InputStream stream = askDataStream(requestName, args); + T[] result = getDatasFromStream(type, stream); + return result; + } + + @Override + public <T> T sendData(String requestName, + Class<T> type, + Object... args) throws RedmineServiceException { + checkLoggued(); + InputStream stream = sendDataStream(requestName, args); + T result = getDataFromStream(type, stream); + return result; + } + + @Override + public <T> T[] sendDatas(String requestName, + Class<T> type, + Object... args) throws RedmineServiceException { + checkLoggued(); + InputStream stream = sendDataStream(requestName, args); + T[] result = getDatasFromStream(type, stream); + return result; + } + + @Override + public void checkLoggued() throws IllegalStateException, RedmineServiceLoginException, NullPointerException { + checkInit(); + checkSessionNotNull(session); + checkSessionConfigurationNotNull(session); + if (session.getConfiguration().isAnonymous()) { + throw new RedmineServiceLoginException( + "can not access this service in anonymous mode"); + } + } + + protected InputStream askDataStream(String requestName, + Object... args) throws RedmineServiceException { + + RestRequest r = getRequest(requestName, args); + + // obtain data from rest client + try { + + InputStream stream = session.askData(r); + return stream; + } catch (Exception e) { + throw new RedmineServiceException( + "could not obtain data stream for request " + requestName + + " for reason " + e.getMessage(), e); + } + } + + protected InputStream sendDataStream(String requestName, + Object... args) throws RedmineServiceException { + + RestRequest r = getRequest(requestName, args); + + // obtain data from rest client + try { + + InputStream stream = session.sendData(r); + return stream; + } catch (Exception e) { + throw new RedmineServiceException( + "could not send data stream for request " + requestName + + " for reason " + e.getMessage(), e); + } + } + + protected RestRequest getRequest(String requestName, + Object... args) throws RedmineServiceException { + RestRequest r; + try { + r = session.getRequest(requestName, args); + } catch (Exception e) { + throw new RedmineServiceException( + "could not find the request named " + requestName + + " for reason " + e.getMessage(), e); + } + if (r == null) { + throw new RedmineServiceException( + "could not find the request named " + requestName); + } + return r; + } + + protected <T> T getDataFromStream(Class<T> type, + InputStream stream) throws RedmineServiceException { + if (stream == null) { + return null; + } + + try { + T result = xpp3Helper.readObject(type, stream, true); + return result; + } catch (Exception ex) { + throw new RedmineServiceException( + "could not obtain datas of type " + type + " for reason " + + ex.getMessage(), ex); + } + } + + protected <T> T[] getDatasFromStream(Class<T> type, + InputStream stream) throws RedmineServiceException { + if (stream == null) { + return null; + } + try { + T[] result = xpp3Helper.readObjects(type, stream, true); + return result; + } catch (Exception ex) { + throw new RedmineServiceException( + "could not obtain datas of type " + type + " for reason " + + ex.getMessage(), ex); + } + } + + protected void checkInit() throws IllegalStateException { + if (!init) { + throw new IllegalStateException( + "the client " + this + " is not init!"); + } + } + + protected void checkSessionNotNull(RestClient session) { + if (session == null) { + throw new NullPointerException("session can not be null"); + } + } + + protected void checkSessionConfigurationNotNull(RestClient session) { + if (session.getConfiguration() == null) { + throw new NullPointerException( + "session configuration can not be null"); + } + } +} Property changes on: trunk/jredmine-client-2.x/src/main/java/org/nuiton/jredmine/v2_x/RedmineServiceImplementorImpl.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/jredmine-client-2.x/src/main/java/org/nuiton/jredmine/v2_x/RedmineServiceProviderImpl.java =================================================================== --- trunk/jredmine-client-2.x/src/main/java/org/nuiton/jredmine/v2_x/RedmineServiceProviderImpl.java (rev 0) +++ trunk/jredmine-client-2.x/src/main/java/org/nuiton/jredmine/v2_x/RedmineServiceProviderImpl.java 2012-07-13 17:44:33 UTC (rev 292) @@ -0,0 +1,59 @@ +package org.nuiton.jredmine.v2_x; +/* + * #%L + * JRedmine :: Client 2.x + * $Id$ + * $HeadURL:$ + * %% + * Copyright (C) 2009 - 2012 CodeLutin, Tony Chemit + * %% + * 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% + */ + +import org.nuiton.jredmine.RedmineAnonymousService; +import org.nuiton.jredmine.RedmineService; +import org.nuiton.jredmine.RedmineServiceConfiguration; +import org.nuiton.jredmine.RedmineServiceProvider; + +/** + * Implmentation of {@link RedmineServiceProvider} for this module. + * + * @author tchemit <chemit@codelutin.com> + * @plexus.component role="org.nuiton.jredmine.RedmineServiceProvider" role-hint="1.3.x" + * @since 1.4 + */ +public class RedmineServiceProviderImpl implements RedmineServiceProvider { + + @Override + public String getRedmineVersion() { + return "2"; + } + + @Override + public boolean isRequireJRedminePlugin() { + return false; + } + + @Override + public RedmineService newRedmineService(RedmineServiceConfiguration configuration) { + return new RedmineServiceImpl(); + } + + @Override + public RedmineAnonymousService newRedmineAnonymousService(RedmineServiceConfiguration configuration) { + return new RedmineAnonymousServiceImpl(); + } +} Property changes on: trunk/jredmine-client-2.x/src/main/java/org/nuiton/jredmine/v2_x/RedmineServiceProviderImpl.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/jredmine-client-2.x/src/site/apt/index.apt =================================================================== --- trunk/jredmine-client-2.x/src/site/apt/index.apt (rev 0) +++ trunk/jredmine-client-2.x/src/site/apt/index.apt 2012-07-13 17:44:33 UTC (rev 292) @@ -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-client-2.x/src/site/apt/index.apt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/jredmine-client-2.x/src/site/apt/rails_api.apt =================================================================== --- trunk/jredmine-client-2.x/src/site/apt/rails_api.apt (rev 0) +++ trunk/jredmine-client-2.x/src/site/apt/rails_api.apt 2012-07-13 17:44:33 UTC (rev 292) @@ -0,0 +1,503 @@ +~~~ +~~ #%L +~~ JRedmine :: Client +~~ +~~ $Id$ +~~ $HeadURL: http://svn.nuiton.org/svn/jredmine/trunk/jredmine-client/src/site/apt/rails_... $ +~~ %% +~~ 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% +~~~ +---- +API du plugin rails JRedmine +---- +---- +2009-09-20 +---- + +Introduction + + Ce document décrit l'API du plugin rails. + + + Toutes les actions REST sont préfixés par <<jredmine/>>. + + Par exemple, si votre serveur redmine accessible sur <http://myredmine>, + les appels sur redmine seront de type <http://myredmine/jredmine/XXX>. + + On distingue donc trois types d'API : + + * API de login : pour gérer la connexion au serveur Redmine : une connexion + authentifié est requise pour pouvoir récupérer des données ou effectuer des + actions sur le serveur. + + * API de lecture : pour récupérer des données du serveur. + + * API d'actions : pour effecuter des actions de maintenance sur le serveur. + + Toutes les données en sortie du plugin sont au format <xml>, ou <json>. + +API de login + +*-----------*-----------------------------------------------+ +| <action> | <description> | +*-----------*-----------------------------------------------+ +| <<ping>> | un service de ping qui retourne le mot <ping> | +*-----------*-----------------------------------------------+ +| <<login>> | pour connecter l'utilisateur au serveur | +*-----------*-----------------------------------------------+ +| <<logout>>| pour déconnecter l'utilisateur du serveur | +*-----------*-----------------------------------------------+ + +* ping + + Ce service ne requiert pas de paramètre. + + Requète : + +-------------------------------------------------------------------------------- +jredmine/ping +-------------------------------------------------------------------------------- + +* login + + Ce service nécessite deux paramètres : + + * <<username>> + + * <<password>> + + <<Note:>> Cette requête ne peut être exécutée qu'en <<POST>>. + + Requète : + +-------------------------------------------------------------------------------- +jredmine/login +-------------------------------------------------------------------------------- + +* logout + + Ce service ne requiert pas de paramètre. + + Requète : + +-------------------------------------------------------------------------------- +jredmine/logout +-------------------------------------------------------------------------------- + +API de lecture + + On distingue quatre niveaux de données récupérables : + + * les données qui ne dépendent pas d'un projet + + * les données qui dépendent d'un projet + + * les données qui dépendent d'une version d'un projet + + * les données qui dépendent d'une issued'un projet + +* Services des données indépendantes + +*--------------------------*-----------------------------------+ +| <action[.xml\|.json]> | <données récupérées> | +*--------------------------*-----------------------------------+ +| <<get_projects>> | tous les projets | +*--------------------------*-----------------------------------+ +| <<get_user_projects>> | tous les projets dont l'utilisateur connecté est membre | +*--------------------------*-----------------------------------+ +| <<get_issue_statuses>> | tous les status de demandes | +*--------------------------*-----------------------------------+ +| <<get_issue_priorities>> | toutes les prioritiés de demandes | +*--------------------------*-----------------------------------+ + +** get_projects + + Ce service ne requiert pas de paramètre. + + Requètes : + +-------------------------------------------------------------------------------- +jredmine/get_projects.xml +jredmine/get_projects.json +-------------------------------------------------------------------------------- + +** get_user_projects + + Ce service ne requiert pas de paramètre. + + Requètes : + +-------------------------------------------------------------------------------- +jredmine/get_user_projects.xml +jredmine/get_user_projects.json +-------------------------------------------------------------------------------- + +** get_issue_statuses + + Ce service ne requiert pas de paramètre. + + Requètes : + +-------------------------------------------------------------------------------- +jredmine/get_issue_statuses.xml +jredmine/get_issue_statuses.json +-------------------------------------------------------------------------------- + +** get_issue_priorities + + Ce service ne requiert pas de paramètre. + + Requètes : + +-------------------------------------------------------------------------------- +jredmine/get_issue_priorities.xml +jredmine/get_issue_priorities.json +-------------------------------------------------------------------------------- + +* Services des données dépendantes d'un projet + +*-------------------------------*---------------------------------------+ +| <action[.xml\|.json]> | <données récupérées pour un projet> | +*-------------------------------*---------------------------------------+ +| <<get_projet>> | le projet | +*-------------------------------*---------------------------------------+ +| <<get_issue_categories>> | touts les catégories de demande | +*-------------------------------*---------------------------------------+ +| <<get_project_users>> | tous les membres du projet | +*-------------------------------*---------------------------------------+ +| <<get_project_trackers>> | tous les types de tracker | +*-------------------------------*---------------------------------------+ +| <<get_project_versions>> | toutes les versions d'un projet | +*-------------------------------*---------------------------------------+ +| <<get_project_issues>> | toutes les issues d'un projet | +*-------------------------------*---------------------------------------+ +| <<get_project_opened_issues>> | toutes les issues ouvertes d'un projet| +*-------------------------------*---------------------------------------+ +| <<get_project_closed_issues>> | toutes les issues fermées d'un projet | +*-------------------------------*---------------------------------------+ + +** get_projet + + Ce service ne requiert pas de paramètre. + + Requètes : + +-------------------------------------------------------------------------------- +jredmine/get_projet.xml/myProject +jredmine/get_projet.json/myProject +-------------------------------------------------------------------------------- + +** get_issue_categories + + Ce service ne requiert pas de paramètre. + + Requètes : + +-------------------------------------------------------------------------------- +jredmine/get_issue_categories.xml/myProject +jredmine/get_issue_categories.json/myProject +-------------------------------------------------------------------------------- + +** get_project_users + + Ce service ne requiert pas de paramètre. + + Requètes : + +-------------------------------------------------------------------------------- +jredmine/get_project_users.xml/myProject +jredmine/get_project_users.json/myProject +-------------------------------------------------------------------------------- + +** get_project_trackers + + Ce service ne requiert pas de paramètre. + + Requètes : + +-------------------------------------------------------------------------------- +jredmine/get_project_trackers.xml/myProject +jredmine/get_project_trackers.json/myProject +-------------------------------------------------------------------------------- + +** get_project_versions + + Ce service ne requiert pas de paramètre. + + Requètes : + +-------------------------------------------------------------------------------- +jredmine/get_project_versions.xml/myProject +jredmine/get_project_versions.json/myProject +-------------------------------------------------------------------------------- + +** get_issues + + Ce service ne requiert pas de paramètre. + + Requètes : + +-------------------------------------------------------------------------------- +jredmine/get_project_issues.xml/myProject +jredmine/get_project_issues.json/myProject +-------------------------------------------------------------------------------- + +* Services des données dépendantes d'une version d'un projet + +*------------------------------*-----------------------------------------------------+ +| <action[.xml\|.json]> | <données récupérées pour une version d'un projet> | +*------------------------------*-----------------------------------------------------+ +| <<get_version>> | la version | +*------------------------------*-----------------------------------------------------+ +| <<get_version_issues>> | touts les catégories de demande | +*------------------------------*-----------------------------------------------------+ +| <<get_versions_attachments>> | tous les membres du projet | +*------------------------------*-----------------------------------------------------+ + +** get_version + + Ce service requiert un paramètre : + + * <<version_name>> le nom de la version + + Requètes : + +-------------------------------------------------------------------------------- +jredmine/get_version.xml/myProject?version_name=myVersion +jredmine/get_version.json/myProject?version_name=myVersion +-------------------------------------------------------------------------------- + +** get_version_issues + + Ce service requiert un paramètre : + + * <<version_name>> le nom de la version + + Requètes : + +-------------------------------------------------------------------------------- +jredmine/get_version_issues.xml/myProject?version_name=myVersion +jredmine/get_version_issues.json/myProject?version_name=myVersion +-------------------------------------------------------------------------------- + +** get_versions_attachments + + Ce service requiert un paramètre : + + * <<version_name>> le nom de la version + + Requètes : + +-------------------------------------------------------------------------------- +jredmine/get_versions_attachments.xml/myProject?version_name=myVersion +jredmine/get_versions_attachments.json/myProject?version_name=myVersion +-------------------------------------------------------------------------------- + +* Services des données dépendantes d'une issue d'un projet + +*--------------------------*---------------------------------------------------+ +| <action[.xml\|.json]> | <données récupérées pour une issue d'un projet> | +*--------------------------*---------------------------------------------------+ +| <<get_issue_times>> | les temps de l'issue | +*--------------------------*---------------------------------------------------+ + +** get_issue_times + + Ce service requiert un paramètre : + + * <<issue_id>> l'id de l'issue + + Requètes : + +-------------------------------------------------------------------------------- +jredmine/get_issue_time.xml/myProject?issue_id=myIssueId +jredmine/get_issue_time.json/myProject?issue_id=myIssueId +-------------------------------------------------------------------------------- + +API d'actions + +*----------------------------*-----------------------------------------------+ +| <action> | <description> | +*----------------------------*-----------------------------------------------+ +| <<add_version>> | ajouter une version à un projet | +*----------------------------*-----------------------------------------------+ +| <<update_version>> | mettre à jour une version d'un projet | +*----------------------------*-----------------------------------------------+ +| <<next_version>> | préparer la prochaine version d'un projet | +*----------------------------*-----------------------------------------------+ +| <<add_attachment>> | ajouter un fichier à un projet | +*----------------------------*-----------------------------------------------+ +| <<add_version_attachment>> | ajouter un fichier à une version d'un projet | +*----------------------------*-----------------------------------------------+ +| <<add_news>> | ajouter une annonce à un projet | +*----------------------------*-----------------------------------------------+ +| <<add_issue_time>> | ajouter un temps à une issue d'un projet | +*----------------------------*-----------------------------------------------+ +| <<update_issue_time>> | mettre à jour le temps d'une issue d'un projet| +*----------------------------*-----------------------------------------------+ + + <<Note:>> Toutes ces opérations doivent obligatoirement être exécutées + par une méthod http <<POST>> (donc pas réalisable via un navigateur). + +* add_version + + Ce service requiert trois paramètres : + + * <<version[name]>> le nom de la version + + * <<version[description]>> la description de la version + + * <<version[effective_date]>> la date effective de la version + + Requètes : + +-------------------------------------------------------------------------------- +jredmine/add_version.xml/myProject +jredmine/add_version.json/myProject +-------------------------------------------------------------------------------- + +* update_version + + Ce service requiert trois paramètres : + + * <<version[name]>> le nom de la version + + * <<version[description]>> la description de la version + + * <<version[effective_date]>> la date effective de la version + + Requètes : + +-------------------------------------------------------------------------------- +jredmine/update_version.xml/myProject +jredmine/update_version.json/myProject +-------------------------------------------------------------------------------- + +* next_version + + Ce service requiert quatre paramètres : + + * <<previousVersionName>> le nom de la version précédente + + * <<version[name]>> le nom de la version + + * <<version[description]>> la description de la version + + * <<version[effective_date]>> la date effective de la version + + Requètes : + +-------------------------------------------------------------------------------- +jredmine/next_version.xml/myProject +jredmine/next_version.json/myProject +-------------------------------------------------------------------------------- + +* add_attachment + + Ce service requiert deux paramètres : + + * <<attachment[description]>> la description de la pièce jointe + + * <<attachment[file]>> la pièce-jointe + + <<Note:>> La requète est de type <<multi-part>>. + + Requètes : + +-------------------------------------------------------------------------------- +jredmine/add_attachment.xml/myProject +jredmine/add_attachment.json/myProject +-------------------------------------------------------------------------------- + +* add_version_attachment + + Ce service requiert trois paramètres : + + * <<version_name>> le nom de la version + + * <<attachment[description]>> la description de la pièce jointe + + * <<attachment[file]>> la pièce-jointe + + <<Note:>> La requète est de type <<multi-part>>. + + Requètes : + +-------------------------------------------------------------------------------- +jredmine/add_version_attachment.xml/myProject +jredmine/add_version_attachment.json/myProject +-------------------------------------------------------------------------------- + +* add_news + + Ce service requiert trois paramètres : + + * <<news[title]>> le titre de de la version + + * <<news[summary]>> la description de l'annonce + + * <<news[description]>> le contenu de l'annonce + + Requètes : + +-------------------------------------------------------------------------------- +jredmine/add_news.xml/myProject +jredmine/add_news.json/myProject +-------------------------------------------------------------------------------- + +** add_issue_time + + Ce service requiert cinq paramètres : + + * <<issue_id>> l'id de l'issue + + * <<time_entry[activity_id]>> l'id de l'activité du temps à ajouter + + * <<time_entry[hours]>> le nombre d'heures du temps à ajouter + + * <<time_entry[spent_on]>> la date du temps à ajouter (si null, on prend la date du jour) + + * <<time_entry[comments]>> commentaire du temps à ajouter + + Requètes : + +-------------------------------------------------------------------------------- +jredmine/add_issue_time.xml/myProject +jredmine/add_issue_time.json/myProject +-------------------------------------------------------------------------------- + +** update_issue_time + + Ce service requiert cinq paramètres : + + * <<issue_id>> l'id de l'issue + + * <<time_entry[activity_id]>> l'id de l'activité du temps à mettre à jour + + * <<time_entry[hours]>> le nombre d'heures du temps à mettre à jour + + * <<time_entry[spent_on]>> la date du temps à mettre à jour (si null, on prend la date du jour) + + * <<time_entry[comments]>> commentaire du temps à mettre à jour + + Requètes : + +-------------------------------------------------------------------------------- +jredmine/update_issue_time.xml/myProject +jredmine/update_issue_time.json/myProject +-------------------------------------------------------------------------------- Property changes on: trunk/jredmine-client-2.x/src/site/apt/rails_api.apt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/jredmine-client-2.x/src/site/apt/redmine_service.apt =================================================================== --- trunk/jredmine-client-2.x/src/site/apt/redmine_service.apt (rev 0) +++ trunk/jredmine-client-2.x/src/site/apt/redmine_service.apt 2012-07-13 17:44:33 UTC (rev 292) @@ -0,0 +1,71 @@ +~~~ +~~ #%L +~~ JRedmine :: Client +~~ +~~ $Id$ +~~ $HeadURL: http://svn.nuiton.org/svn/jredmine/trunk/jredmine-client/src/site/apt/redmin... $ +~~ %% +~~ 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% +~~~ +---- +RedmineService +---- +---- +2009-09-15 +---- + +Les contrats de service + + L'api java sépare depuis la version 1.0.3 les services publiques et privés. + +* org.nuiton.jredmine.RedmineAnonymousService + + Ce contrat permet d'exécuter les services publiques (services anonymes). + +* org.nuiton.jredmine.RedmineLogguedService + + Ce contrat permet d'exécuter les services privés (services avec login). + +* org.nuiton.jredmine.RedmineService + + Ce contrat regroupe les deux précédents et constitue l'ensemble des services + connus par redmine. + + +Les implentations de service + + L'api offre deux implentations de service. + +* org.nuiton.jredmine.DefaultRedmineAnonymousService + + Ce service peut-être appelé pour tout opération publique, la session + sous-jacente au service (RedmineRestClient) n'établiera pas d'authentification + vers les serveur redmine. + +* org.nuiton.jredmine.DefaultRedmineService + + Ce service peut-être appelé pour toute opération vers le serveur redmine. + + Si la configuration requièrt un login (propriété anonymous à false), une + authentification sera effectuée. + + A noter que si on utilise ce service en anonyme et que l'on tente d'appeler + une méthode de service privé, une exception sera remontée indiquant qu'il faut + être authentifié pour effectuer cette opération. + + <Pour plus de détails, consulter la javadoc du module.> Property changes on: trunk/jredmine-client-2.x/src/site/apt/redmine_service.apt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/jredmine-client-2.x/src/site/site_fr.xml =================================================================== --- trunk/jredmine-client-2.x/src/site/site_fr.xml (rev 0) +++ trunk/jredmine-client-2.x/src/site/site_fr.xml 2012-07-13 17:44:33 UTC (rev 292) @@ -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-client-2.x/src/site/site_fr.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/jredmine-client-2.x/src/test/java/org/nuiton/jredmine/v2_x/RedmineAnonymousServiceTest.java =================================================================== --- trunk/jredmine-client-2.x/src/test/java/org/nuiton/jredmine/v2_x/RedmineAnonymousServiceTest.java (rev 0) +++ trunk/jredmine-client-2.x/src/test/java/org/nuiton/jredmine/v2_x/RedmineAnonymousServiceTest.java 2012-07-13 17:44:33 UTC (rev 292) @@ -0,0 +1,188 @@ +package org.nuiton.jredmine.v2_x; +/* + * #%L + * JRedmine :: Client 2.x + * $Id$ + * $HeadURL:$ + * %% + * Copyright (C) 2009 - 2012 CodeLutin, Tony Chemit + * %% + * 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% + */ + +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Rule; +import org.junit.Test; +import org.nuiton.jredmine.RedmineAnonymousService; +import org.nuiton.jredmine.RedmineServiceConfiguration; +import org.nuiton.jredmine.RedmineServiceException; +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.io.IOException; + +/** + * Tests the {@link RedmineAnonymousServiceImpl}. + * + * @author tchemit <chemit@codelutin.com> + * @since 1.5 + */ +@Ignore +public class RedmineAnonymousServiceTest { + + protected static final RedmineFixtures fixtures = new RedmineFixtures(); + + @Rule + public final RedmineServer<RedmineAnonymousService> server = createNewServer(fixtures); + + protected RedmineAnonymousService getService() { + return server.getService(); + } + + protected RedmineServer<RedmineAnonymousService> createNewServer(RedmineFixtures fixtures) { + return new RedmineServer<RedmineAnonymousService>(fixtures) { + + @Override + protected RedmineAnonymousService createService( + RedmineFixtures fixture, + RedmineServiceConfiguration configuration) throws IOException, RedmineServiceException { + + return fixture.newRedmineAnonymousService(configuration); + } + + @Override + protected RedmineServiceConfiguration createConfiguration(RedmineFixtures fixture) throws IOException { + RedmineServiceConfiguration conf = fixture.newAnonymousConfiguration(); + return conf; + } + }; + } + + @BeforeClass + public static void beforeClass() { + RedmineServer<RedmineAnonymousService> newServer = + new RedmineAnonymousServiceTest().createNewServer(fixtures); + newServer.checkService(); + } + + @Test + public void getProjects() throws Exception { + Project[] projects = getService().getProjects(); + Assert.assertNotNull(projects); + } + + @Test + public void getIssuePriorities() throws Exception { + IssuePriority[] issuePriorities = getService().getIssuePriorities(); + Assert.assertNotNull(issuePriorities); + } + + @Test + public void getIssueStatuses() throws Exception { + IssueStatus[] issueStatuses = getService().getIssueStatuses(); + Assert.assertNotNull(issueStatuses); + } + + @Test + public void getProject() throws Exception { + Project project = getService().getProject(fixtures.projectName()); + Assert.assertNotNull(project); + } + + @Test + public void getIssueCategories() throws Exception { + IssueCategory[] issueCategories = getService().getIssueCategories(fixtures.projectName()); + Assert.assertNotNull(issueCategories); + } + + @Test + public void getTrackers() throws Exception { + Tracker[] trackers = getService().getTrackers(fixtures.projectName()); + Assert.assertNotNull(trackers); + } + + @Test + public void getNews() throws Exception { + News[] news = getService().getNews(fixtures.projectName()); + Assert.assertNotNull(news); + } + + @Test + public void getProjectMembers() throws Exception { + User[] users = getService().getProjectMembers(fixtures.projectName()); + Assert.assertNotNull(users); + } + + @Test + public void getProjectIssues() throws Exception { + Issue[] issues = getService().getIssues(fixtures.projectName()); + Assert.assertNotNull(issues); + } + + @Test + public void getVersions() throws Exception { + Version[] versions = getService().getVersions(fixtures.projectName()); + Assert.assertNotNull(versions); + } + + @Test + public void getVersion() throws Exception { + Version version = getService().getVersion(fixtures.projectName(), fixtures.versionName()); + Assert.assertNotNull(version); + } + + @Test + public void getVersionIssues() throws Exception { + Issue[] issues = getService().getIssues(fixtures.projectName(), fixtures.versionName()); + Assert.assertNotNull(issues); + } + + @Test + public void getOpenedIssues() throws Exception { + Issue[] issues = getService().getOpenedIssues(fixtures.projectName()); + Assert.assertNotNull(issues); + } + + @Test + public void getClosedIssues() throws Exception { + Issue[] issues = getService().getClosedIssues(fixtures.projectName()); + Assert.assertNotNull(issues); + } + + @Test + public void getIssueTimeEntries() throws Exception { + TimeEntry[] timeEntries = getService().getIssueTimeEntries(fixtures.projectName(), fixtures.issueId()); + Assert.assertNotNull(timeEntries); + } + + @Test + public void getAttachments() throws Exception { + Attachment[] attachments = getService().getAttachments(fixtures.projectName(), fixtures.versionName()); + Assert.assertNotNull(attachments); + } + +} Property changes on: trunk/jredmine-client-2.x/src/test/java/org/nuiton/jredmine/v2_x/RedmineAnonymousServiceTest.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/jredmine-client-2.x/src/test/java/org/nuiton/jredmine/v2_x/RedmineFixtures.java =================================================================== --- trunk/jredmine-client-2.x/src/test/java/org/nuiton/jredmine/v2_x/RedmineFixtures.java (rev 0) +++ trunk/jredmine-client-2.x/src/test/java/org/nuiton/jredmine/v2_x/RedmineFixtures.java 2012-07-13 17:44:33 UTC (rev 292) @@ -0,0 +1,821 @@ +package org.nuiton.jredmine.v2_x; +/* + * #%L + * JRedmine :: Client 2.x + * $Id$ + * $HeadURL:$ + * %% + * Copyright (C) 2009 - 2012 CodeLutin, Tony Chemit + * %% + * 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% + */ + +import com.google.common.base.Charsets; +import com.google.common.collect.ArrayListMultimap; +import org.apache.commons.io.FileUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.nuiton.jredmine.RedmineAnonymousService; +import org.nuiton.jredmine.RedmineService; +import org.nuiton.jredmine.RedmineServiceConfiguration; +import org.nuiton.jredmine.RedmineServiceException; +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.io.InputStream; +import java.net.URL; +import java.util.Date; +import java.util.List; +import java.util.Properties; + +/** + * 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; + + private RedmineServiceConfiguration anonymousConfiguration; + + private RedmineServiceConfiguration logguedConfiguration; + + public String projectName() { + return PROJECT_NAME; + } + + public String versionName() { + return VERSION_NAME; + } + + public String issueId() { + return ISSUE_ID; + } + + public RedmineServiceConfiguration newAnonymousConfiguration() + throws IOException { + RedmineServiceConfiguration conf = new FakeRedmineServiceConfiguration(); + copyConfiguration(getAnonymousConfiguration(), conf); + return conf; + } + + public RedmineServiceConfiguration newLogguedConfiguration() + throws IOException { + RedmineServiceConfiguration conf = new FakeRedmineServiceConfiguration(); + copyConfiguration(getLogguedConfiguration(), conf); + return conf; + } + + public RedmineAnonymousService newRedmineAnonymousService(RedmineServiceConfiguration configuration) + throws IOException, RedmineServiceException { + RedmineAnonymousServiceImpl service = new RedmineAnonymousServiceImpl(); + service.init(configuration); + return service; + } + + public RedmineService newRedmineService(RedmineServiceConfiguration configuration) + throws IOException, RedmineServiceException { + RedmineServiceImpl service = new RedmineServiceImpl(); + service.init(configuration); + return service; + } + + protected RedmineServiceConfiguration getAnonymousConfiguration() + throws IOException { + if (anonymousConfiguration == null) { + + Properties props = new Properties(); + + InputStream inputStream = null; + try { + String jredmineConfiguration = System.getenv("jredmine-test.properties"); + if (jredmineConfiguration == null) { + if (log.isWarnEnabled()) { + log.warn("Could not find environement variable " + + "'jredmine-test.properties' will use " + + "default test configuration"); + } + + inputStream = getClass().getResourceAsStream("/test-config.properties"); + } else { + + File file = new File(jredmineConfiguration); + + if (!file.exists()) { + throw new IllegalStateException("Could not find " + jredmineConfiguration + + " file"); + } + inputStream = FileUtils.openInputStream(file); + } + props.load(inputStream); + } finally { + if (inputStream != null) { + inputStream.close(); + } + } + anonymousConfiguration = new FakeRedmineServiceConfiguration(); + + String url = props.getProperty("test.redmineUrl"); + anonymousConfiguration.setRestUrl(new URL(url)); + + String e = props.getProperty("test.encoding"); + anonymousConfiguration.setEncoding(e); + + String verbose = props.getProperty("test.verbose"); + if (StringUtils.isNotEmpty(verbose)) { + anonymousConfiguration.setVerbose(Boolean.valueOf(verbose)); + } + anonymousConfiguration.setEncoding(Charsets.UTF_8.name()); + anonymousConfiguration.setAnonymous(true); + + verbose = System.getenv("jredmine-test.verbose"); + if (StringUtils.isNotEmpty(verbose)) { + anonymousConfiguration.setVerbose(Boolean.valueOf(verbose)); + } + + } + return anonymousConfiguration; + } + + protected RedmineServiceConfiguration getLogguedConfiguration() + throws IOException { + if (logguedConfiguration == null) { + + // use anonymous configuration + + RedmineServiceConfiguration anoConf = getAnonymousConfiguration(); + if (anoConf != null) { + logguedConfiguration = new FakeRedmineServiceConfiguration(); + copyConfiguration(anoConf, logguedConfiguration); + + // get system login password from env + String login = System.getenv("jredmine-test.login"); + String password = System.getenv("jredmine-test.password"); + if (!"null".equals(login)) { + logguedConfiguration.setRestUsername(login); + } + if (!"null".equals(password)) { + logguedConfiguration.setRestPassword(password); + } + logguedConfiguration.setAnonymous(false); + } + } + return logguedConfiguration; + } + + protected void copyConfiguration(RedmineServiceConfiguration src, + RedmineServiceConfiguration dst) { + dst.setRestUrl(src.getRestUrl()); + dst.setRestUsername(src.getRestUsername()); + dst.setRestPassword(src.getRestPassword()); + dst.setEncoding(src.getEncoding()); + dst.setVerbose(src.isVerbose()); + dst.setAnonymous(src.isAnonymous()); + } + + 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 modifiée"); + 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); + } + + } + + /** + * Configuration of a redmine service for test purposes. + * + * @author tchemit <chemit@codelutin.com> + * @since 1.4 + */ + public static class FakeRedmineServiceConfiguration implements RedmineServiceConfiguration { + + URL restUrl; + + String restUsername; + + String restPassword; + + boolean verbose; + + boolean anonymous; + + String encoding; + + @Override + public String getEncoding() { + return encoding; + } + + @Override + public void setEncoding(String encoding) { + this.encoding = encoding; + } + + @Override + public String getRestPassword() { + return restPassword; + } + + @Override + public void setRestPassword(String restPassword) { + this.restPassword = restPassword; + } + + @Override + public URL getRestUrl() { + return restUrl; + } + + @Override + public void setRestUrl(URL restUrl) { + this.restUrl = restUrl; + } + + @Override + public String getRestUsername() { + return restUsername; + } + + @Override + public void setRestUsername(String restUsername) { + this.restUsername = restUsername; + } + + @Override + public boolean isVerbose() { + return verbose; + } + + @Override + public void setVerbose(boolean verbose) { + this.verbose = verbose; + } + + @Override + public boolean isAnonymous() { + return anonymous; + } + + @Override + public void setAnonymous(boolean anonymous) { + this.anonymous = anonymous; + } + + @Override + public String toString() { + ToStringBuilder b = new ToStringBuilder(this, + ToStringStyle.MULTI_LINE_STYLE + ); + b.append("redmineUrl", restUrl); + if (anonymous) { + b.append("anonymous", true); + } else { + b.append("redmineUsername", restUsername); + b.append("redminePassword", "***"); + } + b.append("encoding", encoding); + b.append("verbose", verbose); + return b.toString(); + } + } +} Property changes on: trunk/jredmine-client-2.x/src/test/java/org/nuiton/jredmine/v2_x/RedmineFixtures.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/jredmine-client-2.x/src/test/java/org/nuiton/jredmine/v2_x/RedmineServer.java =================================================================== --- trunk/jredmine-client-2.x/src/test/java/org/nuiton/jredmine/v2_x/RedmineServer.java (rev 0) +++ trunk/jredmine-client-2.x/src/test/java/org/nuiton/jredmine/v2_x/RedmineServer.java 2012-07-13 17:44:33 UTC (rev 292) @@ -0,0 +1,206 @@ +package org.nuiton.jredmine.v2_x; +/* + * #%L + * JRedmine :: Client 2.x + * $Id$ + * $HeadURL:$ + * %% + * Copyright (C) 2009 - 2012 CodeLutin, Tony Chemit + * %% + * 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% + */ + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.codehaus.plexus.util.StringUtils; +import org.junit.Assume; +import org.junit.rules.TestWatcher; +import org.junit.runner.Description; +import org.nuiton.jredmine.RedmineServiceConfiguration; +import org.nuiton.jredmine.RedmineServiceException; +import org.nuiton.jredmine.RedmineServiceImplementor; + +import java.io.IOException; + +/** + * A redmine server usable by tests. + * + * @author tchemit <chemit@codelutin.com> + * @since 1.4 + */ +public abstract class RedmineServer<S> extends TestWatcher { + + /** Logger. */ + private static final Log log = LogFactory.getLog(RedmineServer.class); + + /** + * Fixtures. + * + * @since 1.4 + */ + protected final RedmineFixtures fixtures; + + /** + * Service configuration to use. + * + * @since 1.4 + */ + protected RedmineServiceConfiguration configuration; + + /** + * Current service. + * + * @since 1.4 + */ + protected S service; + + public RedmineServer(RedmineFixtures fixtures) { + this.fixtures = fixtures; + } + + protected abstract S createService(RedmineFixtures fixtures, + RedmineServiceConfiguration configuration) throws IOException, RedmineServiceException; + + protected abstract RedmineServiceConfiguration createConfiguration(RedmineFixtures fixtures) throws IOException; + + public RedmineFixtures getFixtures() { + return fixtures; + } + + public RedmineServiceConfiguration getConfiguration() { + return configuration; + } + + public S getService() { + return service; + } + + @Override + protected void starting(Description description) { + + try { + configuration = createConfiguration(fixtures); + } catch (IOException e) { + + throw new IllegalStateException("Could not create configuration", e); + } + + try { + service = createService(fixtures, configuration); + } catch (Exception e) { + throw new IllegalStateException("Could not create service", e); + } + } + + @Override + protected void finished(Description description) { + + if (service != null) { + try { + ((RedmineServiceImplementor) service).destroy(); + } catch (RedmineServiceException e) { + throw new IllegalStateException("Could not close service ", e); + } + } + } + + protected void checkService() { + + if (log.isInfoEnabled()) { + log.info("Will check service..."); + } + + try { + + try { + configuration = createConfiguration(fixtures); + } catch (IOException e) { + + throw new IllegalStateException("Could not create configuration", e); + } + + boolean anonymous = configuration.isAnonymous(); + try { + configuration.setAnonymous(true); + service = createService(fixtures, configuration); + } catch (Exception e) { + + // could not init service + if (log.isInfoEnabled()) { + log.info("Will skip test " + + RedmineServiceTest.class.getName() + + ", since could not init service", e); + } + Assume.assumeTrue(false); + return; + + } finally { + + //push back initial flag value + configuration.setAnonymous(anonymous); + } + + if (!anonymous) { + + if (StringUtils.isBlank(configuration.getRestUsername())) { + if (log.isInfoEnabled()) { + log.info("Will skip test " + + RedmineServiceTest.class.getName() + + ", since not username was given and loggued service is required"); + } + Assume.assumeTrue(false); + return; + } + + + if (StringUtils.isBlank(configuration.getRestPassword())) { + if (log.isInfoEnabled()) { + log.info("Will skip test " + + RedmineServiceTest.class.getName() + + ", since not password was given and loggued service is required"); + } + Assume.assumeTrue(false); + return; + } + + // recheck service (to test now login) + try { + service = createService(fixtures, configuration); + } catch (Exception e) { + // ping was not ok + if (log.isInfoEnabled()) { + log.info("Will skip test " + + RedmineServiceTest.class.getName() + + ", since login [" + configuration.getRestUsername() + "] was bad : " + e.getMessage(), e); + } + + Assume.assumeTrue(false); + } + } + } finally { + if (log.isInfoEnabled()) { + log.info("Service checked..."); + } + if (service != null) { + try { + ((RedmineServiceImplementor) service).destroy(); + } catch (RedmineServiceException e) { + throw new IllegalStateException("Could not close service", e); + } + } + } + } +} Property changes on: trunk/jredmine-client-2.x/src/test/java/org/nuiton/jredmine/v2_x/RedmineServer.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/jredmine-client-2.x/src/test/java/org/nuiton/jredmine/v2_x/RedmineServiceAsAnonymousTest.java =================================================================== --- trunk/jredmine-client-2.x/src/test/java/org/nuiton/jredmine/v2_x/RedmineServiceAsAnonymousTest.java (rev 0) +++ trunk/jredmine-client-2.x/src/test/java/org/nuiton/jredmine/v2_x/RedmineServiceAsAnonymousTest.java 2012-07-13 17:44:33 UTC (rev 292) @@ -0,0 +1,225 @@ +package org.nuiton.jredmine.v2_x; +/* + * #%L + * JRedmine :: Client 2.x + * $Id$ + * $HeadURL:$ + * %% + * Copyright (C) 2009 - 2012 CodeLutin, Tony Chemit + * %% + * 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% + */ + +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Rule; +import org.junit.Test; +import org.nuiton.jredmine.RedmineService; +import org.nuiton.jredmine.RedmineServiceConfiguration; +import org.nuiton.jredmine.RedmineServiceException; +import org.nuiton.jredmine.RedmineServiceLoginException; +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.io.IOException; + +/** + * Tests the {@link RedmineAnonymousServiceImpl}. + * + * @author tchemit <chemit@codelutin.com> + * @since 1.5 + */ +@Ignore +public class RedmineServiceAsAnonymousTest { + + protected static final RedmineFixtures fixtures = new RedmineFixtures(); + + @Rule + public final RedmineServer<RedmineService> server = createNewServer(fixtures); + + protected RedmineService getService() { + return server.getService(); + } + + protected RedmineServer<RedmineService> createNewServer(RedmineFixtures fixtures) { + return new RedmineServer<RedmineService>(fixtures) { + + @Override + protected RedmineService createService( + RedmineFixtures fixture, + RedmineServiceConfiguration configuration) throws IOException, RedmineServiceException { + + return fixture.newRedmineService(configuration); + } + + @Override + protected RedmineServiceConfiguration createConfiguration(RedmineFixtures fixture) throws IOException { + RedmineServiceConfiguration conf = fixture.newAnonymousConfiguration(); + return conf; + } + }; + } + + + @BeforeClass + public static void beforeClass() { + RedmineServer<RedmineService> newServer = + new RedmineServiceAsAnonymousTest().createNewServer(fixtures); + newServer.checkService(); + } + + @Test + public void getProjects() throws Exception { + Project[] projects = getService().getProjects(); + Assert.assertNotNull(projects); + } + + @Test + public void getIssuePriorities() throws Exception { + IssuePriority[] issuePriorities = getService().getIssuePriorities(); + Assert.assertNotNull(issuePriorities); + } + + @Test + public void getIssueStatuses() throws Exception { + IssueStatus[] issueStatuses = getService().getIssueStatuses(); + Assert.assertNotNull(issueStatuses); + } + + @Test + public void getProject() throws Exception { + Project project = getService().getProject(fixtures.projectName()); + Assert.assertNotNull(project); + } + + @Test + public void getIssueCategories() throws Exception { + IssueCategory[] issueCategories = getService().getIssueCategories(fixtures.projectName()); + Assert.assertNotNull(issueCategories); + } + + @Test + public void getTrackers() throws Exception { + Tracker[] trackers = getService().getTrackers(fixtures.projectName()); + Assert.assertNotNull(trackers); + } + + @Test + public void getNews() throws Exception { + News[] news = getService().getNews(fixtures.projectName()); + Assert.assertNotNull(news); + } + + @Test + public void getProjectMembers() throws Exception { + User[] users = getService().getProjectMembers(fixtures.projectName()); + Assert.assertNotNull(users); + } + + @Test + public void getProjectIssues() throws Exception { + Issue[] issues = getService().getIssues(fixtures.projectName()); + Assert.assertNotNull(issues); + } + + @Test + public void getVersions() throws Exception { + Version[] versions = getService().getVersions(fixtures.projectName()); + Assert.assertNotNull(versions); + } + + @Test + public void getVersion() throws Exception { + Version version = getService().getVersion(fixtures.projectName(), fixtures.versionName()); + Assert.assertNotNull(version); + } + + @Test + public void getVersionIssues() throws Exception { + Issue[] issues = getService().getIssues(fixtures.projectName(), fixtures.versionName()); + Assert.assertNotNull(issues); + } + + @Test + public void getOpenedIssues() throws Exception { + Issue[] issues = getService().getOpenedIssues(fixtures.projectName()); + Assert.assertNotNull(issues); + } + + @Test + public void getClosedIssues() throws Exception { + Issue[] issues = getService().getClosedIssues(fixtures.projectName()); + Assert.assertNotNull(issues); + } + + @Test + public void getIssueTimeEntries() throws Exception { + TimeEntry[] timeEntries = getService().getIssueTimeEntries(fixtures.projectName(), fixtures.issueId()); + Assert.assertNotNull(timeEntries); + } + + @Test + public void getAttachments() throws Exception { + Attachment[] attachments = getService().getAttachments(fixtures.projectName(), fixtures.versionName()); + Assert.assertNotNull(attachments); + } + + @Test(expected = RedmineServiceLoginException.class) + public void getUserProjects() throws Exception { + getService().getUserProjects(); + } + + @Test(expected = RedmineServiceLoginException.class) + public void addVersion() throws Exception { + getService().addVersion(fixtures.projectName(), new Version()); + } + + @Test(expected = RedmineServiceLoginException.class) + public void addAttachment() throws Exception { + getService().addAttachment(fixtures.projectName(), fixtures.versionName(), new Attachment()); + } + + @Test(expected = RedmineServiceLoginException.class) + public void addNews() throws Exception { + getService().addNews(fixtures.projectName(), new News()); + } + + @Test(expected = RedmineServiceLoginException.class) + public void updateVersion() throws Exception { + getService().updateVersion(fixtures.projectName(), new Version()); + } + + @Test(expected = RedmineServiceLoginException.class) + public void nextVersion() throws Exception { + getService().nextVersion(fixtures.projectName(), fixtures.versionName(), new Version()); + } + + @Test(expected = RedmineServiceLoginException.class) + public void addIssueTime() throws Exception { + getService().addIssueTimeEntry(fixtures.projectName(), fixtures.issueId(), new TimeEntry()); + } + +} Property changes on: trunk/jredmine-client-2.x/src/test/java/org/nuiton/jredmine/v2_x/RedmineServiceAsAnonymousTest.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/jredmine-client-2.x/src/test/java/org/nuiton/jredmine/v2_x/RedmineServiceTest.java =================================================================== --- trunk/jredmine-client-2.x/src/test/java/org/nuiton/jredmine/v2_x/RedmineServiceTest.java (rev 0) +++ trunk/jredmine-client-2.x/src/test/java/org/nuiton/jredmine/v2_x/RedmineServiceTest.java 2012-07-13 17:44:33 UTC (rev 292) @@ -0,0 +1,237 @@ +package org.nuiton.jredmine.v2_x; +/* + * #%L + * JRedmine :: Client 2.x + * $Id$ + * $HeadURL:$ + * %% + * Copyright (C) 2009 - 2012 CodeLutin, Tony Chemit + * %% + * 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% + */ + +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Rule; +import org.junit.Test; +import org.nuiton.jredmine.RedmineService; +import org.nuiton.jredmine.RedmineServiceConfiguration; +import org.nuiton.jredmine.RedmineServiceException; +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.io.IOException; + +/** + * Tests the {@link RedmineAnonymousServiceImpl}. + * + * @author tchemit <chemit@codelutin.com> + * @since 1.5 + */ +@Ignore +public class RedmineServiceTest { + + protected static final RedmineFixtures fixtures = new RedmineFixtures(); + + @Rule + public final RedmineServer<RedmineService> server = createNewServer(fixtures); + + protected RedmineService getService() { + return server.getService(); + } + + + protected RedmineServer<RedmineService> createNewServer(RedmineFixtures fixtures) { + return new RedmineServer<RedmineService>(fixtures) { + + @Override + protected RedmineService createService( + RedmineFixtures fixture, + RedmineServiceConfiguration configuration) throws IOException, RedmineServiceException { + return fixture.newRedmineService(configuration); + } + + @Override + protected RedmineServiceConfiguration createConfiguration(RedmineFixtures fixture) throws IOException { + RedmineServiceConfiguration conf = fixture.newLogguedConfiguration(); + return conf; + } + }; + } + + @BeforeClass + public static void beforeClass() { + RedmineServer<RedmineService> newServer = + new RedmineServiceTest().createNewServer(fixtures); + newServer.checkService(); + } + + @Test + public void getProjects() throws Exception { + Project[] projects = getService().getProjects(); + Assert.assertNotNull(projects); + } + + @Test + public void getIssuePriorities() throws Exception { + IssuePriority[] issuePriorities = getService().getIssuePriorities(); + Assert.assertNotNull(issuePriorities); + } + + @Test + public void getIssueStatuses() throws Exception { + IssueStatus[] issueStatuses = getService().getIssueStatuses(); + Assert.assertNotNull(issueStatuses); + } + + @Test + public void getProject() throws Exception { + Project project = getService().getProject(fixtures.projectName()); + Assert.assertNotNull(project); + } + + @Test + public void getIssueCategories() throws Exception { + IssueCategory[] issueCategories = getService().getIssueCategories(fixtures.projectName()); + Assert.assertNotNull(issueCategories); + } + + @Test + public void getTrackers() throws Exception { + Tracker[] trackers = getService().getTrackers(fixtures.projectName()); + Assert.assertNotNull(trackers); + } + + @Test + public void getNews() throws Exception { + News[] news = getService().getNews(fixtures.projectName()); + Assert.assertNotNull(news); + } + + @Test + public void getProjectMembers() throws Exception { + User[] users = getService().getProjectMembers(fixtures.projectName()); + Assert.assertNotNull(users); + } + + @Test + public void getProjectIssues() throws Exception { + Issue[] issues = getService().getIssues(fixtures.projectName()); + Assert.assertNotNull(issues); + } + + @Test + public void getVersions() throws Exception { + Version[] versions = getService().getVersions(fixtures.projectName()); + Assert.assertNotNull(versions); + } + + @Test + public void getVersion() throws Exception { + Version version = getService().getVersion(fixtures.projectName(), fixtures.versionName()); + Assert.assertNotNull(version); + } + + @Test + public void getVersionIssues() throws Exception { + Issue[] issues = getService().getIssues(fixtures.projectName(), fixtures.versionName()); + Assert.assertNotNull(issues); + } + + @Test + public void getOpenedIssues() throws Exception { + Issue[] issues = getService().getOpenedIssues(fixtures.projectName()); + Assert.assertNotNull(issues); + } + + @Test + public void getClosedIssues() throws Exception { + Issue[] issues = getService().getClosedIssues(fixtures.projectName()); + Assert.assertNotNull(issues); + } + + @Test + public void getIssueTimeEntries() throws Exception { + TimeEntry[] timeEntries = getService().getIssueTimeEntries(fixtures.projectName(), fixtures.issueId()); + Assert.assertNotNull(timeEntries); + } + + @Test + public void getAttachments() throws Exception { + Attachment[] attachments = getService().getAttachments(fixtures.projectName(), fixtures.versionName()); + Assert.assertNotNull(attachments); + } + + @Test + public void getUserProjects() throws Exception { + Project[] userProjects = getService().getUserProjects(); + Assert.assertNotNull(userProjects); + } + + @Ignore + @Test + public void addVersion() throws Exception { + getService().addVersion(fixtures.projectName(), new Version()); + } + + @Ignore + @Test + public void addAttachment() throws Exception { + Version version = fixtures.getVersion(); + Attachment attachment = fixtures.getAttachment(); + Attachment updatedAttachment = getService().addAttachment( + fixtures.projectName(), + version.getName(), + attachment + ); + Assert.assertNotNull(updatedAttachment); + } + + @Ignore + @Test + public void addNews() throws Exception { + getService().addNews(fixtures.projectName(), new News()); + } + + @Ignore + @Test + public void updateVersion() throws Exception { + getService().updateVersion(fixtures.projectName(), new Version()); + } + + @Ignore + @Test + public void nextVersion() throws Exception { + getService().nextVersion(fixtures.projectName(), fixtures.versionName(), new Version()); + } + + @Ignore + @Test + public void addIssueTime() throws Exception { + getService().addIssueTimeEntry(fixtures.projectName(), fixtures.issueId(), new TimeEntry()); + } + +} Property changes on: trunk/jredmine-client-2.x/src/test/java/org/nuiton/jredmine/v2_x/RedmineServiceTest.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/jredmine-client-2.x/src/test/resources/log4j.properties =================================================================== --- trunk/jredmine-client-2.x/src/test/resources/log4j.properties (rev 0) +++ trunk/jredmine-client-2.x/src/test/resources/log4j.properties 2012-07-13 17:44:33 UTC (rev 292) @@ -0,0 +1,33 @@ +### +# #%L +# JRedmine :: Client 2.x +# $Id$ +# $HeadURL:$ +# %% +# Copyright (C) 2009 - 2012 CodeLutin, Tony Chemit +# %% +# 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% +### +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 Property changes on: trunk/jredmine-client-2.x/src/test/resources/log4j.properties ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/jredmine-client-2.x/src/test/resources/test-config.properties =================================================================== --- trunk/jredmine-client-2.x/src/test/resources/test-config.properties (rev 0) +++ trunk/jredmine-client-2.x/src/test/resources/test-config.properties 2012-07-13 17:44:33 UTC (rev 292) @@ -0,0 +1,27 @@ +### +# #%L +# JRedmine :: Client 2.x +# $Id$ +# $HeadURL:$ +# %% +# Copyright (C) 2009 - 2012 CodeLutin, Tony Chemit +# %% +# 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% +### +# default values for test configuration +test.redmineUrl=http://nuiton.org +test.encoding=UTF-8 +test.verbose=false Property changes on: trunk/jredmine-client-2.x/src/test/resources/test-config.properties ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Modified: trunk/jredmine-maven-plugin/pom.xml =================================================================== --- trunk/jredmine-maven-plugin/pom.xml 2012-07-13 17:16:17 UTC (rev 291) +++ trunk/jredmine-maven-plugin/pom.xml 2012-07-13 17:44:33 UTC (rev 292) @@ -56,6 +56,17 @@ </exclusion> </exclusions> </dependency> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>jredmine-client-2.x</artifactId> + <version>${project.version}</version> + <exclusions> + <exclusion> + <groupId>commons-httpclient</groupId> + <artifactId>commons-httpclient</artifactId> + </exclusion> + </exclusions> + </dependency> <dependency> <groupId>org.nuiton</groupId> Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2012-07-13 17:16:17 UTC (rev 291) +++ trunk/pom.xml 2012-07-13 17:44:33 UTC (rev 292) @@ -42,6 +42,7 @@ <modules> <module>jredmine-client-api</module> <module>jredmine-client-1.x</module> + <module>jredmine-client-2.x</module> <module>jredmine-maven-plugin</module> </modules>
participants (1)
-
tchemit@users.nuiton.org