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 10435 - in incubator/depot/trunk/update/src: java java/org/apache/depot/update/protocols java/org/apache/depot/update/repository java/org/apache/depot/update/util/io resources/test/repo/junit resources/test/repo/junit/jars resources/test/usecase resources/test/usecase/find resources/test/usecase/find/repo resources/test/usecase/find/repo/gorilla resources/test/usecase/find/repo/gorilla/jars resources/test/usecase/synchronize resources/test/usecase/synchronize/repo resources/test/usecase/synchronize/repo/cat resources/test/usecase/synchronize/repo/cat/jars resources/test/usecase/synchronize/target test/org/apache/depot/update/repository test/org/apache/depot/update/usecases test/org/apache/depot/update/util/io
Date Thu, 29 Apr 2004 22:40:13 GMT
Author: ajack
Date: Thu Apr 29 15:40:12 2004
New Revision: 10435

Added:
   incubator/depot/trunk/update/src/resources/test/repo/junit/
   incubator/depot/trunk/update/src/resources/test/repo/junit/jars/
   incubator/depot/trunk/update/src/resources/test/repo/junit/jars/junit1.0.jar
   incubator/depot/trunk/update/src/resources/test/repo/junit/jars/junit2.0.jar
   incubator/depot/trunk/update/src/resources/test/usecase/
   incubator/depot/trunk/update/src/resources/test/usecase/find/
   incubator/depot/trunk/update/src/resources/test/usecase/find/repo/
   incubator/depot/trunk/update/src/resources/test/usecase/find/repo/gorilla/
   incubator/depot/trunk/update/src/resources/test/usecase/find/repo/gorilla/jars/
   incubator/depot/trunk/update/src/resources/test/usecase/synchronize/
   incubator/depot/trunk/update/src/resources/test/usecase/synchronize/repo/
   incubator/depot/trunk/update/src/resources/test/usecase/synchronize/repo/cat/
   incubator/depot/trunk/update/src/resources/test/usecase/synchronize/repo/cat/jars/
   incubator/depot/trunk/update/src/resources/test/usecase/synchronize/target/
   incubator/depot/trunk/update/src/test/org/apache/depot/update/util/io/
   incubator/depot/trunk/update/src/test/org/apache/depot/update/util/io/FileTests.java
Modified:
   incubator/depot/trunk/update/src/java/depot-update.xml
   incubator/depot/trunk/update/src/java/org/apache/depot/update/protocols/DefaultProtocolOperationsManager.java
   incubator/depot/trunk/update/src/java/org/apache/depot/update/protocols/ProtocolOperationsManager.java
   incubator/depot/trunk/update/src/java/org/apache/depot/update/repository/DefaultRepository.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/io/FileUtils.java
   incubator/depot/trunk/update/src/java/org/apache/depot/update/util/io/ResolvedFile.java
   incubator/depot/trunk/update/src/test/org/apache/depot/update/repository/RepositoryTests.java
   incubator/depot/trunk/update/src/test/org/apache/depot/update/usecases/FindTests.java
   incubator/depot/trunk/update/src/test/org/apache/depot/update/usecases/SynchronizeTests.java
Log:
Getting testing...


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 Apr 29 15:40:12 2004
@@ -38,7 +38,7 @@
 					remote="true"/>
 					
 		<repository id="test" 
-					url="./testrepo"
+					url="./src/resources/test/repo"
 					remote="true"/>
 	</repositoryset>	
 		

Modified: incubator/depot/trunk/update/src/java/org/apache/depot/update/protocols/DefaultProtocolOperationsManager.java
==============================================================================
--- incubator/depot/trunk/update/src/java/org/apache/depot/update/protocols/DefaultProtocolOperationsManager.java
(original)
+++ incubator/depot/trunk/update/src/java/org/apache/depot/update/protocols/DefaultProtocolOperationsManager.java
Thu Apr 29 15:40:12 2004
@@ -24,15 +24,11 @@
 /**
  * @author ajack
  */
-public class DefaultProtocolOperationsManager
-	extends ProtocolOperationsManager {
+public class DefaultProtocolOperationsManager extends ProtocolOperationsManager {
 
-	private static final String VFS_PROVIDER =
-		"org.apache.depot.update.protocols.impl.VfsProtocolOperationsProvider";
-	private static final String HTTP_CLIENT_PROVIDER =
-		"org.apache.depot.update.protocols.impl.HttpClientProtocolOperationsProvider";
-	private static final String URL_PROVIDER =
-		"org.apache.depot.update.protocols.impl.BasicProtocolOperationsProvider";
+	private static final String VFS_PROVIDER = "org.apache.depot.update.protocols.impl.VfsProtocolOperationsProvider";
+	private static final String HTTP_CLIENT_PROVIDER = "org.apache.depot.update.protocols.impl.HttpClientProtocolOperationsProvider";
+	private static final String URL_PROVIDER = "org.apache.depot.update.protocols.impl.BasicProtocolOperationsProvider";
 
 	/**
 	 * @param context
@@ -46,24 +42,18 @@
 		try {
 			ClassLoaderContext loader = new ClassLoaderContext(context);
 
-			IProtocolOperationsProvider provider =
-				(IProtocolOperationsProvider) loader.loadClassWithFallbacks(
-					VFS_PROVIDER,
-					HTTP_CLIENT_PROVIDER,
-					URL_PROVIDER);
+			IProtocolOperationsProvider provider = (IProtocolOperationsProvider) loader.loadClassWithFallbacks(
+					VFS_PROVIDER, HTTP_CLIENT_PROVIDER, URL_PROVIDER);
 
 			registerProvider(provider);
-		}
-		catch (Exception ve) {
+		} catch (Exception ve) {
 			throw new UpdateRuntimeException(
-				"No *Working* Protocol Operation Providers Detected",
-				ve);
+					"No *Working* Protocol Operation Providers Detected", ve);
 		}
 	}
 
 	public static void main(String args[]) {
-		ProtocolOperationsManager pom =
-			new DefaultProtocolOperationsManager(
+		ProtocolOperationsManager pom = new DefaultProtocolOperationsManager(
 				ResourceUpdaterContext.getTestContext());
 
 		DebugUtils.dump(pom);

Modified: incubator/depot/trunk/update/src/java/org/apache/depot/update/protocols/ProtocolOperationsManager.java
==============================================================================
--- incubator/depot/trunk/update/src/java/org/apache/depot/update/protocols/ProtocolOperationsManager.java
(original)
+++ incubator/depot/trunk/update/src/java/org/apache/depot/update/protocols/ProtocolOperationsManager.java
Thu Apr 29 15:40:12 2004
@@ -137,7 +137,9 @@
 	public boolean checkExists(VirtualResourceLocator container)
 		throws Exception {
 		Logger.getLogger().debug("Check EXISTS: " + container);
-		return determineProviderFor(container).exists(container);
+		boolean exists= determineProviderFor(container).exists(container);
+		Logger.getLogger().debug("Check EXISTS: " + container + " returns " + exists);
+		return exists;
 	}
 
 	/**
@@ -226,7 +228,6 @@
 
 	private List determineSourceProviders(String protocol)
 		throws UpdateException {
-		List listOfProviders = null;
 		// set the selector and then pass the providers through the process chain
 		SourceProtocolProviderSelector sourceProtocolSelector =
 			new SourceProtocolProviderSelector(protocol);
@@ -236,7 +237,6 @@
 
 	private List determineDestinationProviders(String protocol)
 		throws UpdateException {
-		List listOfProviders = null;
 		// set the selector and then pass the providers through the process chain
 		DestinationProtocolProviderSelector destinationProtocolSelector =
 			new DestinationProtocolProviderSelector(protocol);
@@ -248,7 +248,6 @@
 		String srcProtocol,
 		String destProtocol)
 		throws UpdateException {
-		List listOfProviders = null;
 		// set the selector and then pass the providers through the process chain
 		SourceDestinationProtocolProviderSelector srcDestProtocolSelector =
 			new SourceDestinationProtocolProviderSelector(
@@ -283,7 +282,7 @@
 		providers.add(p);
 	}
 
-	private List join(List list1, List list2) {
+	/*private List join(List list1, List list2) {
 		List join = new ArrayList();
 
 		for (Iterator i = list1.iterator(); i.hasNext();) {
@@ -294,10 +293,10 @@
 		}
 
 		return join;
-	}
+	}*/
 
 	public void dump(PrintWriter out, int depth, boolean verbose) {
-		String indent = DebugUtils.getIndent(depth);
+		//String indent = DebugUtils.getIndent(depth);
 		String indent1 = DebugUtils.getIndent(depth + 1);
 
 		dumpRegistry(out, indent1, "Source Protocols", m_sourceProtocolMap);

Modified: incubator/depot/trunk/update/src/java/org/apache/depot/update/repository/DefaultRepository.java
==============================================================================
--- incubator/depot/trunk/update/src/java/org/apache/depot/update/repository/DefaultRepository.java
(original)
+++ incubator/depot/trunk/update/src/java/org/apache/depot/update/repository/DefaultRepository.java
Thu Apr 29 15:40:12 2004
@@ -19,6 +19,7 @@
 import java.util.List;
 
 import org.apache.depot.common.log.Logger;
+import org.apache.depot.common.util.SystemUtils;
 import org.apache.depot.update.impl.ReferenceManager;
 import org.apache.depot.update.impl.ResourceUpdaterContext;
 import org.apache.depot.update.resource.Resource;
@@ -37,8 +38,7 @@
  * @author arb_jack
  */
 public class DefaultRepository extends AbstractHierarchicalRepository {
-	public static final String DEFAULT_REPOSITORY_CLASSNAME =
-		DefaultRepository.class.getName();
+	public static final String DEFAULT_REPOSITORY_CLASSNAME = DefaultRepository.class.getName();
 
 	DefaultRepository(String id) {
 		super(id);
@@ -48,10 +48,8 @@
 		super(id, new VirtualResourceLocator(root));
 	}
 
-	public DefaultRepository(
-		String id,
-		final String root,
-		final boolean hierarchical) {
+	public DefaultRepository(String id, final String root,
+			final boolean hierarchical) {
 		super(id, new VirtualResourceLocator(root), hierarchical);
 	}
 
@@ -59,10 +57,8 @@
 		super(id, new VirtualResourceLocator(root));
 	}
 
-	public DefaultRepository(
-		String id,
-		final ResolvedFile root,
-		final boolean hierarchical) {
+	public DefaultRepository(String id, final ResolvedFile root,
+			final boolean hierarchical) {
 		super(id, new VirtualResourceLocator(root), hierarchical);
 	}
 
@@ -70,49 +66,41 @@
 		super(id, root);
 	}
 
-	public DefaultRepository(
-		String id,
-		final VirtualResourceLocator root,
-		final boolean hierarchical) {
+	public DefaultRepository(String id, final VirtualResourceLocator root,
+			final boolean hierarchical) {
 		super(id, root, hierarchical);
 	}
 
 	public List listGroups(ResourceUpdaterContext context, ISelector selector)
-		throws Exception {
+			throws Exception {
 
 		List results = null;
 
 		if (context.getProtocolManager().checkExists(getRepositoryRoot())) {
 
-			List groupVRLs =
-				context.getProtocolManager().performList(
+			List groupVRLs = context.getProtocolManager().performList(
 					getRepositoryRoot(),
-					new AndSelector(
-						new ChildVrlSelector(getRepositoryRoot()),
-						selector));
+					new AndSelector(new ChildVrlSelector(getRepositoryRoot()),
+							selector));
 
 			if (!groupVRLs.isEmpty()) {
 
-				List analyzedGroupList =
-					getGroupAnalyzer().determineGroups(groupVRLs);
+				List analyzedGroupList = getGroupAnalyzer().determineGroups(
+						groupVRLs);
 
 				results = SelectionHelper.select(analyzedGroupList, selector);
-			}
-			else
+			} else
 				results = UpdateConstants.EMPTY_LIST;
 
-		}
-		else
+		} else
 			results = UpdateConstants.EMPTY_LIST;
 
 		return results;
 	}
 
-	public List listResources(
-		final ResourceUpdaterContext context,
-		final ResourceGroup group,
-		final ISelector selector)
-		throws Exception {
+	public List listResources(final ResourceUpdaterContext context,
+			final ResourceGroup group, final ISelector selector)
+			throws Exception {
 
 		List results = null;
 
@@ -123,60 +111,49 @@
 			// List the container (by Selector)
 			// Convert to Resources
 			// Select the right ones...
-			List resourceList =
-				context.getProtocolManager().performList(
-					container,
-					new ChildVrlSelector(container));
+			List resourceList = context.getProtocolManager().performList(
+					container, new ChildVrlSelector(container));
 
-			List analyzedGroupList =
-				getAnalyzer().determineResources(resourceList);
+			List analyzedGroupList = getAnalyzer().determineResources(
+					resourceList);
 
 			results = SelectionHelper.select(analyzedGroupList, selector);
-		}
-		else
+		} else
 			results = UpdateConstants.EMPTY_LIST;
 
 		return results;
 	}
 
-	public Resource publishResource(
-		ResourceUpdaterContext context,
-		Resource resource)
-		throws Exception {
+	public Resource publishResource(ResourceUpdaterContext context,
+			Resource resource) throws Exception {
 
 		// Create the 'remote' resource
 		Resource publishedResource = new Resource(resource);
-		publishedResource.setLocation(
-			new VirtualResourceLocator(
-				folderForGroup(resource.getGroup()),
-				resource.getFilename()));
+		publishedResource.setLocation(new VirtualResourceLocator(
+				folderForGroup(resource.getGroup()), resource.getFilename()));
 
 		// Perform copy
-		context.getProtocolManager().performCopy(
-			resource.getLocation(),
-			publishedResource.getLocation(),
-			AllSelector.getInstance());
+		context.getProtocolManager().performCopy(resource.getLocation(),
+				publishedResource.getLocation(), AllSelector.getInstance());
 
 		return publishedResource;
 	}
 
-	public void deleteResource(
-		ResourceUpdaterContext context,
-		Resource resource)
-		throws Exception {
+	public void deleteResource(ResourceUpdaterContext context, Resource resource)
+			throws Exception {
 
 		// Perform copy
-		context.getProtocolManager().performDelete(
-			resource.getLocation(),
-			AllSelector.getInstance());
+		context.getProtocolManager().performDelete(resource.getLocation(),
+				AllSelector.getInstance());
 	}
 
 	public static IRepository getLocalTestRepository() {
 		return new DefaultRepository(
-			"test",
-			new VirtualResourceLocator(
-				new VirtualResourceLocator(ResolvedFile.resolve(".")),
-				"src/resource/test/testrepo"));
+				"test",
+				new VirtualResourceLocator(
+						new VirtualResourceLocator(
+								ResolvedFile.resolve(SystemUtils.getCWD().getAbsolutePath())),
+						"src/resources/test/repo"));
 	}
 
 	public static IRepository getRepository(String identifier) {
@@ -184,29 +161,25 @@
 		return getRepository(new RepositoryIdentifier(identifier), false);
 	}
 
-	public static IRepository getRepository(
-		String identifier,
-		final boolean createIfRequired) {
-
-		return getRepository(
-			new RepositoryIdentifier(identifier),
-			createIfRequired);
+	public static IRepository getRepository(String identifier,
+			final boolean createIfRequired) {
+
+		return getRepository(new RepositoryIdentifier(identifier),
+				createIfRequired);
 	}
 
-	public static IRepository getRepository(
-		RepositoryIdentifier identifier,
-		final boolean createIfRequired) {
+	public static IRepository getRepository(RepositoryIdentifier identifier,
+			final boolean createIfRequired) {
 
 		IRepository repo = null;
 
 		if (ReferenceManager.hasReference(identifier)) {
 			try {
 				repo = (IRepository) ReferenceManager.getReference(identifier);
-			}
-			catch (NoSuchReferenceException exp) {
+			} catch (NoSuchReferenceException exp) {
 				Logger.getLogger().error(
-					"No Repository reference in the RefMgr ",
-					exp);
+						"No Repository reference in the ReferenceManager: ",
+						exp);
 			}
 		}
 

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 Apr 29 15:40:12 2004
@@ -31,17 +31,14 @@
  */
 public class MockRepository extends AbstractHierarchicalRepository {
 
-	private final static List EMPTY_LIST = new ArrayList();
+	//private final static List EMPTY_LIST = new ArrayList();
 
 	MockRepository(String id) {
-		super(
-			id,
-			new VirtualResourceLocator("http://mockrepo.org/stuff"),
-			true);
+		super(id, new VirtualResourceLocator("http://mockrepo.org/stuff"), true);
 	}
 
 	public List listGroups(ResourceUpdaterContext context, ISelector selector)
-		throws Exception {
+			throws Exception {
 
 		List groups = new ArrayList();
 
@@ -53,36 +50,34 @@
 		return groups;
 	}
 
-	public List listResources(
-		final ResourceUpdaterContext context,
-		final ResourceGroup group,
-		final ISelector selector)
-		throws Exception {
+	public List listResources(final ResourceUpdaterContext context,
+			final ResourceGroup group, final ISelector selector)
+			throws Exception {
 
 		List results = null;
 
 		VirtualResourceLocator container = folderForGroup(group);
 
 		List resourceList = Resource.getTestResourceList(group.getGroup(), 10);
-		
+
 		results = SelectionHelper.select(resourceList, selector);
 
 		return results;
 	}
 
-	public Resource publishResource(
-		ResourceUpdaterContext context,
-		Resource resource)
-		throws Exception {
+	public Resource publishResource(ResourceUpdaterContext context,
+			Resource resource) throws Exception {
 
 		Resource publishedResource = new Resource(resource);
 
-		publishedResource.setLocation(
-			new VirtualResourceLocator(
-				folderForGroup(resource.getGroup()),
-				resource.getFilename()));
+		publishedResource.setLocation(new VirtualResourceLocator(
+				folderForGroup(resource.getGroup()), resource.getFilename()));
 
 		return publishedResource;
+	}
+	
+	public void initialize(ResourceUpdaterContext context) throws Exception {
+		
 	}
 
 	public static IRepository getMockRepository() {

Modified: incubator/depot/trunk/update/src/java/org/apache/depot/update/util/io/FileUtils.java
==============================================================================
--- incubator/depot/trunk/update/src/java/org/apache/depot/update/util/io/FileUtils.java	(original)
+++ incubator/depot/trunk/update/src/java/org/apache/depot/update/util/io/FileUtils.java	Thu
Apr 29 15:40:12 2004
@@ -46,22 +46,8 @@
 		isSpecial[0x7f] = true;
 		escapedChar1[0x7f] = '7';
 		escapedChar2[0x7f] = 'F';
-		char[] escChs =
-			{
-				'<',
-				'>',
-				'#',
-				'%',
-				'"',
-				'{',
-				'}',
-				'|',
-				'\\',
-				'^',
-				'~',
-				'[',
-				']',
-				'`' };
+		char[] escChs = {'<', '>', '#', '%', '"', '{', '}', '|', '\\', '^',
+				'~', '[', ']', '`'};
 		int len = escChs.length;
 		char ch;
 		for (int i = 0; i < len; i++) {
@@ -72,39 +58,38 @@
 		}
 	}
 
-	public static URL getFileURL(File file)  {
+	public static URL getFileURL(File file) {
 		URL url = null;
-		
+
 		String str = null;
-		try
-		{
+		try {
 			str = toURI(file.getAbsolutePath());
-			
-			url= new URL(str);
-		}
-		catch (MalformedURLException e) {
+
+			url = new URL(str);
+		} catch (MalformedURLException e) {
 			//:TODO: Ought never happen, so it is a bug on
 			// us ..
-			
-			throw new UpdateRuntimeException("Bogus: " + str, e);	
+			throw new UpdateRuntimeException("Bogus: " + str, e);
 		}
-		
+
 		return url;
 	}
 
 	public static String toURI(String path) {
 		return toURI(new File(path));
 	}
-	
-	public static String toURI(File path){
+
+	public static String toURI(File path) {
 		boolean isDir = path.isDirectory();
-		
+
 		String pathString = path.getAbsolutePath();
 
 		StringBuffer sb = new StringBuffer(UpdateConstants.FILE_PREFIX);
 
 		// add an extra slash for filesystems with drive-specifiers
-		if (!pathString.startsWith(File.separator)) {
+		//:TODO: determine if too dodgy.
+		if (!pathString.startsWith(File.separator)
+				&& (-1 != pathString.indexOf(":"))) {
 			sb.append("/");
 		}
 
@@ -117,39 +102,36 @@
 		// Escaping..
 		//
 		CharacterIterator iter = new StringCharacterIterator(pathString);
-		for (char c = iter.first();
-			c != CharacterIterator.DONE;
-			c = iter.next()) {
+		for (char c = iter.first(); c != CharacterIterator.DONE; c = iter.next()) {
 			if (isSpecial[c]) {
 				sb.append('%');
 				sb.append(escapedChar1[c]);
 				sb.append(escapedChar2[c]);
-			}
-			else {
+			} else {
 				sb.append(c);
 			}
 		}
-		
+
 		//
 		// Ensure directories end with a /
 		//
 		if (isDir && !pathString.endsWith("/")) {
 			sb.append('/');
 		}
-		
+
 		return sb.toString();
 	}
 
 	/**
-	 * Transfer all the data from one file to file. 
-	 * Does NOT delete the output file on exception.
+	 * Transfer all the data from one file to file. Does NOT delete the output
+	 * file on exception.
 	 * 
 	 * @param inputFile
 	 * @param outputFile
 	 * @throws IOException
 	 */
 	public static void transfer(File inputFile, File outputFile)
-		throws IOException {
+			throws IOException {
 		FileInputStream input = null;
 
 		try {
@@ -161,12 +143,10 @@
 				output = new FileOutputStream(outputFile);
 
 				IOUtils.transfer(input, output);
-			}
-			finally {
+			} finally {
 				IOUtils.close(output);
 			}
-		}
-		finally {
+		} finally {
 			IOUtils.close(input);
 		}
 	}

Modified: incubator/depot/trunk/update/src/java/org/apache/depot/update/util/io/ResolvedFile.java
==============================================================================
--- incubator/depot/trunk/update/src/java/org/apache/depot/update/util/io/ResolvedFile.java
(original)
+++ incubator/depot/trunk/update/src/java/org/apache/depot/update/util/io/ResolvedFile.java
Thu Apr 29 15:40:12 2004
@@ -28,16 +28,17 @@
 	private Object m_originalInput = null;
 	private Object m_resolverContext = null;
 
-	private ResolvedFile(
-		Object resolveContext,
-		Object originalInput,
-		File fullyQualified) {
+	private ResolvedFile(Object resolverContext, Object originalInput,
+			File fullyQualified) {
 		super(fullyQualified.getAbsolutePath());
+
+		m_resolverContext = resolverContext;
+		m_originalInput = originalInput;
 	}
 
-//
-// Resolve in JVM 'current working directory' context.
-//
+	//
+	// Resolve in JVM 'current working directory' context.
+	//
 	public static ResolvedFile resolve(Object file) {
 		return resolve(SystemUtils.getCWD(), file);
 	}
@@ -46,9 +47,7 @@
 
 		// Previously resolved within this context...
 		if ((file instanceof ResolvedFile)
-			&& (((ResolvedFile) file)
-				.m_resolverContext
-				.equals(m_resolverContext)))
+				&& (((ResolvedFile) file).m_resolverContext.equals(m_resolverContext)))
 			return (ResolvedFile) file;
 
 		// Extract a 'path' (local or absolute) from this thing
@@ -58,27 +57,32 @@
 		else if (file instanceof String)
 			path = (String) file;
 		else {
-			throw new IllegalArgumentException(
-				"Unable to resolve " + file.getClass().getName());
+			throw new IllegalArgumentException("Unable to resolve "
+					+ file.getClass().getName());
 		}
 
 		File pathFile = new File(path);
 
-		// Get a fully qualified file 
+		// Get a fully qualified file
 		File fullyQualified = null;
 		if (pathFile.isAbsolute()) {
 			fullyQualified = pathFile;
-		}
-		else {
+		} else {
 			if (m_resolverContext instanceof File)
-				fullyQualified = new File((File) m_resolverContext, path);
+				if (".".equals(path)) {
+					fullyQualified = (File) m_resolverContext;
+				} else
+					fullyQualified = new File((File) m_resolverContext, path);
 			else if (m_resolverContext instanceof String)
-				fullyQualified =
-					new File(new File((String) m_resolverContext), path);
+				if (".".equals(path)) {
+					fullyQualified = new File((String) m_resolverContext);
+				} else
+					fullyQualified = new File(new File(
+							(String) m_resolverContext), path);
 			else {
 				throw new IllegalArgumentException(
-					"Unable to resolve using context "
-						+ m_resolverContext.getClass().getName());
+						"Unable to resolve using context "
+								+ m_resolverContext.getClass().getName());
 			}
 
 		}
@@ -86,6 +90,20 @@
 		return new ResolvedFile(m_resolverContext, file, fullyQualified);
 	}
 
+	/**
+	 * @return Returns the originalInput.
+	 */
+	public Object getOriginalInput() {
+		return m_originalInput;
+	}
+
+	/**
+	 * @return Returns the resolverContext.
+	 */
+	public Object getResolverContext() {
+		return m_resolverContext;
+	}
+
 	public static void main(String args[]) {
 		String file = "lib/test.jar";
 
@@ -93,9 +111,11 @@
 			file = args[0];
 
 		File rf1 = ResolvedFile.resolve(file);
-		File rf2 =
-			ResolvedFile.resolve(SystemUtils.getCWD().getAbsolutePath(), file);
+
+		File rf2 = ResolvedFile.resolve(SystemUtils.getCWD().getAbsolutePath(),
+				file);
 		File rf3 = ResolvedFile.resolve(SystemUtils.getCWD().getAbsolutePath());
+		File rf4 = ResolvedFile.resolve(".");
 
 		System.out.println("RF1:" + rf1.toString());
 		System.out.println("RF1:" + rf1.getAbsolutePath());
@@ -103,6 +123,27 @@
 		System.out.println("RF2:" + rf2.getAbsolutePath());
 		System.out.println("RF3:" + rf3.toString());
 		System.out.println("RF3:" + rf3.getAbsolutePath());
+		System.out.println("RF4:" + rf4.toString());
+		System.out.println("RF4:" + rf4.getAbsolutePath());
+
+	}
 
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see java.lang.Object#toString()
+	 */
+	public String toString() {
+		StringBuffer buf = new StringBuffer();
+		buf.append(m_resolverContext.getClass().toString());
+		buf.append(" [");
+		buf.append(m_resolverContext.toString());
+		buf.append("] : ");
+		buf.append(m_originalInput.getClass().toString());
+		buf.append(" [");
+		buf.append(m_originalInput.toString());
+		buf.append("] : ");
+		buf.append(super.toString());
+		return buf.toString();
 	}
 }

Added: incubator/depot/trunk/update/src/resources/test/repo/junit/jars/junit1.0.jar
==============================================================================

Added: incubator/depot/trunk/update/src/resources/test/repo/junit/jars/junit2.0.jar
==============================================================================

Modified: incubator/depot/trunk/update/src/test/org/apache/depot/update/repository/RepositoryTests.java
==============================================================================
--- incubator/depot/trunk/update/src/test/org/apache/depot/update/repository/RepositoryTests.java
(original)
+++ incubator/depot/trunk/update/src/test/org/apache/depot/update/repository/RepositoryTests.java
Thu Apr 29 15:40:12 2004
@@ -46,9 +46,10 @@
 
 		Logger.testInit();
 
-		m_repo1 = new RepositoryWrapper(DefaultRepository
-				.getLocalTestRepository(), ResourceUpdaterContext
-				.getTestContext());
+		m_repo1 = new RepositoryWrapper(
+				DefaultRepository.getLocalTestRepository(),
+				ResourceUpdaterContext.getTestContext());
+
 		m_repo2 = new RepositoryWrapper(MockRepository.getMockRepository(),
 				ResourceUpdaterContext.getTestContext());
 	}
@@ -69,13 +70,11 @@
 	public void testListResources1() throws Exception {
 		ResourceGroup testGroup = new ResourceGroup("junit");
 
-		List list1 = m_repo1
-				.listResources(testGroup, AllSelector.getInstance());
+		List list1 = m_repo1.listResources(testGroup, AllSelector.getInstance());
 		assertNotNull("List Resources", list1);
 		assertFalse("List Resources not Empty", list1.isEmpty());
 
-		List list2 = m_repo2
-				.listResources(testGroup, AllSelector.getInstance());
+		List list2 = m_repo2.listResources(testGroup, AllSelector.getInstance());
 		assertNotNull("List Resources", list2);
 		assertFalse("List Resources not Empty", list2.isEmpty());
 
@@ -86,10 +85,16 @@
 	public void testListSpecifiers1() throws Exception {
 		ResourceGroup testGroup = new ResourceGroup("junit");
 
-		assertNotNull("List Specifiers", m_repo1.listSpecifiers(testGroup,
-				AllSelector.getInstance()));
-		assertNotNull("List Specifiers", m_repo2.listSpecifiers(testGroup,
-				AllSelector.getInstance()));
+		List specifiers1 = m_repo1.listSpecifiers(testGroup,
+				AllSelector.getInstance());
+
+		assertNotNull("List Specifiers", specifiers1);
+		assertFalse("List Specifiers Not Empty", specifiers1.isEmpty());
+
+		List specifiers2 = m_repo2.listSpecifiers(testGroup,
+				AllSelector.getInstance());
+		assertNotNull("List Specifiers", specifiers2);
+		assertFalse("List Specifiers Not Empty", specifiers2.isEmpty());
 	}
 
 	public static void main(String[] args) {

Modified: incubator/depot/trunk/update/src/test/org/apache/depot/update/usecases/FindTests.java
==============================================================================
--- incubator/depot/trunk/update/src/test/org/apache/depot/update/usecases/FindTests.java
(original)
+++ incubator/depot/trunk/update/src/test/org/apache/depot/update/usecases/FindTests.java
Thu Apr 29 15:40:12 2004
@@ -35,7 +35,7 @@
 import org.apache.depot.update.util.net.VirtualResourceLocator;
 
 public class FindTests extends TestCase {
-	private ResolvedFile m_repoDir = ResolvedFile.resolve("src/resource/test/usecase/find/repo");
+	private ResolvedFile m_repoDir = ResolvedFile.resolve("src/resources/test/usecase/find/repo");
 	private FileHelper m_fileHelper = new FileHelper();
 
 	protected void setUp() {

Modified: incubator/depot/trunk/update/src/test/org/apache/depot/update/usecases/SynchronizeTests.java
==============================================================================
--- incubator/depot/trunk/update/src/test/org/apache/depot/update/usecases/SynchronizeTests.java
(original)
+++ incubator/depot/trunk/update/src/test/org/apache/depot/update/usecases/SynchronizeTests.java
Thu Apr 29 15:40:12 2004
@@ -31,8 +31,8 @@
 import org.apache.depot.update.repository.RepositorySet;
 
 public class SynchronizeTests extends TestCase {
-	File m_repoDir = new File("src/resource/test/usecase/synchronize/repo");
-	File m_targetDir = new File("src/resource/test/usecase/synchronize/target");
+	File m_repoDir = new File("src/resources/test/usecase/synchronize/repo");
+	File m_targetDir = new File("src/resources/test/usecase/synchronize/target");
 	FileHelper m_fileHelper = new FileHelper();
 
 	protected void setUp() {

Added: incubator/depot/trunk/update/src/test/org/apache/depot/update/util/io/FileTests.java
==============================================================================
--- (empty file)
+++ incubator/depot/trunk/update/src/test/org/apache/depot/update/util/io/FileTests.java	Thu
Apr 29 15:40:12 2004
@@ -0,0 +1,65 @@
+/*
+ * 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.util.io;
+
+import org.apache.depot.common.util.SystemUtils;
+
+import junit.framework.TestCase;
+
+/**
+ * @author arb_jack
+ */
+public class FileTests extends TestCase {
+
+	public FileTests(String name) {
+		super(name);
+	}
+
+	public void testDotFile() throws Exception {
+		ResolvedFile file = ResolvedFile.resolve(".");
+
+		assertTrue("File . Exists", file.exists());
+		assertTrue("File . Is Directory", file.isDirectory());
+		assertTrue("File . Is Absolute", file.isAbsolute());
+	}
+
+	public void testCWDFile() throws Exception {
+		ResolvedFile file = ResolvedFile.resolve(SystemUtils.getCWD().getAbsoluteFile());
+
+		assertTrue("File $CWD Exists", file.exists());
+		assertTrue("File $CWD Is Directory", file.isDirectory());
+		assertTrue("File $CWD Is Absolute", file.isAbsolute());
+	}
+
+	public void testEquiv() throws Exception {
+		ResolvedFile file1 = ResolvedFile.resolve(".");
+		ResolvedFile file2 = ResolvedFile.resolve(SystemUtils.getCWD().getAbsoluteFile());
+
+		assertEquals("Equal", file1, file2);
+	}
+
+	public void testURIs() throws Exception {
+		String uri1 = FileUtils.toURI(ResolvedFile.resolve("."));
+		String uri2 = FileUtils.toURI(ResolvedFile.resolve(SystemUtils.getCWD().getAbsoluteFile()));
+
+		assertEquals("Equal", uri1, uri2);
+	}
+
+	public static void main(String[] args) {
+		junit.textui.TestRunner.run(FileTests.class);
+	}
+}

Mime
View raw message