krysalis-update/src/test/java/org/apache/depot/update/util/io ResolvedFileTest.java,NONE,1.1 FileTests.java,NONE,1.1
Nick Chalko <[email protected]> Wed, 08 Dec 2004 09:07:14 +0000
| Newsgroups | gmane.comp.krysalis.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/krysalis/krysalis-update/src/test/java/org/apache/depot/update/util/io
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24726/src/test/java/org/apache/depot/update/util/io
Added Files:
ResolvedFileTest.java FileTests.java
Log Message:
Copied from the apache incubator.
--- NEW FILE: ResolvedFileTest.java ---
/*
* Created on Jul 14, 2004
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package org.apache.depot.update.util.io;
import java.io.File;
import org.apache.depot.common.util.SystemUtils;
import junit.framework.TestCase;
/**
* TestCase for the class ResolvedFile
*
* @author <a href="http://incubator.apache.org/depot">The Apache Incubator Depot Project</a>
*/
public class ResolvedFileTest extends TestCase {
String fileName;
String compareValue;
/**
* @see junit.framework.TestCase#setUp()
*/
protected void setUp() throws Exception {
super.setUp();
fileName = "lib/test.jar";
compareValue = SystemUtils.getCWD().getAbsolutePath() + File.separator + fileName;
}
/**
* Class under test for ResolvedFile resolve(Object)
*/
public void testResolveObject() {
File rf1 = ResolvedFile.resolve(fileName);
File rf2 = ResolvedFile.resolve(SystemUtils.getCWD().getAbsolutePath());
File rf3 = ResolvedFile.resolve(".");
compareValue = SystemUtils.getCWD().getAbsolutePath() + File.separator + fileName;
assertEquals(compareValue, rf1.getAbsolutePath());
assertEquals(SystemUtils.getCWD().getAbsolutePath(), rf2.getAbsolutePath());
assertEquals(SystemUtils.getCWD().getAbsolutePath(), rf3.getAbsolutePath());
}
/**
* Class under test for ResolvedFile resolve(Object, Object)
*/
public void testResolveObjectObject() {
File rf1 = ResolvedFile.resolve(SystemUtils.getCWD().getAbsolutePath(), fileName);
assertEquals(compareValue, rf1.getAbsolutePath());
}
}
--- NEW FILE: FileTests.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.io;
import junit.framework.TestCase;
import org.apache.depot.common.util.SystemUtils;
/**
* @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 void testURIsWithColons() throws Exception {
String uri = FileUtils.toURI("X:/Fred");
assertEquals("Equal", "file://X:/Fred", uri);
}
public static void main(String[] args) {
junit.textui.TestRunner.run(FileTests.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/