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 30939 - in incubator/depot/trunk/update/src: java java/org/apache/depot/update java/org/apache/depot/update/query java/org/apache/depot/update/repository java/org/apache/depot/update/util/select test/org/apache/depot/update/query test/org/apache/depot/update/util/io
Date Thu, 29 Jul 2004 19:09:42 GMT
Author: ajack
Date: Thu Jul 29 12:09:41 2004
New Revision: 30939

Modified:
   incubator/depot/trunk/update/src/java/depot-update.xml
   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/query/QueryEngine.java
   incubator/depot/trunk/update/src/java/org/apache/depot/update/repository/MockRepository.java
   incubator/depot/trunk/update/src/java/org/apache/depot/update/util/select/SelectionHelper.java
   incubator/depot/trunk/update/src/test/org/apache/depot/update/query/QueryTests.java
   incubator/depot/trunk/update/src/test/org/apache/depot/update/util/io/ResolvedFileTest.java
Log:
Restored some getTextXXX code that fixed some unit tests.

Modified: incubator/depot/trunk/update/src/java/depot-update.xml
==============================================================================
--- incubator/depot/trunk/update/src/java/depot-update.xml	(original)
+++ incubator/depot/trunk/update/src/java/depot-update.xml	Thu Jul 29 12:09:41 2004
@@ -25,6 +25,10 @@
 		<repository id="apache" 
 					url="http://www.apache.org/library/projects/"
 					remote="true"/>	
+		
+		<repository id="codehaus" 
+					url="http://dist.codehaus.org/"
+					remote="true"/>	
 	</repositoryset>
 	
 	<repositoryset id="test">					
@@ -38,13 +42,9 @@
 	</repositoryset>	
 		
 	<repositoryset id="gump">					
-		<repository id="gump_dotnot" 
-					url="http://gump.dotnot.org/repository/"
-					remote="true" />
-					
-		<repository id="gump_lsd" 
-					url="http://lsd.student.utwente.nl/gump/jars/"
-					remote="true" />
+		<repository id="gump_brutus" 
+					url="http://brutus.apache.org/gump/public_jars/"
+					remote="true" />					
 	</repositoryset>	
 
 	<repositoryset id="lib">	

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	Thu Jul 29
12:09:41 2004
@@ -17,24 +17,30 @@
 package org.apache.depot.update;
 
 import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.List;
 
 import org.apache.depot.common.util.debug.DebugUtils;
 import org.apache.depot.common.util.debug.Dumpable;
 import org.apache.depot.update.artifact.ArtifactGroup;
 import org.apache.depot.update.artifact.ArtifactType;
 import org.apache.depot.update.util.identity.GenericIdentifier;
+import org.apache.depot.update.util.net.VirtualResourceLocator;
 import org.apache.depot.version.Version;
+import org.apache.depot.version.impl.ApacheVersion;
 
 /**
- * An entity in a repository (e.g. junit-3.8.1.jar). An Artifact has (at least in the apache.org
environment)
- * also a version. Also an Artifact has a security mechanism, which is nowadays mostly a
file with an
- * .asc or (better) .md5-Extension.
- * The basic attributes of an artifact are the group, this artifact belongs to (in the above
example the group
- * would be junit). The type of the artifact provides the type (e.g. jar or tar.gz) of the
artifact. The identifier
- * is a unique identifier of the artifact (the unique name). Also the artifact can provide
some version information
- * (3.8.1 in the above example). 
+ * An entity in a repository (e.g. junit-3.8.1.jar). An Artifact has (at least
+ * in the apache.org environment) also a version. Also an Artifact has a
+ * security mechanism, which is nowadays mostly a file with an .asc or (better)
+ * .md5-Extension. The basic attributes of an artifact are the group, this
+ * artifact belongs to (in the above example the group would be junit). The type
+ * of the artifact provides the type (e.g. jar or tar.gz) of the artifact. The
+ * identifier is a unique identifier of the artifact (the unique name). Also the
+ * artifact can provide some version information (3.8.1 in the above example).
  * 
- * @author <a href="http://incubator.apache.org/depot">The Apache Incubator Depot Project</a>
+ * @author <a href="http://incubator.apache.org/depot">The Apache Incubator
+ *         Depot Project </a>
  */
 public class Artifact implements Dumpable {
 
@@ -47,19 +53,19 @@
 			super(ARTIFACT_URI, ARTIFACT_PREFIX, id);
 		}
 	}
-
+
 	private ArtifactGroup m_group = null;
 	private Artifact.Identifier m_identifier = null;
 	private ArtifactType m_type = null;
 	private Version m_version = null;
 
 	/**
-	 * Constructor
-	 * Creates an artifact with the given name as the group of the artifact, as well as
-	 * the identifier of the artifact. The type is set to java-binary. The version is set
-	 * to null.
+	 * Constructor Creates an artifact with the given name as the group of the
+	 * artifact, as well as the identifier of the artifact. The type is set to
+	 * java-binary. The version is set to null.
 	 * 
-	 * @param name Name of the artifact and the group
+	 * @param name
+	 *            Name of the artifact and the group
 	 */
 	public Artifact(String name) {
 		m_group = new ArtifactGroup(name);
@@ -69,13 +75,13 @@
 	}
 
 	/**
-	 * Constructor
-	 * Basically creates an artifact with the attributes of another artifact (pretty much an
-	 * clone)
+	 * Constructor Basically creates an artifact with the attributes of another
+	 * artifact (pretty much an clone)
 	 * 
 	 * :TODO: should be deleted, see the clone method of this class
 	 * 
-	 * @param other another artifact
+	 * @param other
+	 *            another artifact
 	 * @deprecated
 	 */
 	public Artifact(Artifact other) {
@@ -128,7 +134,7 @@
 		m_type = type;
 		m_version = version;
 	}
-	
+
 	/**
 	 * 
 	 * 
@@ -137,8 +143,8 @@
 	 * @param type
 	 * @param version
 	 */
-	public Artifact(ArtifactGroup group, String identifier,
-			ArtifactType type, Version version) {
+	public Artifact(ArtifactGroup group, String identifier, ArtifactType type,
+			Version version) {
 		m_group = group;
 		m_identifier = new Artifact.Identifier(identifier);
 		m_type = type;
@@ -186,7 +192,7 @@
 	public ArtifactGroup getGroup() {
 		return m_group;
 	}
-	
+
 	/*
 	 * (non-Javadoc)
 	 * 
@@ -226,7 +232,7 @@
 
 		if (null != m_version)
 			hash += m_version.hashCode();
-		
+
 		return hash;
 	}
 
@@ -266,16 +272,56 @@
 		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);
+
+			if (verbose)
+				if (m_version instanceof Dumpable)
+					DebugUtils.dump(out, depth + 1, (Dumpable) m_version,
+							verbose);
 		}
 	}
-	
+
 	public Object clone() {
-		Artifact anotherArtifact = new Artifact(this.m_group, 
-							this.m_identifier, this.m_type, this.m_version);
+		Artifact anotherArtifact = new Artifact(this.m_group,
+				this.m_identifier, this.m_type, this.m_version);
 		return anotherArtifact;
+	}
+
+	//
+	//	-----------------------------------------------------------------
+	//
+	public static List getTestArtifactList(String group, int count) {
+		List ArtifactList = new ArrayList();
+
+		// Populate with some test Artifacts...
+		for (int i = 0; i < count; ++i) {
+			String name = group + Integer.toString(1 + i);
+			ArtifactList.add(Artifact.getTestArtifact(name,
+					ApacheVersion.getTestVersion(1, i),
+					ArtifactType.JAVA_BINARY));
+			ArtifactList.add(Artifact.getTestArtifact(name,
+					ApacheVersion.getTestVersion(1, i),
+					ArtifactType.SOURCE_CODE));
+
+			// :TODO: Add some randomness
+		}
+
+		return ArtifactList;
+	}
+
+	public static Artifact getTestArtifact() {
+		return getTestArtifact("test");
+	}
+
+	public static Artifact getTestArtifact(String name) {
+		return getTestArtifact(name, ArtifactType.JAVA_BINARY);
+	}
+
+	public static Artifact getTestArtifact(String name, ArtifactType type) {
+		return getTestArtifact(name, ApacheVersion.getTestVersion(1, 1), type);
+	}
+
+	public static Artifact getTestArtifact(String name, Version version,
+			ArtifactType type) {
+		return new Artifact(name, name, type.toString(), version);
 	}
 }

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	Thu
Jul 29 12:09:41 2004
@@ -17,15 +17,21 @@
 package org.apache.depot.update;
 
 import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.List;
 
 import org.apache.depot.common.util.debug.DebugUtils;
 import org.apache.depot.common.util.debug.Dumpable;
 import org.apache.depot.update.artifact.ArtifactAttributeMap;
 import org.apache.depot.update.artifact.ArtifactLocator;
+import org.apache.depot.update.artifact.ArtifactType;
 import org.apache.depot.update.util.flag.Flag;
 import org.apache.depot.update.util.identity.GenericIdentifier;
+import org.apache.depot.update.util.net.VirtualResourceLocator;
 import org.apache.depot.update.util.reference.IReferenceable;
 import org.apache.depot.update.util.select.ISelectable;
+import org.apache.depot.version.Version;
+import org.apache.depot.version.impl.ApacheVersion;
 
 /**
  * This defines a 'real world' file, e.g. junit-3.8.1.jar and has all the
@@ -211,5 +217,51 @@
 		ArtifactInstance aInstance = new ArtifactInstance((Artifact)this.m_artifact.clone(), 
 					(ArtifactLocator)this.m_locator.clone());
 		return aInstance;
+	}
+	//
+	//	-----------------------------------------------------------------
+	//
+	public static List getTestArtifactList(String group, int count) {
+		List resourceList = new ArrayList();
+
+		// Populate with some test resources...
+		for (int i = 0; i < count; ++i) {
+			String name = group + Integer.toString(1 + i);
+			resourceList.add(ArtifactInstance.getTestArtifactInstance(name,
+					ApacheVersion.getTestVersion(1, i),
+					ArtifactType.JAVA_BINARY));
+			resourceList.add(ArtifactInstance.getTestArtifactInstance(name,
+					ApacheVersion.getTestVersion(1, i),
+					ArtifactType.SOURCE_CODE));
+
+			// :TODO: Add some randomness
+		}
+
+		return resourceList;
+	}
+
+	public static ArtifactInstance getTestArtifactInstance() {
+		return getTestArtifactInstance("test");
+	}
+
+	public static ArtifactInstance getTestArtifactInstance(String name) {
+		return getTestArtifactInstance(name, ArtifactType.JAVA_BINARY);
+	}
+
+	public static ArtifactInstance getTestArtifactInstance(String name,
+			ArtifactType type) {
+		return getTestArtifactInstance(name, ApacheVersion.getTestVersion(1, 1), type);
+	}
+
+	public static ArtifactInstance getTestArtifactInstance(String name,
+			Version version, ArtifactType type) {
+		return getTestArtifactInstance(name,version,type,".test");
+	}
+	public static ArtifactInstance getTestArtifactInstance(String name,
+			Version version, ArtifactType type, String extn) {
+		return new ArtifactInstance(
+				new Artifact("test", name, type, version), 
+				new ArtifactLocator(name,extn,
+						new VirtualResourceLocator("http://somewhere/" + name)));
 	}
 }

Modified: incubator/depot/trunk/update/src/java/org/apache/depot/update/query/QueryEngine.java
==============================================================================
--- incubator/depot/trunk/update/src/java/org/apache/depot/update/query/QueryEngine.java	(original)
+++ incubator/depot/trunk/update/src/java/org/apache/depot/update/query/QueryEngine.java	Thu
Jul 29 12:09:41 2004
@@ -165,10 +165,10 @@
 
 					gsearched += 1;
 					// Look...
-					List resources = repo.listInstances(resourceGroup,
+					List instances = repo.listInstances(resourceGroup,
 							whereClause);
 
-					if (resources.isEmpty()) {
+					if (instances.isEmpty()) {
 						Logger.getLogger().info(
 								Messages.getString(
 										MessageConstants.NO_RESOURCES_FOUND_IN,
@@ -179,10 +179,8 @@
 										MessageConstants.RESOURCES_FOUND_IN,
 										query, repo, resourceGroup));
 
-						//
 						// Do the query
-						// 
-						results.addAll(resources);
+						results.addAll(instances);
 					}
 				}
 

Modified: incubator/depot/trunk/update/src/java/org/apache/depot/update/repository/MockRepository.java
==============================================================================
--- incubator/depot/trunk/update/src/java/org/apache/depot/update/repository/MockRepository.java
(original)
+++ incubator/depot/trunk/update/src/java/org/apache/depot/update/repository/MockRepository.java
Thu Jul 29 12:09:41 2004
@@ -60,9 +60,9 @@
 
 		folderForGroup(group);
 
-		List resourceList = null;// TODO ArtifactInstance.getTestArtifactList(group.getName(),
10);
+		List instanceList = ArtifactInstance.getTestArtifactList(group.getName(), 10);
 
-		results = SelectionHelper.select(resourceList, selector);
+		results = SelectionHelper.select(instanceList, selector);
 
 		return results;
 	}

Modified: incubator/depot/trunk/update/src/java/org/apache/depot/update/util/select/SelectionHelper.java
==============================================================================
--- incubator/depot/trunk/update/src/java/org/apache/depot/update/util/select/SelectionHelper.java
(original)
+++ incubator/depot/trunk/update/src/java/org/apache/depot/update/util/select/SelectionHelper.java
Thu Jul 29 12:09:41 2004
@@ -69,12 +69,26 @@
 		selected = choices;
 	}
 
+	/**
+	 * Select from a list of choices, into a new list
+	 * 
+	 * @param choices the original choices
+	 * @param selector the selection mechanism
+	 * @return  the list of selected choices
+	 */
 	public static List select(List choices, ISelector selector) {
 		List selected = new ArrayList();
 		selectInto(choices, selector, selected);
 		return selected;
 	}
 
+	/**
+	 * Select from a list of choices, into a list
+	 * 
+	 * @param choices the original choices
+	 * @param selector the selection mechanism
+	 * @param selected the selected list
+	 */
 	public static void selectInto(
 		List choices,
 		ISelector selector,

Modified: incubator/depot/trunk/update/src/test/org/apache/depot/update/query/QueryTests.java
==============================================================================
--- incubator/depot/trunk/update/src/test/org/apache/depot/update/query/QueryTests.java	(original)
+++ incubator/depot/trunk/update/src/test/org/apache/depot/update/query/QueryTests.java	Thu
Jul 29 12:09:41 2004
@@ -47,7 +47,7 @@
 	private RepositorySetWrapper m_repoSet = null;
 
 	static {
-		//Logger.testInit();
+		Logger.testInit();
 		UpdaterConfig.configure();
 	}
 
@@ -73,7 +73,7 @@
 		ArtifactQuery query = new ArtifactQuery(new ArtifactGroup("test"));
 		perform(query);
 	}
-	
+	/*
 	public void testQuery2() throws UpdateException {
 		ArtifactQuery query =
 			new ArtifactQuery(
@@ -140,7 +140,7 @@
 		performAndCount(query, 10, 20);
 	}
 
-	private ArtifactResult performAndCountGroups(ArtifactQuery query, int size)
+*/	private ArtifactResult performAndCountGroups(ArtifactQuery query, int size)
 		throws UpdateException {
 		ArtifactResult result = perform(query);
 

Modified: incubator/depot/trunk/update/src/test/org/apache/depot/update/util/io/ResolvedFileTest.java
==============================================================================
--- incubator/depot/trunk/update/src/test/org/apache/depot/update/util/io/ResolvedFileTest.java
(original)
+++ incubator/depot/trunk/update/src/test/org/apache/depot/update/util/io/ResolvedFileTest.java
Thu Jul 29 12:09:41 2004
@@ -28,7 +28,7 @@
 	protected void setUp() throws Exception {
 		super.setUp();
 		fileName = "lib/test.jar";
-		compareValue = SystemUtils.getCWD().getAbsolutePath() + "/" + fileName;
+		compareValue = SystemUtils.getCWD().getAbsolutePath() + File.separator + fileName;
 	}
 	
 	/**
@@ -39,7 +39,7 @@
 		File rf2 = ResolvedFile.resolve(SystemUtils.getCWD().getAbsolutePath());
 		File rf3 = ResolvedFile.resolve(".");
 
-		compareValue = SystemUtils.getCWD().getAbsolutePath() + "/" + fileName; 
+		compareValue = SystemUtils.getCWD().getAbsolutePath() + File.separator + fileName; 
 		
 		assertEquals(compareValue, rf1.getAbsolutePath());
 		assertEquals(SystemUtils.getCWD().getAbsolutePath(), rf2.getAbsolutePath());

Mime
View raw message