mirror of
https://github.com/internetarchive/heritrix3.git
synced 2026-10-05 11:57:43 +00:00
Cleanup/consolidation/expansion of *Utils classes
* IoUtils.java
remove class that confusingly-overlaps with commons IOUtils; move remaining methods to ArchiveUtils or archive's FileUtils
* ArchiveUtils.java, FileUtils.java
receive relocated methods; eliminated deprecated or unused methods
* JSONUtils.java
new class to collect common JSON actions
* Iteratorable.java
wrap Iterator as Iterable for foreach usage
* (many)
update to use alternate utils methods
This commit is contained in:
1 parent
300ce15a06
commit
e42e2ed7f6
21 files changed
+314
-601
No files matched your search
@@ -248,20 +248,20 @@ public class ArchiveUtilsTest extends TestCase {
|
||||
.formatBytesForDisplay(0));
|
||||
assertEquals("1023 bytes", "1,023 B", ArchiveUtils
|
||||
.formatBytesForDisplay(1023));
|
||||
assertEquals("1025 bytes", "1.0 KB", ArchiveUtils
|
||||
assertEquals("1025 bytes", "1.0 KiB", ArchiveUtils
|
||||
.formatBytesForDisplay(1025));
|
||||
// expected display values taken from Google calculator
|
||||
assertEquals("10,000 bytes", "9.8 KB",
|
||||
assertEquals("10,000 bytes", "9.8 KiB",
|
||||
ArchiveUtils.formatBytesForDisplay(10000));
|
||||
assertEquals("1,000,000 bytes", "977 KB",
|
||||
assertEquals("1,000,000 bytes", "977 KiB",
|
||||
ArchiveUtils.formatBytesForDisplay(1000000));
|
||||
assertEquals("100,000,000 bytes", "95 MB",
|
||||
assertEquals("100,000,000 bytes", "95 MiB",
|
||||
ArchiveUtils.formatBytesForDisplay(100000000));
|
||||
assertEquals("100,000,000,000 bytes", "93 GB",
|
||||
assertEquals("100,000,000,000 bytes", "93 GiB",
|
||||
ArchiveUtils.formatBytesForDisplay(100000000000L));
|
||||
assertEquals("100,000,000,000,000 bytes", "91 TB",
|
||||
assertEquals("100,000,000,000,000 bytes", "91 TiB",
|
||||
ArchiveUtils.formatBytesForDisplay(100000000000000L));
|
||||
assertEquals("100,000,000,000,000,000 bytes", "90,949 TB",
|
||||
assertEquals("100,000,000,000,000,000 bytes", "90,949 TiB",
|
||||
ArchiveUtils.formatBytesForDisplay(100000000000000000L));
|
||||
}
|
||||
|
||||
|
||||
@@ -119,17 +119,6 @@ public class FileUtilsTest extends TmpDirTestCase {
|
||||
org.apache.commons.io.FileUtils.deleteQuietly(nakedLastLineWindows);
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void testCopyFiles() throws IOException {
|
||||
FileUtils.copyFiles(this.srcDirFile, this.tgtDirFile);
|
||||
File [] srcFiles = this.srcDirFile.listFiles();
|
||||
for (int i = 0; i < srcFiles.length; i++) {
|
||||
File tgt = new File(this.tgtDirFile, srcFiles[i].getName());
|
||||
assertTrue("Tgt doesn't exist " + tgt.getAbsolutePath(),
|
||||
tgt.exists());
|
||||
}
|
||||
}
|
||||
|
||||
public void testCopyFile() {
|
||||
// Test exception copying nonexistent file.
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
* This file is part of the Heritrix web crawler (crawler.archive.org).
|
||||
*
|
||||
* Licensed to the Internet Archive (IA) by one or more individual
|
||||
* contributors.
|
||||
*
|
||||
* The IA licenses this file to You 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.archive.util;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* @author stack
|
||||
* @version $Date$, $Revision$
|
||||
*/
|
||||
public class IoUtilsTest extends TestCase {
|
||||
|
||||
public void testGetClasspathPath() {
|
||||
final String absUnixPath = "/one/two/three";
|
||||
File f = new File(absUnixPath);
|
||||
assertTrue("Path is wrong abs " + IoUtils.getClasspathPath(f),
|
||||
IoUtils.getClasspathPath(f).equals(absUnixPath));
|
||||
final String relUnixPath = "one/two/three";
|
||||
f = new File(relUnixPath);
|
||||
assertTrue("Path is wrong rel " + IoUtils.getClasspathPath(f),
|
||||
IoUtils.getClasspathPath(f).equals(relUnixPath));
|
||||
final String nameUnixPath = "three";
|
||||
f = new File(nameUnixPath);
|
||||
assertTrue("Path is wrong name " + IoUtils.getClasspathPath(f),
|
||||
IoUtils.getClasspathPath(f).equals(nameUnixPath));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user