incubator-depot-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nickcha...@apache.org
Subject svn commit: rev 36806 - in incubator/depot/trunk/version/src: java/org/apache/depot/version/impl/gump test/java/org/apache/depot/version test/java/org/apache/depot/version/impl/gump
Date Tue, 24 Aug 2004 05:24:29 GMT
Author: nickchalko
Date: Mon Aug 23 22:24:28 2004
New Revision: 36806

Modified:
   incubator/depot/trunk/version/src/java/org/apache/depot/version/impl/gump/GumpVersion.java
   incubator/depot/trunk/version/src/java/org/apache/depot/version/impl/gump/GumpVersionFormat.java
   incubator/depot/trunk/version/src/test/java/org/apache/depot/version/VersionTestCase.java
   incubator/depot/trunk/version/src/test/java/org/apache/depot/version/impl/gump/GumpVersionTest.java
Log:
Ok the GumpVersion tests are now failing.
GumpVersion is very different from ApacheVersion and should help us
keep the top level classes Abstract.

Modified: incubator/depot/trunk/version/src/java/org/apache/depot/version/impl/gump/GumpVersion.java
==============================================================================
--- incubator/depot/trunk/version/src/java/org/apache/depot/version/impl/gump/GumpVersion.java
(original)
+++ incubator/depot/trunk/version/src/java/org/apache/depot/version/impl/gump/GumpVersion.java
Mon Aug 23 22:24:28 2004
@@ -22,40 +22,47 @@
 import org.apache.depot.version.specification.VersionSpecification;
 
 /**
- * 
+ *  
  */
 public class GumpVersion implements Version {
 
 	public final static VersionSpecification SPECIFICATION = new GumpVersionSpecification();
-	
+
 	private final long buildNumber;
-	
+
+	private final int hashCode;
 
 	/**
 	 * @param versionString
 	 */
-	public GumpVersion(String versionString) {
-		versionString=versionString.trim();
-		buildNumber=Long.parseLong(versionString);
+	public GumpVersion(long buildNumber) {
+		this.buildNumber = buildNumber;
+		hashCode = (new Long(buildNumber)).hashCode();
 	}
 
-	/* (non-Javadoc)
+	/*
+	 * (non-Javadoc)
+	 * 
 	 * @see org.apache.depot.version.Version#isCompatible(org.apache.depot.version.Version)
 	 */
 	public boolean isCompatible(Version version) {
-		
+
 		return false;
 	}
 
-	/* (non-Javadoc)
+	/*
+	 * (non-Javadoc)
+	 * 
 	 * @see org.apache.depot.version.Version#increment(java.lang.String)
 	 */
 	public Version increment(String level) throws VersionException {
 		// TODO Auto-generated method stub
-		return null;
+		return new GumpVersion(buildNumber + 1);
 	}
 
-	/* (non-Javadoc)
+	/*
+	 * (non-Javadoc)
+	 * 
 	 * @see org.apache.depot.version.Version#getComparator()
 	 */
 	public Comparator getComparator() {
@@ -63,21 +70,52 @@
 		return null;
 	}
 
-	/* (non-Javadoc)
+	/*
+	 * (non-Javadoc)
+	 * 
 	 * @see java.lang.Comparable#compareTo(java.lang.Object)
 	 */
 	public int compareTo(Object o) {
 		// TODO Auto-generated method stub
 		return 0;
 	}
-	
+
 	/**
 	 * Returns the format.
 	 * 
 	 * @return VersionSpecification
 	 */
 	public VersionSpecification getSpecification() {
-		return SPECIFICATION ;
+		return SPECIFICATION;
 	}
 
-}
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see java.lang.Object#equals(java.lang.Object)
+	 */
+	public boolean equals(Object obj) {
+		// TODO Auto-generated method stub
+		return super.equals(obj);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see java.lang.Object#hashCode()
+	 */
+	public int hashCode() {
+
+		return hashCode;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see java.lang.Object#toString()
+	 */
+	public String toString() {
+
+		return "gump-" + buildNumber;
+	}
+}
\ No newline at end of file

Modified: incubator/depot/trunk/version/src/java/org/apache/depot/version/impl/gump/GumpVersionFormat.java
==============================================================================
--- incubator/depot/trunk/version/src/java/org/apache/depot/version/impl/gump/GumpVersionFormat.java
(original)
+++ incubator/depot/trunk/version/src/java/org/apache/depot/version/impl/gump/GumpVersionFormat.java
Mon Aug 23 22:24:28 2004
@@ -94,7 +94,13 @@
 	 * @see org.apache.depot.version.specification.formatting.VersionFormat#parseVersion(java.lang.String)
 	 */
 	public Version parseVersion(String version) throws VersionFormatException {
-		// TODO Auto-generated method stub
-		return null;
+
+		String number = version.trim().toUpperCase();
+		if (number.startsWith("GUMP-")) {
+			number = number.substring(5);
+		}
+
+		long buildNumber = Long.parseLong(number);
+		return new GumpVersion(buildNumber);
 	}
 }

Modified: incubator/depot/trunk/version/src/test/java/org/apache/depot/version/VersionTestCase.java
==============================================================================
--- incubator/depot/trunk/version/src/test/java/org/apache/depot/version/VersionTestCase.java
(original)
+++ incubator/depot/trunk/version/src/test/java/org/apache/depot/version/VersionTestCase.java
Mon Aug 23 22:24:28 2004
@@ -293,7 +293,7 @@
 	/**
 	 * @return
 	 */
-	private String getBaseVersionString() {
+	protected String getBaseVersionString() {
 		return "1";
 	}
 

Modified: incubator/depot/trunk/version/src/test/java/org/apache/depot/version/impl/gump/GumpVersionTest.java
==============================================================================
--- incubator/depot/trunk/version/src/test/java/org/apache/depot/version/impl/gump/GumpVersionTest.java
(original)
+++ incubator/depot/trunk/version/src/test/java/org/apache/depot/version/impl/gump/GumpVersionTest.java
Mon Aug 23 22:24:28 2004
@@ -15,11 +15,10 @@
  */
 package org.apache.depot.version.impl.gump;
 
-import org.apache.depot.version.CompoundVersion;
-import org.apache.depot.version.VersionException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
 import org.apache.depot.version.VersionTestCase;
-import org.apache.depot.version.impl.data.ReleaseLevel;
-import org.apache.depot.version.impl.gump.GumpVersion;
 import org.apache.depot.version.specification.formatting.VersionFormatException;
 
 /**
@@ -27,11 +26,16 @@
  */
 public class GumpVersionTest extends VersionTestCase {
 
+	private final String baseVersionString;
+
 	/**
 	 * @param specification
 	 */
 	public GumpVersionTest() {
 		super(GumpVersion.SPECIFICATION);
+		Date now = new Date();
+		SimpleDateFormat format = new SimpleDateFormat("yyyyMMDD");
+		baseVersionString = "gump-" + format.format(now);
 	}
 
 	// :TODO: 1.0.0 ! 1.0.-1 == UNSET
@@ -40,7 +44,7 @@
 	// Maybe it should be....
 
 	public void testEquals() throws VersionFormatException {
-		assertAllEqual(new String[] { "1","gump-1", "GUMP-1" });
+		assertAllEqual(new String[] { "1", "gump-1", "GUMP-1" });
 	}
 
 	public void testNonCompatible() throws VersionFormatException {
@@ -51,6 +55,10 @@
 
 	}
 
-
-
+	/*
+	 * @return "gump-1"
+	 */
+	protected String getBaseVersionString() {
+		return baseVersionString;
+	}
 }

Mime
View raw message