krysalis-update/src/test/java/org/apache/depot/update/util/net VirtualResourceLocatorTests.java,NONE,1.1

Nick Chalko <[email protected]> Wed, 08 Dec 2004 09:06:51 +0000
Newsgroups gmane.comp.krysalis.cvs
Message-ID <[email protected]>
Update of /cvsroot/krysalis/krysalis-update/src/test/java/org/apache/depot/update/util/net
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24726/src/test/java/org/apache/depot/update/util/net

Added Files:
	VirtualResourceLocatorTests.java 
Log Message:
Copied from the apache incubator.

--- NEW FILE: VirtualResourceLocatorTests.java ---
/*
 * 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.net;

import java.net.URL;

import junit.framework.TestCase;

import org.apache.depot.update.protocols.Protocol;
import org.apache.depot.update.util.io.ResolvedFile;

/**
 * @author arb_jack
 */
public class VirtualResourceLocatorTests extends TestCase {

	private URL m_mavenUrl = null;

	public VirtualResourceLocatorTests(String name) {
		super(name);
	}

	public void setUp() throws Exception {
		m_mavenUrl = new URL("http://www.ibiblio.org/maven/");
	}

	public void testVRLToFromURL() throws Exception {
		VirtualResourceLocator vrl = new VirtualResourceLocator(m_mavenUrl);

		assertEquals(
			"HTTP Protocol",
			Protocol.HTTP_PROTOCOL,
			vrl.getProtocol());
	}

	public void testVRLToFromFile() throws Exception {
		VirtualResourceLocator vrl =
			new VirtualResourceLocator(ResolvedFile.resolve("."));

		assertEquals(
			"File Protocol",
			Protocol.FILE_PROTOCOL,
			vrl.getProtocol());
	}

	public void testVRLToFromMicrosoftFile() throws Exception {
		VirtualResourceLocator vrl =
			new VirtualResourceLocator(ResolvedFile.resolve("X:\\Fred"));

		assertEquals(
			"File Protocol",
			Protocol.FILE_PROTOCOL,
			vrl.getProtocol());
		
		assertEquals(
				"URL",
				"file://X:/Fred",
				vrl.toExternalForm());
	}

	public void testEquals() {
		VirtualResourceLocator vrlFileA =
			new VirtualResourceLocator(ResolvedFile.resolve("."));
		VirtualResourceLocator vrlFileB =
			new VirtualResourceLocator(ResolvedFile.resolve("."));

		assertEquals(
			"Virtual resource locators constructed from same file should be equal",
			vrlFileA,
			vrlFileB);

		VirtualResourceLocator vrlUrlA = new VirtualResourceLocator(m_mavenUrl);
		VirtualResourceLocator vrlUrlB = new VirtualResourceLocator(m_mavenUrl);

		assertEquals(
			"Virtual resource locators constructed from same url should be equal",
			vrlUrlA,
			vrlUrlB);
	}

	public static void main(String[] args) {
		junit.textui.TestRunner.run(VirtualResourceLocatorTests.class);
	}
}



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now. 
http://productguide.itmanagersjournal.com/