incubator-depot-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aj...@apache.org
Subject svn commit: rev 23084 - in incubator/depot/trunk/version/src: java/org/apache/depot/version/impl/data java/org/apache/depot/version/impl/util test/java/org/apache/depot/version/discovery/loading test/java/org/apache/depot/version/impl
Date Tue, 20 Jul 2004 15:21:49 GMT
Author: ajack
Date: Tue Jul 20 08:21:48 2004
New Revision: 23084

Added:
   incubator/depot/trunk/version/src/java/org/apache/depot/version/impl/util/DiffTool.java
      - copied, changed from rev 23083, incubator/depot/trunk/version/src/java/org/apache/depot/version/impl/util/ApacheVersionMarkerDiffTool.java
Removed:
   incubator/depot/trunk/version/src/java/org/apache/depot/version/impl/util/ApacheVersionMarkerDiffTool.java
Modified:
   incubator/depot/trunk/version/src/java/org/apache/depot/version/impl/data/VersionData.java
   incubator/depot/trunk/version/src/java/org/apache/depot/version/impl/data/VersionDataComparator.java
   incubator/depot/trunk/version/src/test/java/org/apache/depot/version/discovery/loading/FilenameLoaderTests.java
   incubator/depot/trunk/version/src/test/java/org/apache/depot/version/impl/VersionTest.java
Log:
Cleaned up some unit tests, more to do.

Modified: incubator/depot/trunk/version/src/java/org/apache/depot/version/impl/data/VersionData.java
==============================================================================
--- incubator/depot/trunk/version/src/java/org/apache/depot/version/impl/data/VersionData.java
(original)
+++ incubator/depot/trunk/version/src/java/org/apache/depot/version/impl/data/VersionData.java
Tue Jul 20 08:21:48 2004
@@ -45,7 +45,7 @@
  * @author arb_jack@users.apache.org
  */
 public class VersionData
-	implements Dumpable, Comparable, DOMProducer, DOMConsumer, Version {
+	implements Dumpable, Comparable, DOMProducer, DOMConsumer {
 
 	public final static String VERSION_TAG = "version";
 	public final static String MAJOR_TAG = "major";
@@ -135,7 +135,9 @@
 		m_buildNumber = buildNumber;
 
 		m_buildDate = buildDate;
-	}/**
+	}
+	
+	/**
 	 * Constructor for VersionData.
 	*/
 	public VersionData(
@@ -517,6 +519,7 @@
 			else
 				equal &= (null == getReleaseLevel());
 
+			// Down to checking qualifiers...
 			equal
 				&= (otherVersionData.getReleaseQualifier()
 					== getReleaseQualifier());
@@ -834,23 +837,7 @@
 	}
 	public static VersionData getTestVersionData(int major,int minor,ReleaseLevel level,int
point)
 	{
-		return new TestVersionData(major,minor);
-	}
-
-	/* (non-Javadoc)
-	 * @see org.apache.depot.version.Version#isCompatible(org.apache.depot.version.Version)
-	 */
-	public boolean isCompatible(Version version) {
-		// TODO Auto-generated method stub
-		return false;
-	}
-
-	/* (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 TestVersionData(major,minor,level,point);
 	}
 }
 
@@ -860,35 +847,32 @@
 //
 class TestVersionData extends VersionData {
 	TestVersionData(int major,int minor) {
-		super(		VersionDataElementSet.SHORT,
-					major, 
+		super(		major, 
 					minor, 
-					VersionDataElement.UNSET_RELEASE_LEVEL, 
-					VersionDataElement.UNSET_RELEASE_QUALIFIER, 
-					VersionDataElement.UNSET_POINT, 
-					VersionDataElement.UNSET_BUILD_NUMBER,
-					VersionDataElement.UNSET_BUILD_DATE);
+					VersionDataElement.DEFAULT_RELEASE_LEVEL, 
+					VersionDataElement.DEFAULT_RELEASE_QUALIFIER, 
+					VersionDataElement.DEFAULT_POINT, 
+					VersionDataElement.DEFAULT_BUILD_NUMBER,
+					VersionDataElement.DEFAULT_BUILD_DATE);
 	}
 	
 	TestVersionData(int major,int minor,ReleaseLevel level, int point) {
-		super(		VersionDataElementSet.SHORT,
-					major, 
+		super(		major, 
 					minor, 
 					level, 
-					VersionDataElement.UNSET_RELEASE_QUALIFIER, 
+					VersionDataElement.DEFAULT_RELEASE_QUALIFIER, 
 					point, 
-					VersionDataElement.UNSET_BUILD_NUMBER,
-					VersionDataElement.UNSET_BUILD_DATE);
+					VersionDataElement.DEFAULT_BUILD_NUMBER,
+					VersionDataElement.DEFAULT_BUILD_DATE);
 	}
 	
 	TestVersionData() {
-		super(		VersionDataElementSet.SHORT,
-					1, 
+		super(		1, 
 					1, 
-					VersionDataElement.UNSET_RELEASE_LEVEL, 
-					VersionDataElement.UNSET_RELEASE_QUALIFIER, 
+					VersionDataElement.DEFAULT_RELEASE_LEVEL, 
+					VersionDataElement.DEFAULT_RELEASE_QUALIFIER, 
 					1, 
-					VersionDataElement.UNSET_BUILD_NUMBER,
-					VersionDataElement.UNSET_BUILD_DATE);
+					VersionDataElement.DEFAULT_BUILD_NUMBER,
+					VersionDataElement.DEFAULT_BUILD_DATE);
 	}
 }

Modified: incubator/depot/trunk/version/src/java/org/apache/depot/version/impl/data/VersionDataComparator.java
==============================================================================
--- incubator/depot/trunk/version/src/java/org/apache/depot/version/impl/data/VersionDataComparator.java
(original)
+++ incubator/depot/trunk/version/src/java/org/apache/depot/version/impl/data/VersionDataComparator.java
Tue Jul 20 08:21:48 2004
@@ -18,6 +18,8 @@
 
 import java.util.Comparator;
 
+import org.apache.depot.common.util.debug.DebugUtils;
+
 // :TODO: Compatibility a class -- a range? 
 // :TODO: Types of compatiblity, see commons...
 
@@ -47,7 +49,7 @@
                 VersionDataElementSet set2 = secondVersionData.getElements();
 
                 VersionDataElementSet elements = m_overlap ? set1.intersect(set2) : set1.union(set2);
-
+                
                 if (!elements.isEmpty()) {
                     comparison = 0;
 

Copied: incubator/depot/trunk/version/src/java/org/apache/depot/version/impl/util/DiffTool.java
(from rev 23083, incubator/depot/trunk/version/src/java/org/apache/depot/version/impl/util/ApacheVersionMarkerDiffTool.java)
==============================================================================
--- incubator/depot/trunk/version/src/java/org/apache/depot/version/impl/util/ApacheVersionMarkerDiffTool.java
(original)
+++ incubator/depot/trunk/version/src/java/org/apache/depot/version/impl/util/DiffTool.java
Tue Jul 20 08:21:48 2004
@@ -18,15 +18,26 @@
 
 import org.apache.depot.common.util.debug.DebugUtils;
 import org.apache.depot.common.util.note.AnnotationScratchpad;
+import org.apache.depot.version.impl.ApacheVersion;
 import org.apache.depot.version.impl.ApacheVersionMarker;
 import org.apache.depot.version.impl.VersionIdentifier;
 import org.apache.depot.version.impl.data.VersionData;
+import org.apache.depot.version.impl.data.VersionDataElementSet;
+import org.apache.depot.version.specification.VersionSpecification;
 
 /**
  * @author arb_jack@users.sourceforge.net
  */
-public class ApacheVersionMarkerDiffTool {
+public class DiffTool {
 
+	/**
+	 * Perform a difference on two ApacheVersionMarkers
+	 * 
+	 * @param vm1
+	 * @param vm2
+	 * @return the AnnotationScratchpad
+	 * @see AnnotationScratchpad
+	 */
 	public static AnnotationScratchpad diff(
 		ApacheVersionMarker vm1,
 		ApacheVersionMarker vm2) {
@@ -37,6 +48,13 @@
 		return pad;
 	}
 
+	/**
+	 * Difference two ApacheVersionMarkers
+	 * @param pad where to write into
+	 * @param vm1
+	 * @param vm2
+	 * @see AnnotationScratchpad
+	 */
 	public static void diff(
 		AnnotationScratchpad pad,
 		ApacheVersionMarker vm1,
@@ -46,9 +64,9 @@
 		pad.info("Version Marker #2: " + vm2);
 
 		if (vm1.equals(vm2))
-			pad.info(" * Versions Reported as Equal *");
+			pad.info(" * Version Markers Reported as Equal *");
 		else
-			pad.info(" * Versions Reported as NOT Equal *");
+			pad.info(" * Version Markers Reported as NOT Equal *");
 
 		VersionIdentifier id1 = vm1.getIdentifier();
 		VersionIdentifier id2 = vm2.getIdentifier();
@@ -65,24 +83,184 @@
 			pad.info("Version Identifier #2: " + id2);
 		}
 
-		VersionData d1 = vm1.getApacheVersion().getVersionData();
-		VersionData d2 = vm2.getApacheVersion().getVersionData();
+		ApacheVersion v1 = vm1.getApacheVersion();
+		ApacheVersion v2 = vm2.getApacheVersion();
+
+		diff(pad,v1,v2);
+	}
+	
+	/**
+	 * Perform a difference on two ApacheVersions
+	 * 
+	 * @param v1
+	 * @param v2
+	 * @return the AnnotationScratchpad
+	 * @see AnnotationScratchpad
+	 */
+	public static AnnotationScratchpad diff(
+		ApacheVersion v1,
+		ApacheVersion v2) {
+		AnnotationScratchpad pad = new AnnotationScratchpad();
+
+		diff(pad, v1, v2);
+
+		return pad;
+	}
+	
+	/**
+	 * Difference two ApacheVersions
+	 * 
+	 * @param pad the AnnotationScratchpad to write into
+	 * @param v1
+	 * @param v2
+	 * @see AnnotationScratchpad
+	 */
+	public static void diff(
+		AnnotationScratchpad pad,
+		ApacheVersion v1,
+		ApacheVersion v2) {
+
+		pad.info("Version #1: " + v1);
+		pad.info("Version #2: " + v2);
 
-		if (d1.equals(d2)) {
-			pad.debug(" * Version Datum Reported as Equal *");
-			pad.debug("Version Data #1: " + d1);
-			pad.debug("Version Data #2: " + d2);
+		if (v1.equals(v2))
+			pad.info(" * Versions Reported as Equal *");
+		else
+			pad.info(" * Versions Reported as NOT Equal *");
+
+		VersionSpecification s1 = v1.getSpecification();
+		VersionSpecification s2 = v2.getSpecification();
+
+		if (s1.equals(s2)) {
+			pad.debug(" * Version Specifications Reported as Equal *");
+			pad.debug("Version Specification #1: " + s1);
+			pad.debug("Version Specification #2: " + s2);
 		}
 		else {
-			pad.info(" * Version Datum Reported as NOT Equal *");
-			pad.info("Version Data #1: " + d1);
-			pad.info("Version Data #2: " + d2);
+			pad.info(" * Version Specifications Reported as NOT Equal *");
+			pad.info("Version Specification #1: " + s1);
+			pad.info("Version Specification #2: " + s2);
+		}
+
+		VersionData d1 = v1.getVersionData();
+		VersionData d2 = v2.getVersionData();
+
+		diff(pad,d1,d2);
+	}
+
+	/**
+	 * Perform a difference on two VersionData
+	 * 
+	 * @param d1
+	 * @param d2
+	 * @return the AnnotationScratchpad
+	 * @see AnnotationScratchpad
+	 */
+	public static AnnotationScratchpad diff(
+		VersionData d1,
+		VersionData d2) {
+		AnnotationScratchpad pad = new AnnotationScratchpad();
+
+		diff(pad, d1, d2);
+
+		return pad;
+	}
+	
+	/**
+	 * Difference two VersionDatum
+	 * 
+	 * @param pad -- the scratchpad to write into
+	 * @param d1
+	 * @param d2
+	 * @see AnnotationScratchpad
+	 */
+	public static void diff(
+		AnnotationScratchpad pad,
+		VersionData d1,
+		VersionData d2) {
+
+		pad.info("VersionData #1: " + d1);
+		pad.info("VersionData #2: " + d2);
+
+		if (d1.equals(d2))
+			pad.info(" * VersionDatum Reported as Equal *");
+		else
+			pad.info(" * VersionDatum Reported as NOT Equal *");
+
+		VersionDataElementSet s1 = d1.getElements();
+		VersionDataElementSet s2 = d2.getElements();
+		if (s1.equals(s2)) {
+			pad.debug(" * VersionDataElementSets Reported as Equal *");
+			pad.debug("VersionData ElementSet #1: " + s1);
+			pad.debug("VersionData ElementSet #2: " + s2);
+		}
+		else {
+			pad.info(" * VersionDataElementSets Reported as NOT Equal *");
+			pad.info("VersionData ElementSet #1: " + s1);
+			pad.info("VersionData ElementSet #2: " + s2);
+		}
+		
+
+		if (d1.getMajor() != d2.getMajor())
+		{
+			pad.info("* Major Version Numbers differ *");
+			pad.info("Major Version #1: " + d1.getMajor());
+			pad.info("Major Version #2: " + d2.getMajor());
+		}
+
+		if (d1.getMinor() != d2.getMinor())
+		{
+			pad.info("* Minor Version Numbers differ *");
+			pad.info("Minor Version #1: " + d1.getMinor());
+			pad.info("Minor Version #2: " + d2.getMinor());
+		}
+
+		if (!d1.getReleaseLevel().equals(d2.getReleaseLevel()))
+		{
+			pad.info("* Release Levels differ *");
+			pad.info("Release Level #1: " + d1.getReleaseLevel());
+			pad.info("Release Level #2: " + d2.getReleaseLevel());
+			pad.info("Release Level #1: " + d1.getReleaseLevelAsString());
+			pad.info("Release Level #2: " + d2.getReleaseLevelAsString());
+		}
+		
+		if (d1.getReleaseQualifier() != d2.getReleaseQualifier())
+		{
+			pad.info("* Release Qualifiers differ *");
+			pad.info("Release Qualifier#1: " + d1.getReleaseQualifier());
+			pad.info("Release Qualifier#2: " + d2.getReleaseQualifier());
+		}
+		
+		if (d1.getPoint() != d2.getPoint())
+		{
+			pad.info("* Point Version Numbers differ *");
+			pad.info("Point Version #1: " + d1.getPoint());
+			pad.info("Point Version #2: " + d2.getPoint());
+		}
+
+/*
+
+		
+				equal &= (otherVersionData.getBuildNumber() == getBuildNumber());
+
+				if (null != otherVersionData.getBuildDate()) {
+					equal
+						&= (otherVersionData.getBuildDate().equals(getBuildDate()));
+				}
+				else
+					equal &= (null == getBuildDate());
+
+				// :TODO: Attributes/Annotations/Constraints/other
+			}
+
+			return equal;
 		}
+		*/
 	}
 
 	public static void main(String args[]) throws Exception {
 		AnnotationScratchpad pad =
-			ApacheVersionMarkerDiffTool.diff(
+			DiffTool.diff(
 				ApacheVersionMarker.getTestVersionMarker("A"),
 				ApacheVersionMarker.getTestVersionMarker("B", 1, 2));
 

Modified: incubator/depot/trunk/version/src/test/java/org/apache/depot/version/discovery/loading/FilenameLoaderTests.java
==============================================================================
--- incubator/depot/trunk/version/src/test/java/org/apache/depot/version/discovery/loading/FilenameLoaderTests.java
(original)
+++ incubator/depot/trunk/version/src/test/java/org/apache/depot/version/discovery/loading/FilenameLoaderTests.java
Tue Jul 20 08:21:48 2004
@@ -20,11 +20,14 @@
 
 import junit.framework.TestCase;
 
+import org.apache.depot.common.util.debug.DebugUtils;
+import org.apache.depot.common.util.note.AnnotationScratchpad;
 import org.apache.depot.version.VersionException;
 import org.apache.depot.version.VersionMarker;
 import org.apache.depot.version.impl.ApacheVersionMarker;
 import org.apache.depot.version.impl.VersionIdentifier;
 import org.apache.depot.version.impl.VersionIdentifierType;
+import org.apache.depot.version.impl.util.DiffTool;
 import org.apache.depot.version.specification.formatting.VersionFormatException;
 
 /**
@@ -115,7 +118,14 @@
 		VersionMarker expectedResult)
 		throws VersionFormatException, VersionException {
 		VersionLoadContext context = m_loader.load(new File(filename));
+		
+		/*AnnotationScratchpad pad =
+			DiffTool.diff(
+				(ApacheVersionMarker)expectedResult,
+				(ApacheVersionMarker)context.getVersionMarker());
 
+		DebugUtils.dump(pad);*/
+		
 		assertNotNull(
 			"Extracted something from filename: " + filename,
 			context);

Modified: incubator/depot/trunk/version/src/test/java/org/apache/depot/version/impl/VersionTest.java
==============================================================================
--- incubator/depot/trunk/version/src/test/java/org/apache/depot/version/impl/VersionTest.java
(original)
+++ incubator/depot/trunk/version/src/test/java/org/apache/depot/version/impl/VersionTest.java
Tue Jul 20 08:21:48 2004
@@ -95,8 +95,8 @@
             "compares to self",
             m_version11A1.compareTo(m_version11A1) == 0);
         assertTrue(
-            "alpha less than beta",
-            m_version11A1.compareTo(m_version11B1) < 0);
+                "alpha less than beta",
+                m_version11A1.compareTo(m_version11B1) < 0);
         assertTrue(
             "11 beta with 12 alpha",
             m_version11B1.compareTo(m_version12A1) < 0);

Mime
View raw message