dion 2002/06/10 18:21:58 Modified: src/java/org/apache/maven/project Project.java Added: src/test/org/apache/maven/project ProjectTest.java Log: - Fixed some javadocs that were missing. - Added authors and fixed author tags - the pom version is now accessible as an int - whether the pom version matches MavenConstants is now available via a method - added tests for new functionality Revision Changes Path 1.1 jakarta-turbine-maven/src/test/org/apache/maven/project/ProjectTest.java Index: ProjectTest.java =================================================================== package org.apache.maven.project; /* ==================================================================== * The Apache Software License, Version 1.1 * * Copyright (c) 2002 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgment: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software itself, * if and wherever such third-party acknowledgments normally appear. * * 4. The names "Apache" and "Apache Software Foundation" and * "Apache Maven" must not be used to endorse or promote products * derived from this software without prior written permission. For * written permission, please contact [EMAIL PROTECTED] * * 5. Products derived from this software may not be called "Apache", * "Apache Maven", nor may "Apache" appear in their name, without * prior written permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. * * ==================================================================== */ import junit.framework.TestCase; import org.apache.maven.MavenConstants; /** * Unit tests for {@link Project} * * @author dion * @version $Id: ProjectTest.java,v 1.1 2002/06/11 01:21:56 dion Exp $ */ public class ProjectTest extends TestCase { Project instance; /** Creates a new instance of the test case * @param testName the name of the test */ public ProjectTest(String testName) { super(testName); } /** * Initialize per test data * @throws Exception when there is an unexpected problem */ public void setUp() throws Exception { instance = new Project(); } /** test that the object is created */ public void testConstructor() { assertNotNull("object not created", instance); } /** test that a null pomVersion returns "1" */ public void testPomVersion() { assertEquals("default pom version is not 1", "1", instance.getPomVersion()); assertEquals("default pom version not converted to an int", 1, instance.getPomVersionAsInt()); String newVersion = String.valueOf(MavenConstants.POM_VERSION); instance.setPomVersion(newVersion); assertEquals("set or get of pom version failed", newVersion, instance.getPomVersion()); assertEquals("conversion of new value failed", Integer.parseInt(newVersion), instance.getPomVersionAsInt()); } /** test that pom current works */ public void testPomCurrent() { assertTrue("pom is reporting it is current", !instance.isPomCurrent()); String newVersion = String.valueOf(MavenConstants.POM_VERSION); instance.setPomVersion(newVersion); assertTrue("pom is reporting it is not current", instance.isPomCurrent()); } } 1.25 +51 -6 jakarta-turbine-maven/src/java/org/apache/maven/project/Project.java Index: Project.java =================================================================== RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/project/Project.java,v retrieving revision 1.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- Project.java 4 Jun 2002 03:20:51 -0000 1.24 +++ Project.java 11 Jun 2002 01:21:58 -0000 1.25 @@ -62,9 +62,13 @@ import java.util.List; import java.util.Map; +import org.apache.maven.MavenConstants; + /** * @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a> - * @author <a href="[EMAIL PROTECTED]">Vincent Massol</a> + * @author <a href="mailto:[EMAIL PROTECTED]">Vincent Massol</a> + * @author <a href="mailto:[EMAIL PROTECTED]">dIon Gillard</a> + * @author <a href="mailto:[EMAIL PROTECTED]">Glenn McAllister</a> * @version $Id$ */ public class Project @@ -345,7 +349,7 @@ /** * Set the repository for this project. * - * @param repository + * @param repository the repository this project is part of */ public void setRepository(Repository repository) { @@ -355,7 +359,7 @@ /** * Return the repository used by this project. * - * @return Repository + * @return {@link Repository} for this project */ public Repository getRepository() { @@ -400,6 +404,7 @@ /** * Sets the description attribute of the Project object + * @param description the long description of the project */ public void setDescription(String description) { @@ -408,6 +413,7 @@ /** * Gets the description attribute of the Project object + * @return the long description of the project */ public String getDescription() { @@ -415,7 +421,8 @@ } /** - * Description of the Method + * @return <code>true</code> if the project is part of a repository, + * <code>false</code> otherwise */ public boolean hasRepository() { @@ -424,6 +431,8 @@ /** * Sets the currentVersion attribute of the Project object + * @param currentVersion the current version number of the project, e.g. + * <code>1.0</code>, <code>1.1-dev</code> */ public void setCurrentVersion(String currentVersion) { @@ -432,6 +441,8 @@ /** * Gets the currentVersion attribute of the Project object + * @return the current version of the project e.g. <code>1.0</code>, + * <code>1.1-dev</code> */ public String getCurrentVersion() { @@ -441,7 +452,7 @@ /** * Sets the project Organization. * - * @param organization + * @param organization the organisation name */ public void setOrganization(Organization organization) { @@ -460,6 +471,8 @@ /** * Sets the package attribute of the Project object + * @param projectPackage the package name, e.g. + * <code>org.apache.maven</code> */ public void setPackage(String projectPackage) { @@ -468,6 +481,8 @@ /** * Gets the package attribute of the Project object + * @return the base package name for the project, e.g. + * <code>org.apache.maven</code> */ public String getPackage() { @@ -476,6 +491,7 @@ /** * Sets the inceptionYear attribute of the Project object + * @param inceptionYear the year the project started, e.g. <code>2000</code> */ public void setInceptionYear(String inceptionYear) { @@ -500,12 +516,41 @@ /** * Gets the version attribute of the Project object + * @return the version of the project object specified or <code>1</code> + * if no value is provided */ public String getPomVersion() { + if (pomVersion == null) + { + pomVersion = "1"; + } return pomVersion; } + /** + * A helper method for various clients. + * @return the pom version as an integer. + * @throws NumberFormatException if {@link #getPomVersion} doesn't return + * a well formatted number + */ + public int getPomVersionAsInt() + { + return Integer.parseInt(getPomVersion()); + } + + /** + * Is the pom up to date? + * + * @return <code>true</code> if the pom version is the same as the + * currently running version of maven specified by {@link MavenConstants}, + * or <code>false</code> otherwise + */ + public boolean isPomCurrent() + { + return getPomVersionAsInt() == MavenConstants.POM_VERSION; + } + /** * Gets the module attribute of the Project object */
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
