ZipFSTester.java revision 6086
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* Tests various zipfs operations.
*/
public class ZipFSTester {
{
}
}
throws Exception
{
while (zes.hasMoreElements()) {
}
throw new RuntimeException("path existence check failed!");
throw new RuntimeException("parent existence check failed!");
}
}
}
}
throws Exception
{
// clone a fs and test on it
}
// newFileSystem(path...) should not throw exception
{
throw new RuntimeException("newFileSystem(uri...) does not throw exception");
} catch (FileSystemAlreadyExistsException fsaee) {}
// prepare a src
byte[] bits = new byte[12345];
try {
throw new RuntimeException("newFileSystem() opens a directory as zipfs");
} catch (UnsupportedOperationException uoe) {}
try {
throw new RuntimeException("newFileSystem() opens a non-zip file as zipfs");
} catch (UnsupportedOperationException uoe) {}
// copyin
// copy
//dst.moveTo(dst2);
// delete
throw new RuntimeException("Failed!");
// moveout
// delete
throw new RuntimeException("Failed!");
throw new RuntimeException("Failed!");
// newInputStream on dir
try {
throw new RuntimeException("Failed");
} catch (FileSystemException e) {
e.printStackTrace(); // expected fse
}
// rmdirs
try {
} catch (IOException x) {
x.printStackTrace();
}
// newFileChannel() copy in, out and verify via fch
// test channels
} finally {
}
}
// create a new filesystem, copy everything from fs
public void run() {
try {
} catch (Exception x) {
x.printStackTrace();
}
}
}
});
public void run() {
try {
} catch (Exception x) {
x.printStackTrace();
}
}
}
});
public void run() {
try {
} catch (Exception x) {
x.printStackTrace();
}
}
}
});
public void run() {
try {
}
} catch (FileAlreadyExistsException x){
} catch (Exception x) {
x.printStackTrace();
}
}
}
}
});
int failed = 0;
try {
} catch (IOException x) {
//x.printStackTrace();
failed++;
}
}
}
}
throws Exception
{
return FileSystems.newFileSystem(
}
{
}
throws IOException
{
}
} else {
}
}
int method)
throws IOException
{
try {
} catch (FileAlreadyExistsException x) {}
}
method);
}
}
} else {
try {
return;
switch (method) {
case 0:
break;
case 1:
break;
case 2:
//fchCopy(srcPath, dstPath);
break;
}
} catch (FileAlreadyExistsException x) {}
}
}
throws IOException
{
}
}
} else {
//System.out.println("moving..." + path);
}
}
{
path,
new SimpleFileVisitor<Path>() {
private int indent = 0;
private void indent() {
int n = 0;
while (n++ < indent)
}
{
indent();
return FileVisitResult.CONTINUE;
}
{
indent();
indent += 2;
return FileVisitResult.CONTINUE;
}
throws IOException
{
indent -= 2;
return FileVisitResult.CONTINUE;
}
});
}
return;
}
}
}
}
// check the content of two paths are equal
{
//System.out.printf("checking <%s> vs <%s>...%n",
// src.toString(), dst.toString());
//streams
byte[] bufSrc = new byte[8192];
byte[] bufDst = new byte[8192];
{
int nSrc = 0;
int nDst = 0;
if (n == -1) {
throw new RuntimeException("CHECK FAILED!");
}
nDst += n;
}
while (--nSrc >= 0) {
throw new RuntimeException("CHECK FAILED!");
}
nSrc--;
}
}
}
// channels
{
throw new RuntimeException("CHECK FAILED!");
}
int nSrc = 0;
throw new RuntimeException("CHECK FAILED!");
}
while (--nSrc >= 0) {
throw new RuntimeException("CHECK FAILED!");
}
nSrc--;
}
}
// Check if source read position is at the end
throw new RuntimeException("CHECK FAILED!");
}
// Check if destination read position is at the end
throw new RuntimeException("CHECK FAILED!");
}
} catch (IOException x) {
x.printStackTrace();
}
}
{
.provider()
.provider()
{
}
}
}
{
{
}
// Check if source read position is at the end
throw new RuntimeException("CHECK FAILED!");
}
// Check if destination write position is at the end
throw new RuntimeException("CHECK FAILED!");
}
}
}
{
byte[] buf = new byte[8192];
{
int n = 0;
}
}
}
throws Exception
{
int n = 0;
int N = 120;
throw new RuntimeException("CHECK FAILED!");
}
throw new RuntimeException("CHECK FAILED!");
}
}
// sbc.position(pos) is not supported in current version
// try the FileChannel
throw new RuntimeException("CHECK FAILED!");
}
throw new RuntimeException("CHECK FAILED!");
}
}
}
// create parents if does not exist
throws Exception
{
return path;
}
}