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 30886 - in incubator/depot/trunk/update: . bin src src/java/org/apache/depot/update src/java/org/apache/depot/update/files src/java/org/apache/depot/update/impl/util src/java/org/apache/depot/update/tool src/java/org/apache/depot/update/util/net/http src/java/org/apache/depot/update/version src/test/org/apache/depot/update/files
Date Wed, 28 Jul 2004 23:55:55 GMT
Author: ajack
Date: Wed Jul 28 16:55:54 2004
New Revision: 30886

Added:
   incubator/depot/trunk/update/src/.svnignore
   incubator/depot/trunk/update/src/java/org/apache/depot/update/impl/util/
   incubator/depot/trunk/update/src/java/org/apache/depot/update/impl/util/DiffTool.java
   incubator/depot/trunk/update/src/java/org/apache/depot/update/version/Version.java
      - copied, changed from rev 30844, incubator/depot/trunk/update/src/java/org/apache/depot/update/version/VersionHelper.java
Removed:
   incubator/depot/trunk/update/src/java/org/apache/depot/update/version/VersionHelper.java
Modified:
   incubator/depot/trunk/update/.svnignore
   incubator/depot/trunk/update/bin/update.py
   incubator/depot/trunk/update/src/java/org/apache/depot/update/Artifact.java
   incubator/depot/trunk/update/src/java/org/apache/depot/update/ArtifactInstance.java
   incubator/depot/trunk/update/src/java/org/apache/depot/update/files/DefaultArtifactFilenameAnalyzer.java
   incubator/depot/trunk/update/src/java/org/apache/depot/update/tool/RepositoryTool.java
   incubator/depot/trunk/update/src/java/org/apache/depot/update/tool/Tool.java
   incubator/depot/trunk/update/src/java/org/apache/depot/update/util/net/http/HttpClientUserAgent.java
   incubator/depot/trunk/update/src/test/org/apache/depot/update/files/DefaultArtifactAnalyzerTests.java
Log:
Added a DiffTool to help debug unit test failures. Needn't have bothered,
we didn't even have an equals() implemented on Artifact. Doh!

Modified: incubator/depot/trunk/update/.svnignore
==============================================================================
--- incubator/depot/trunk/update/.svnignore	(original)
+++ incubator/depot/trunk/update/.svnignore	Wed Jul 28 16:55:54 2004
@@ -4,3 +4,4 @@
 .project
 .classpath
 doc
+test
\ No newline at end of file

Modified: incubator/depot/trunk/update/bin/update.py
==============================================================================
--- incubator/depot/trunk/update/bin/update.py	(original)
+++ incubator/depot/trunk/update/bin/update.py	Wed Jul 28 16:55:54 2004
@@ -29,41 +29,90 @@
 import time
 from string import split
 
+class Verbosity:
+    
+    QUIET=0
+    VERBOSE=1
+    DEBUG=2
+    
+    def __init__(self,level=QUIET):
+        self.level=level
+        
+    def setLevel(self,level):
+        self.level=level
+        
+    def isVerbose(self):
+        return self.level >= Verbosity.VERBOSE
+        
+    def isDebug(self):
+        return self.level >= Verbosity.DEBUG
+        
+    def isQuiet(self):
+        return self.level >= Verbosity.QUIET
 
 def checkEnvironment():
+    """
+    Check environment is set correct.
+    """
+    if os.environ.has_key('DEPOT_UPDATE_HOME'):
+       return 
+    
     if not os.environ.has_key('DEPOT_HOME'):
-        raise RuntimeError, 'Please set the DEPOT_HOME environment variable to where Apache
Depot is installed.'
+        raise RuntimeError, 'Please set $DEPOT_HOME (or $DEPOT_UPDATE_HOME) to where Apache
Depot is installed.'
     
 def callJavaCommand(iargs):
-    
+    """
+    Do the thing...
+    """
     env={}
     cp=[]
-    
-    # Original CLASSPATH
-    if os.environ.has_key('CLASSPATH'):
-        cp=split(os.environ['CLASSPATH'],os.pathsep)
-    
     # Where out jar/code is...
-    depotHome=os.path.abspath(os.environ['DEPOT_HOME'])
-    print depotHome
+    depotHome=os.path.abspath(os.environ['DEPOT_UPDATE_HOME'] or os.environ['DEPOT_HOME'])
+    if verbosity.isDebug(): print "DEPOT_HOME: " + depotHome
     depotJars=os.path.abspath(os.path.join(depotHome,'jars'))
-    print depotJars
+    depotEnv=os.path.abspath(os.path.join(depotHome,'local.env'))
     
+    # Allow local additions
+    if os.path.exists(depotEnv):
+        if verbosity.isDebug(): print "Depot Env: " + depotEnv
+        envFile=None
+        try:
+            envFile=file(depotEnv,'r')
+    
+            # Split into a dict of NAME=VALUE (from file)
+            import re
+            envInfo=dict(re.findall('(.*?)=(.*)', envFile.read()))
+        
+            for key in envInfo.iterkeys():
+                if verbosity.isDebug(): print 'ENV : ' + key  + ' -> ' + envInfo[key]
+                env[key]=envInfo[key]             
+        finally:
+            if envFile: envFile.close()
+    else:
+        if verbosity.isDebug(): print "*No* Depot Env: " + depotEnv       
+                
+    # Original CLASSPATH
+    if env.has_key('CLASSPATH'):
+        cp=split(env['CLASSPATH'],os.pathsep)
+    elif os.environ.has_key('CLASSPATH'):
+        cp=split(os.environ['CLASSPATH'],os.pathsep)
+        
     # Build the CLASSPATH
     if os.path.exists(depotJars):
+        if verbosity.isDebug(): print "DEPOT JARS: " + depotJars   
         for jar in os.listdir(depotJars):
             if jar.endWith('.jar'):
+                if verbosity.isDebug(): print "DEPOT JAR: " + `jar`    
                 cp.append(os.path.abspath(jar))
-            
+    else:
+        if verbosity.isDebug(): print "*No* Depot Jars: " + depotJars       
+        
     # New CLASSPATH    
     classpath = os.pathsep.join(cp) 
     env['CLASSPATH'] = classpath
-    print classpath
+    if verbosity.isDebug(): print 'Formed CLASSPATH : ' + classpath
     
-    
-    #
     # Actually run the Java command
-    #    
     return runCommand(	'java org.apache.depot.update.tool.DownloaderTool', 
                         ' '.join(iargs),
                         env)
@@ -85,7 +134,7 @@
             raise
             
     if env:
-                 # Note: We only override what is given, not everything
+        # Note: We only override what is given, not everything
         originalENV={}
         for envKey in env.iterkeys():
             try:
@@ -128,12 +177,12 @@
 
     return exit_code
 
-
 # static void main()
 if __name__=='__main__':
 
     args=list(sys.argv)
     result=0
+    verbosity=Verbosity(Verbosity.QUIET)
     
     try:
         checkEnvironment()
@@ -143,17 +192,18 @@
         del args[0]     
     
         # Call the Java command with the rest of them
-        callJavaCommand(args)
+        result=callJavaCommand(args)
 
     except KeyboardInterrupt:    
-        print 'Terminated by user interrupt...'
+        if verbosity.isVerbose(): print 'Terminated by user interrupt...'
         result = 1
         raise
         
     except:    
-        print 'Terminated unintentionally...'
+        if verbosity.isVerbose(): print  'Terminated unintentionally...'
         result = 1
         raise
     
-    # bye!
+    # Exiting...
+    if verbosity.isVerbose(): print  'Exited with code: ' + `result`       
     sys.exit(result)

Added: incubator/depot/trunk/update/src/.svnignore
==============================================================================
--- (empty file)
+++ incubator/depot/trunk/update/src/.svnignore	Wed Jul 28 16:55:54 2004
@@ -0,0 +1 @@
+resources

Modified: incubator/depot/trunk/update/src/java/org/apache/depot/update/Artifact.java
==============================================================================
--- incubator/depot/trunk/update/src/java/org/apache/depot/update/Artifact.java	(original)
+++ incubator/depot/trunk/update/src/java/org/apache/depot/update/Artifact.java	Wed Jul 28
16:55:54 2004
@@ -186,6 +186,49 @@
 	public ArtifactGroup getGroup() {
 		return m_group;
 	}
+	
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see java.lang.Object#equals(java.lang.Object)
+	 */
+	public boolean equals(Object other) {
+		boolean equal = true;
+
+		if (other instanceof Artifact) {
+			Artifact otherArtifact = (Artifact) other;
+
+			equal = otherArtifact.m_identifier.equals(m_identifier);
+			equal &= otherArtifact.m_group.equals(m_group);
+			equal &= otherArtifact.m_type.equals(m_type);
+			if (null != m_version)
+				equal &= otherArtifact.m_version.equals(m_version);
+			else
+				equal &= (null == otherArtifact.m_version);
+		} else
+			throw new IllegalArgumentException("Not an Artifact: "
+					+ other.getClass().getName());
+
+		return equal;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see java.lang.Object#hashCode()
+	 */
+	public int hashCode() {
+		int hash = 0;
+
+		hash += m_identifier.hashCode();
+		hash += m_group.hashCode();
+		hash += m_type.hashCode();
+
+		if (null != m_version)
+			hash += m_version.hashCode();
+		
+		return hash;
+	}
 
 	public String toString() {
 		StringBuffer buffer = new StringBuffer();
@@ -223,6 +266,10 @@
 		if (null != m_version) {
 			out.print(indent);
 			out.println("Resource Version: " + m_version);
+			
+			if ( verbose )
+				if ( m_version instanceof Dumpable )
+				DebugUtils.dump(out,depth+1,(Dumpable)m_version,verbose);
 		}
 	}
 	

Modified: incubator/depot/trunk/update/src/java/org/apache/depot/update/ArtifactInstance.java
==============================================================================
--- incubator/depot/trunk/update/src/java/org/apache/depot/update/ArtifactInstance.java	(original)
+++ incubator/depot/trunk/update/src/java/org/apache/depot/update/ArtifactInstance.java	Wed
Jul 28 16:55:54 2004
@@ -192,6 +192,9 @@
 		out.print(indent);
 		out.println("Resource Artifact: " + m_artifact);
 
+		if (verbose)
+			m_artifact.dump(out, depth+1, verbose);
+		
 		out.print(indent);
 		out.println("Resource Locator: " + m_locator);
 

Modified: incubator/depot/trunk/update/src/java/org/apache/depot/update/files/DefaultArtifactFilenameAnalyzer.java
==============================================================================
--- incubator/depot/trunk/update/src/java/org/apache/depot/update/files/DefaultArtifactFilenameAnalyzer.java
(original)
+++ incubator/depot/trunk/update/src/java/org/apache/depot/update/files/DefaultArtifactFilenameAnalyzer.java
Wed Jul 28 16:55:54 2004
@@ -309,8 +309,8 @@
 	}
 
 	//
-	//		HACK HACK HACK -- to get us started. Will evolve into a
-	//		whole configurable parsing sub-system
+	//		HACK HACK HACK -- to get us started. Could evolve into a
+	//		configurable parsing sub-system
 	//
 	void processString(
 		String artifactName,

Added: incubator/depot/trunk/update/src/java/org/apache/depot/update/impl/util/DiffTool.java
==============================================================================
--- (empty file)
+++ incubator/depot/trunk/update/src/java/org/apache/depot/update/impl/util/DiffTool.java
Wed Jul 28 16:55:54 2004
@@ -0,0 +1,174 @@
+/*
+ * Copyright  2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.depot.update.impl.util;
+
+import org.apache.depot.common.util.note.AnnotationScratchpad;
+import org.apache.depot.update.Artifact;
+import org.apache.depot.update.ArtifactInstance;
+import org.apache.depot.update.artifact.ArtifactGroup;
+import org.apache.depot.update.artifact.ArtifactLocator;
+import org.apache.depot.update.artifact.ArtifactType;
+import org.apache.depot.version.Version;
+
+/**
+ * @author ajack@apache.org
+ */
+public class DiffTool {
+
+	/**
+	 * Perform a difference on two ArtifactInstance
+	 * 
+	 * @param ai1
+	 * @param ai2
+	 * @return the AnnotationScratchpad
+	 * @see AnnotationScratchpad
+	 */
+	public static AnnotationScratchpad diff(
+		ArtifactInstance ai1,
+		ArtifactInstance ai2) {
+		AnnotationScratchpad pad = new AnnotationScratchpad();
+
+		diff(pad, ai1, ai2);
+
+		return pad;
+	}
+
+	/**
+	 * Difference two ArtifactInstance
+	 * @param pad where to write into
+	 * @param ai1
+	 * @param ai2
+	 * @see AnnotationScratchpad
+	 */
+	public static void diff(
+		AnnotationScratchpad pad,
+		ArtifactInstance ai1,
+		ArtifactInstance ai2) {
+
+		pad.info("Artifact Instance #1: " + ai1);
+		pad.info("Artifact Instance #2: " + ai2);
+
+		if (ai1.equals(ai2))
+			pad.info(" * Artifact Instances Reported as Equal *");
+		else
+			pad.info(" * Artifact Instances Reported as NOT Equal *");
+
+		Artifact a1 = ai1.getArtifact();
+		Artifact a2 = ai2.getArtifact();
+
+		boolean ae = a1.equals(a2);
+		if (ae) {
+			pad.debug(" * Artifacts Reported as Equal *");
+		}
+		else {
+			pad.info(" * Artifacts Reported as NOT Equal *");
+		}
+		pad.info("Artifact #1: " + a1);
+		pad.info("Artifact #2: " + a2);
+		if (!ae)
+			diff(pad, a1, a2);
+
+		ArtifactLocator l1 = ai1.getLocator();
+		ArtifactLocator l2 = ai2.getLocator();
+		
+		if (l1.equals(l2)) {
+			pad.debug(" * ArtifactLocators Reported as Equal *");
+		}
+		else {
+			pad.info(" * ArtifactLocators Reported as NOT Equal *");
+		}
+		pad.info("ArtifactLocator #1: " + l1);
+		pad.info("ArtifactLocator #2: " + l2);
+
+	}
+	
+	/**
+	 * Perform a difference on two Artifact
+	 * 
+	 * @param a1
+	 * @param a2
+	 * @return the AnnotationScratchpad
+	 * @see AnnotationScratchpad
+	 */
+	public static AnnotationScratchpad diff(
+		Artifact a1,
+		Artifact a2) {
+		AnnotationScratchpad pad = new AnnotationScratchpad();
+
+		diff(pad, a1, a2);
+
+		return pad;
+	}
+
+	/**
+	 * Difference two Artifact
+	 * @param pad where to write into
+	 * @param a1
+	 * @param a2
+	 * @see AnnotationScratchpad
+	 */
+	public static void diff(
+		AnnotationScratchpad pad,
+		Artifact a1,
+		Artifact a2) {
+
+		pad.info("Artifact  #1: " + a1);
+		pad.info("Artifact  #2: " + a2);
+
+		if (a1.equals(a2))
+			pad.info(" * Artifact s Reported as Equal *");
+		else
+			pad.info(" * Artifact s Reported as NOT Equal *");
+
+		ArtifactGroup g1 = a1.getGroup();
+		ArtifactGroup g2 = a2.getGroup();
+
+		if (g1.equals(g2)) {
+			pad.debug(" * ArtifactGroups Reported as Equal *");
+		}
+		else {
+			pad.info(" * ArtifactGroups Reported as NOT Equal *");
+		}
+		pad.info("ArtifactGroup #1: " + a1);
+		pad.info("ArtifactGroup #2: " + a2);
+		
+		ArtifactType t1 = a1.getType();
+		ArtifactType t2 = a2.getType();
+		
+		if (t1.equals(t2)) {
+			pad.debug(" * ArtifactTypes Reported as Equal *");
+		}
+		else {
+			pad.info(" * ArtifactTypes Reported as NOT Equal *");
+		}
+		pad.info("ArtifactType #1: " + t1);
+		pad.info("ArtifactType #2: " + t2);
+
+		Version v1 = a1.getVersion();
+		Version v2 = a2.getVersion();
+		
+		if (v1.equals(v2)) {
+			pad.debug(" * Versions Reported as Equal *");
+		}
+		else {
+			pad.info(" * Versions Reported as NOT Equal *");
+		}
+		pad.info("Version #1: " + v1);
+		pad.info("Version #2: " + v2);
+
+	}
+}

Modified: incubator/depot/trunk/update/src/java/org/apache/depot/update/tool/RepositoryTool.java
==============================================================================
--- incubator/depot/trunk/update/src/java/org/apache/depot/update/tool/RepositoryTool.java
(original)
+++ incubator/depot/trunk/update/src/java/org/apache/depot/update/tool/RepositoryTool.java
Wed Jul 28 16:55:54 2004
@@ -76,8 +76,8 @@
 		String repoId = cmdline.getMandatoryOptionValue(l_repoOption);
 
 		PrintWriter out = SystemUtils.getSystemOut();
-		//DebugUtils.printSeparator();
-		//DebugUtils.dump(cmdline);
+		DebugUtils.printSeparator();
+		DebugUtils.dump(cmdline);
 
 		Repository repository = DefaultRepository.getRepository(repoId);
 
@@ -108,8 +108,19 @@
 				}
 				else {
 					DebugUtils.printSeparator();
-					DebugUtils.dump(
-						repo.listInstances(group, AllSelector.getInstance()));
+
+					List instances =
+						repo.listInstances(group, AllSelector.getInstance());
+
+					for (Iterator ii = instances.iterator(); ii.hasNext();) {
+						ArtifactInstance instance = (ArtifactInstance) ii.next();
+
+						out.println("Instance : " + instance);
+						
+						if ( isVerbose() )
+							DebugUtils.dump(true,instance);
+							
+					}
 				}
 			}
 			else if (cmdline.isSet(l_listOption)) {
@@ -124,13 +135,13 @@
 
 					out.println("Group: " + group);
 
-					List resources =
+					List instances =
 						repo.listInstances(group, AllSelector.getInstance());
 
-					for (Iterator ii = resources.iterator(); ii.hasNext();) {
-						ArtifactInstance resource = (ArtifactInstance) ii.next();
+					for (Iterator ii = instances.iterator(); ii.hasNext();) {
+						ArtifactInstance instance = (ArtifactInstance) ii.next();
 
-						out.println("Resource : " + resource);
+						out.println("Instance : " + instance);
 					}
 				}
 			}

Modified: incubator/depot/trunk/update/src/java/org/apache/depot/update/tool/Tool.java
==============================================================================
--- incubator/depot/trunk/update/src/java/org/apache/depot/update/tool/Tool.java	(original)
+++ incubator/depot/trunk/update/src/java/org/apache/depot/update/tool/Tool.java	Wed Jul 28
16:55:54 2004
@@ -29,7 +29,7 @@
 import org.apache.depot.update.config.UpdaterConfig;
 import org.apache.depot.update.monitor.Monitor;
 import org.apache.depot.update.monitor.StatisticsMonitor;
-import org.apache.depot.update.version.VersionHelper;
+import org.apache.depot.update.version.Version;
 /**
  * @author ajack
  */
@@ -72,7 +72,7 @@
 	protected abstract String getTitle();
 	protected abstract void init();
 	protected void printVersion() {
-		String version = VersionHelper.getMarker().getLongVersion();
+		String version = Version.VERSION.getLongVersion();
 		System.out.println("Apache Depot " + getTitle() + " : " + version);
 	}
 	protected void printHelp() {
@@ -97,6 +97,15 @@
 		}
 		return cmdline;
 	}
+	
+	protected boolean isDebug(){
+		return l_debug;	
+	}
+	
+	protected boolean isVerbose(){
+		return l_verbose || l_debug;	
+	}
+	
 	public void run(String args[]) {
 		//:TODO:Hack
 		//DebugUtils.enableCommonsLogging();

Modified: incubator/depot/trunk/update/src/java/org/apache/depot/update/util/net/http/HttpClientUserAgent.java
==============================================================================
--- incubator/depot/trunk/update/src/java/org/apache/depot/update/util/net/http/HttpClientUserAgent.java
(original)
+++ incubator/depot/trunk/update/src/java/org/apache/depot/update/util/net/http/HttpClientUserAgent.java
Wed Jul 28 16:55:54 2004
@@ -29,7 +29,7 @@
 import org.apache.depot.common.log.Logger;
 import org.apache.depot.common.util.SystemUtils;
 import org.apache.depot.common.util.io.IOUtils;
-import org.apache.depot.update.version.VersionHelper;
+import org.apache.depot.update.version.Version;
 
 /**
  * @author arb_jack
@@ -176,7 +176,7 @@
 		//
 		method.setRequestHeader(
 			"User-Agent",
-			"Apache-Depot-Update/" + VersionHelper.getMarker().getLongVersion());
+			"Apache-Depot-Update/" + Version.VERSION.getLongVersion());
 	}
 
 	public static void main(String args[]) throws Exception {

Copied: incubator/depot/trunk/update/src/java/org/apache/depot/update/version/Version.java
(from rev 30844, incubator/depot/trunk/update/src/java/org/apache/depot/update/version/VersionHelper.java)
==============================================================================
--- incubator/depot/trunk/update/src/java/org/apache/depot/update/version/VersionHelper.java
(original)
+++ incubator/depot/trunk/update/src/java/org/apache/depot/update/version/Version.java	Wed
Jul 28 16:55:54 2004
@@ -15,43 +15,22 @@
  */
 package org.apache.depot.update.version;
 
-import org.apache.depot.version.VersionException;
-import org.apache.depot.version.VersionManager;
-import org.apache.depot.version.VersionMarker;
+import org.apache.depot.version.impl.ApacheVersionMarker;
+import org.apache.depot.version.impl.data.ReleaseLevel;
+
 
 /**
- * Static method for getting a version Marker for this project.
- *  
+ * Manual versioning..
  */
-public class VersionHelper {
+public class Version extends ApacheVersionMarker {
 	
-	public static void main(String[] args) {
-		System.out.print(VersionHelper.getMarker().getLongVersion());
-	}
-	
-	private final static VersionHelper INSTANCE = new VersionHelper();
-
-	private final Version version = new Version();
+	public final static Version VERSION = new Version();
 
-	private final VersionMarker MARKER;
-
-	private VersionHelper() {
-		VersionMarker temp = VersionMarker.UNKNOWN;
-		try {
-
-			temp = VersionManager.getManager().createVersionMarker(
-					"org.apache.depot.update",
-					version.getMajor() + "." + version.getMinor() + "."
-							+ version.getPoint() + "-"
-							+ version.getReleaseLevel());
-		} catch (VersionException e) {
-			// TODO Auto-generated catch block
-			e.printStackTrace();
-		}
-		MARKER = temp;
+	private Version() {
+		super(Version.class.getName(),1,1,ReleaseLevel.ALPHA,00001);
 	}
-
-	public static VersionMarker getMarker() {
-		return INSTANCE.MARKER;
+	
+	public static void main(String[] args) {
+		System.out.print(VERSION.getLongVersion());
 	}
 }

Modified: incubator/depot/trunk/update/src/test/org/apache/depot/update/files/DefaultArtifactAnalyzerTests.java
==============================================================================
--- incubator/depot/trunk/update/src/test/org/apache/depot/update/files/DefaultArtifactAnalyzerTests.java
(original)
+++ incubator/depot/trunk/update/src/test/org/apache/depot/update/files/DefaultArtifactAnalyzerTests.java
Wed Jul 28 16:55:54 2004
@@ -15,12 +15,13 @@
  */
 package org.apache.depot.update.files;
 
-import java.util.ArrayList;
 import java.util.List;
 
 import junit.framework.TestCase;
 
+import org.apache.depot.common.log.Logger;
 import org.apache.depot.common.util.debug.DebugUtils;
+import org.apache.depot.common.util.note.AnnotationScratchpad;
 import org.apache.depot.update.Artifact;
 import org.apache.depot.update.ArtifactInstance;
 import org.apache.depot.update.UpdateException;
@@ -29,6 +30,7 @@
 import org.apache.depot.update.util.net.VirtualResourceLocator;
 import org.apache.depot.version.Version;
 import org.apache.depot.version.impl.VersionImporter;
+import org.apache.depot.update.impl.util.DiffTool;
 
 
 /**
@@ -38,18 +40,17 @@
 
 	private DefaultArtifactFilenameAnalyzer m_analyzer = null;
 
-	//private VirtualResourceLocator m_http = null;
-	//private VirtualResourceLocator m_file = null;
-
 	public DefaultArtifactAnalyzerTests(String name) {
 		super(name);
+		
+		Logger.testInit();
 	}
 
 	public void setUp() throws Exception {
 		m_analyzer = new DefaultArtifactFilenameAnalyzer(
 				VirtualResourceLocator.getTestVRL());
 	}
-
+/*
 	public void testSeparator() throws Exception {
 		assertEquals("Found Underscore", 1, m_analyzer.findSeparator("A_B"));
 		assertEquals("Found Dash", 1, m_analyzer.findSeparator("A-B"));
@@ -97,6 +98,12 @@
 		checkArtifact(testPattern, createArtifact(testPattern, "mystuff",
 				"1.2", "src", "fred.z"));
 	}
+*/
+	public void testDated1() throws UpdateException {
+		String testPattern = "commons-vfs-20030518103800.jar";
+		checkArtifact(testPattern, createArtifact(testPattern, "commons-vfs",
+				"20030518103800", "java", "jar"));
+	}	
 
 	private ArtifactInstance createArtifact(String filename, String name, String v,
 			String t, String e) throws UpdateException {
@@ -114,7 +121,6 @@
 		else
 			artifactType = ArtifactType.UNKNOWN;
 		
-
 		return new ArtifactInstance(new Artifact(name, name, artifactType, version), 
 				new ArtifactLocator(filename,e,
 						new VirtualResourceLocator(
@@ -126,15 +132,23 @@
 			throws UpdateException {
 
 		DebugUtils.printSeparator();
-		DebugUtils.dump(expected);
+		DebugUtils.dump(true, expected);
 
-		ArtifactInstance artifact = m_analyzer.determineArtifact(pattern);
+		ArtifactInstance instance = m_analyzer.determineArtifact(pattern);
 
-		assertNotNull("Determined something", artifact);
+		assertNotNull("Determined something", instance);
 
 		DebugUtils.printSeparator();
-		DebugUtils.dump(artifact);
-		assertEquals("Same Artifact", expected, artifact);
+		DebugUtils.dump(true, instance);
+
+		AnnotationScratchpad pad =
+			DiffTool.diff(
+				expected,
+				instance);
+
+		DebugUtils.dump(pad);
+		
+		assertEquals("Same Artifact", expected, instance);
 	}
 
 	private void checkExtensionList(String pattern, List extns) {

Mime
View raw message