changeset 2028:fa2afb1da3a0

Added unit test for zip provider path operations Fixed regression so that isDirectory returns true for directories
author alanb
date Thu, 03 Dec 2009 19:44:04 +0000
parents a2cbf3efeaa1
children a11b4063024f
files src/share/demo/nio/ZipFileSystem/com/sun/nio/zipfs/ZipUtils.java test/demo/nio/ZipFileSystem/Basic.java test/demo/nio/ZipFileSystem/PathOps.java test/demo/nio/ZipFileSystem/Sanity.java test/demo/nio/ZipFileSystem/basic.sh test/demo/nio/ZipFileSystem/sanity.sh
diffstat 6 files changed, 642 insertions(+), 226 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/demo/nio/ZipFileSystem/com/sun/nio/zipfs/ZipUtils.java	Thu Dec 03 19:36:54 2009 +0000
+++ b/src/share/demo/nio/ZipFileSystem/com/sun/nio/zipfs/ZipUtils.java	Thu Dec 03 19:44:04 2009 +0000
@@ -200,10 +200,11 @@
                     filenameLen + extraFieldLen + commentLen;
 
             ZipFilePath entryPath = null;
-            entryPath = zipPath.resolve(new String(ze.filename));
 
+            String fn = new String(ze.filename);
+            entryPath = zipPath.resolve(fn);
             ze.isArchiveFile = entryPath.isArchiveFile();
-            ze.isDirectory = (entryPath.toString().endsWith("/") ? true : false);
+            ze.isDirectory = fn.endsWith("/");
             ze.isRegularFile = !ze.isDirectory;
             if (isJar) {
                 jentry = new JarEntryInfo(ze);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/demo/nio/ZipFileSystem/Basic.java	Thu Dec 03 19:44:04 2009 +0000
@@ -0,0 +1,153 @@
+/*
+ * Copyright 2007-2008 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+import java.nio.file.*;
+import java.nio.file.attribute.*;
+import java.nio.file.spi.FileSystemProvider;
+import java.util.*;
+import java.net.URI;
+import java.io.IOException;
+
+/**
+ * Basic test for zip provider
+ */
+
+public class Basic {
+    public static void main(String[] args) throws Exception {
+        Path zipfile = Paths.get(args[0]);
+
+        // Test: zip should should be returned in provider list
+        boolean found = false;
+        for (FileSystemProvider provider: FileSystemProvider.installedProviders()) {
+            if (provider.getScheme().equalsIgnoreCase("zip")) {
+                found = true;
+                break;
+            }
+        }
+        if (!found)
+            throw new RuntimeException("'zip' provider not installed");
+
+        // Test: FileSystems#newFileSystem(FileRef)
+        Map<String,?> env = new HashMap<String,Object>();
+        FileSystems.newFileSystem(zipfile, env, null).close();
+
+        // Test: FileSystems#newFileSystem(URI)
+        URI uri = URI.create("zip" + zipfile.toUri().toString().substring(4));
+        FileSystem fs = FileSystems.newFileSystem(uri, env, null);
+
+        // Test: exercise toUri method
+        String expected = uri.toString() + "#/foo";
+        String actual = fs.getPath("/foo").toUri().toString();
+        if (!actual.equals(expected)) {
+            throw new RuntimeException("toUri returned '" + actual +
+                "', expected '" + expected + "'");
+        }
+
+        // Test: exercise directory iterator and retrieval of basic attributes
+        Files.walkFileTree(fs.getPath("/"), new FileTreePrinter());
+
+        // Test: DirectoryStream
+        found = false;
+        DirectoryStream<Path> stream = fs.getPath("/").newDirectoryStream();
+        try {
+            for (Path entry: stream) {
+                found = entry.toString().equals("/META-INF");
+                if (found) break;
+            }
+        } finally {
+            stream.close();
+        }
+        if (!found)
+            throw new RuntimeException("Expected file not found");
+
+        // Test: copy file from zip file to current (scratch) directory
+        Path source = fs.getPath("/META-INF/services/java.nio.file.spi.FileSystemProvider");
+        if (source.exists()) {
+            Path target = Paths.get(source.getName().toString());
+            source.copyTo(target, StandardCopyOption.REPLACE_EXISTING);
+            try {
+                long s1 = Attributes.readBasicFileAttributes(source).size();
+                long s2 = Attributes.readBasicFileAttributes(target).size();
+                if (s2 != s1)
+                    throw new RuntimeException("target size != source size");
+            } finally {
+                target.delete();
+            }
+        }
+
+        // Test: FileStore
+        FileStore store = fs.getPath("/").getFileStore();
+        if (!store.supportsFileAttributeView("basic"))
+            throw new RuntimeException("BasicFileAttributeView should be supported");
+
+        // Test: ClosedFileSystemException
+        fs.close();
+        if (fs.isOpen())
+            throw new RuntimeException("FileSystem should be closed");
+        try {
+            fs.getPath("/missing").checkAccess(AccessMode.READ);
+        } catch (ClosedFileSystemException x) { }
+    }
+
+    // FileVisitor that pretty prints a file tree
+    static class FileTreePrinter extends SimpleFileVisitor<Path> {
+        private int indent = 0;
+
+        private void indent() {
+            StringBuilder sb = new StringBuilder(indent);
+            for (int i=0; i<indent; i++) sb.append(" ");
+            System.out.print(sb);
+        }
+
+        @Override
+        public FileVisitResult preVisitDirectory(Path dir) {
+            if (dir.getName() != null) {
+                indent();
+                System.out.println(dir.getName() + "/");
+                indent++;
+            }
+            return FileVisitResult.CONTINUE;
+        }
+
+        @Override
+        public FileVisitResult visitFile(Path file,
+                                         BasicFileAttributes attrs)
+        {
+            indent();
+            System.out.print(file.getName());
+            if (attrs.isRegularFile())
+                System.out.format(" (%d)", attrs.size());
+            System.out.println();
+            return FileVisitResult.CONTINUE;
+        }
+
+        @Override
+        public FileVisitResult postVisitDirectory(Path dir, IOException exc) {
+            if (exc != null)
+                super.postVisitDirectory(dir, exc);
+            if (dir.getName() != null)
+                indent--;
+            return FileVisitResult.CONTINUE;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/demo/nio/ZipFileSystem/PathOps.java	Thu Dec 03 19:44:04 2009 +0000
@@ -0,0 +1,414 @@
+/*
+ * Copyright 2008-2009 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+import java.nio.file.*;
+import java.util.*;
+import java.io.IOException;
+
+/**
+ * Tests path operations for zip provider.
+ */
+
+public class PathOps {
+
+    static final java.io.PrintStream out = System.out;
+    static FileSystem fs;
+
+    private String input;
+    private Path path;
+    private Exception exc;
+
+    private PathOps(String s) {
+        out.println();
+        input = s;
+        try {
+            path = fs.getPath(s);
+            out.format("%s -> %s", s, path);
+        } catch (Exception x) {
+            exc = x;
+            out.format("%s -> %s", s, x);
+        }
+        out.println();
+    }
+
+    Path path() {
+        return path;
+    }
+
+    void fail() {
+        throw new RuntimeException("PathOps failed");
+    }
+
+    void checkPath() {
+        if (path == null) {
+            throw new InternalError("path is null");
+        }
+    }
+
+    void check(Object result, String expected) {
+        out.format("\tExpected: %s\n", expected);
+        out.format("\tActual: %s\n",  result);
+        if (result == null) {
+            if (expected == null) return;
+        } else {
+            // compare string representations
+            if (expected != null && result.toString().equals(expected.toString()))
+                return;
+        }
+        fail();
+    }
+
+    void check(Object result, boolean expected) {
+        check(result, Boolean.toString(expected));
+    }
+
+    PathOps root(String expected) {
+        out.println("check root");
+        checkPath();
+        check(path.getRoot(), expected);
+        return this;
+    }
+
+    PathOps parent(String expected) {
+        out.println("check parent");
+        checkPath();
+        check(path.getParent(), expected);
+        return this;
+    }
+
+    PathOps name(String expected) {
+        out.println("check name");
+        checkPath();
+        check(path.getName(), expected);
+        return this;
+    }
+
+    PathOps element(int index, String expected) {
+        out.format("check element %d\n", index);
+        checkPath();
+        check(path.getName(index), expected);
+        return this;
+    }
+
+    PathOps subpath(int startIndex, int endIndex, String expected) {
+        out.format("test subpath(%d,%d)\n", startIndex, endIndex);
+        checkPath();
+        check(path.subpath(startIndex, endIndex), expected);
+        return this;
+    }
+
+    PathOps starts(String prefix) {
+        out.format("test startsWith with %s\n", prefix);
+        checkPath();
+        Path s = fs.getPath(prefix);
+        check(path.startsWith(s), true);
+        return this;
+    }
+
+    PathOps notStarts(String prefix) {
+        out.format("test not startsWith with %s\n", prefix);
+        checkPath();
+        Path s = fs.getPath(prefix);
+        check(path.startsWith(s), false);
+        return this;
+    }
+
+    PathOps ends(String suffix) {
+        out.format("test endsWith %s\n", suffix);
+        checkPath();
+        Path s = fs.getPath(suffix);
+        check(path.endsWith(s), true);
+        return this;
+    }
+
+    PathOps notEnds(String suffix) {
+        out.format("test not endsWith %s\n", suffix);
+        checkPath();
+        Path s = fs.getPath(suffix);
+        check(path.endsWith(s), false);
+        return this;
+    }
+
+    PathOps absolute() {
+        out.println("check path is absolute");
+        checkPath();
+        check(path.isAbsolute(), true);
+        return this;
+    }
+
+    PathOps notAbsolute() {
+        out.println("check path is not absolute");
+        checkPath();
+        check(path.isAbsolute(), false);
+        return this;
+    }
+
+    PathOps resolve(String other, String expected) {
+        out.format("test resolve %s\n", other);
+        checkPath();
+        check(path.resolve(other), expected);
+        return this;
+    }
+
+    PathOps relativize(String other, String expected) {
+        out.format("test relativize %s\n", other);
+        checkPath();
+        Path that = fs.getPath(other);
+        check(path.relativize(that), expected);
+        return this;
+    }
+
+    PathOps normalize(String expected) {
+        out.println("check normalized path");
+        checkPath();
+        check(path.normalize(), expected);
+        return this;
+    }
+
+    PathOps string(String expected) {
+        out.println("check string representation");
+        checkPath();
+        check(path, expected);
+        return this;
+    }
+
+    PathOps invalid() {
+        if (!(exc instanceof InvalidPathException)) {
+            out.println("InvalidPathException not thrown as expected");
+            fail();
+        }
+        return this;
+    }
+
+    static PathOps test(String s) {
+        return new PathOps(s);
+    }
+
+    // -- PathOpss --
+
+    static void header(String s) {
+        out.println();
+        out.println();
+        out.println("-- " + s + " --");
+    }
+
+    static void doPathOpTests() {
+        header("Path operations");
+
+        // all components
+        test("/a/b/c")
+            .root("/")
+            .parent("/a/b")
+            .name("c");
+
+        // root component only
+        test("/")
+            .root("/")
+            .parent(null)
+            .name(null);
+
+        // no root component
+        test("a/b")
+            .root(null)
+            .parent("a")
+            .name("b");
+
+        // name component only
+        test("foo")
+            .root(null)
+            .parent(null)
+            .name("foo");
+
+        // startsWith
+        test("/")
+            .starts("/")
+            .notStarts("/foo");
+        test("/foo")
+            .starts("/")
+            .starts("/foo")
+            .notStarts("/f");
+        test("/foo/bar")
+            .starts("/")
+            .starts("/foo")
+            .starts("/foo/bar")
+            .notStarts("/f")
+            .notStarts("foo")
+            .notStarts("foo/bar");
+        test("foo")
+            .starts("foo")
+            .notStarts("f");
+        test("foo/bar")
+            .starts("foo")
+            .starts("foo/bar")
+            .notStarts("f")
+            .notStarts("/foo")
+            .notStarts("/foo/bar");
+
+        // endsWith
+        test("/")
+            .ends("/")
+            .notEnds("foo")
+            .notEnds("/foo");
+        test("/foo")
+            .ends("foo")
+            .ends("/foo")
+            .notEnds("/");
+        test("/foo/bar")
+            .ends("bar")
+            .ends("foo/bar")
+            .ends("/foo/bar")
+            .notEnds("/bar");
+        test("foo")
+            .ends("foo");
+        test("foo/bar")
+            .ends("bar")
+            .ends("foo/bar");
+
+        // elements
+        test("a/b/c")
+            .element(0,"a")
+            .element(1,"b")
+            .element(2,"c");
+
+        // isAbsolute
+        test("/")
+            .absolute();
+        test("/tmp")
+            .absolute();
+        test("tmp")
+            .notAbsolute();
+
+        // resolve
+        test("/tmp")
+            .resolve("foo", "/tmp/foo")
+            .resolve("/foo", "/foo");
+        test("tmp")
+            .resolve("foo", "tmp/foo")
+            .resolve("/foo", "/foo");
+
+        // relativize
+        test("/a/b/c")
+            .relativize("/a/b/c", null)
+            .relativize("/a/b/c/d/e", "d/e")
+            .relativize("/a/x", "../../x");
+
+        // normalize
+        test("/")
+            .normalize("/");
+        test("foo")
+            .normalize("foo");
+        test("/foo")
+            .normalize("/foo");
+        test(".")
+            .normalize(null);
+        test("..")
+            .normalize("..");
+        test("/..")
+            .normalize("/");
+        test("/../..")
+            .normalize("/");
+        test("foo/.")
+            .normalize("foo");
+        test("./foo")
+            .normalize("foo");
+        test("foo/..")
+            .normalize(null);
+        test("../foo")
+            .normalize("../foo");
+        test("../../foo")
+            .normalize("../../foo");
+        test("foo/bar/..")
+            .normalize("foo");
+        test("foo/bar/gus/../..")
+            .normalize("foo");
+        test("/foo/bar/gus/../..")
+            .normalize("/foo");
+
+        // invalid
+        test("foo\u0000bar")
+            .invalid();
+        test("\u0000foo")
+            .invalid();
+        test("bar\u0000")
+            .invalid();
+        test("//foo\u0000bar")
+            .invalid();
+        test("//\u0000foo")
+            .invalid();
+        test("//bar\u0000")
+            .invalid();
+
+        // normalization
+        test("//foo//bar")
+            .string("/foo/bar")
+            .root("/")
+            .parent("/foo")
+            .name("bar");
+    }
+
+    static void npes() {
+        header("NullPointerException");
+
+        Path path = fs.getPath("foo");
+
+        try {
+            path.resolve((String)null);
+            throw new RuntimeException("NullPointerException not thrown");
+        } catch (NullPointerException npe) {
+        }
+
+        try {
+            path.relativize(null);
+            throw new RuntimeException("NullPointerException not thrown");
+        } catch (NullPointerException npe) {
+        }
+
+        try {
+            path.compareTo(null);
+            throw new RuntimeException("NullPointerException not thrown");
+        } catch (NullPointerException npe) {
+        }
+
+        try {
+            path.startsWith(null);
+            throw new RuntimeException("NullPointerException not thrown");
+        } catch (NullPointerException npe) {
+        }
+
+        try {
+            path.endsWith(null);
+            throw new RuntimeException("NullPointerException not thrown");
+        } catch (NullPointerException npe) {
+        }
+
+    }
+
+    public static void main(String[] args) throws IOException {
+	Path zipfile = Paths.get(args[0]);
+	Map<String,?> env = new HashMap<String,Object>();
+        fs = FileSystems.newFileSystem(zipfile, env, null);
+
+        npes();
+        doPathOpTests();
+    }
+}
--- a/test/demo/nio/ZipFileSystem/Sanity.java	Thu Dec 03 19:36:54 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,153 +0,0 @@
-/*
- * Copyright 2007-2008 Sun Microsystems, Inc.  All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- */
-
-import java.nio.file.*;
-import java.nio.file.attribute.*;
-import java.nio.file.spi.FileSystemProvider;
-import java.util.*;
-import java.net.URI;
-import java.io.IOException;
-
-/**
- * Sanity check zip provider by running a few simple tests.
- */
-
-public class Sanity {
-    public static void main(String[] args) throws Exception {
-        Path zipfile = Paths.get(args[0]);
-
-        // Test: zip should should be returned in provider list
-        boolean found = false;
-        for (FileSystemProvider provider: FileSystemProvider.installedProviders()) {
-            if (provider.getScheme().equalsIgnoreCase("zip")) {
-                found = true;
-                break;
-            }
-        }
-        if (!found)
-            throw new RuntimeException("'zip' provider not installed");
-
-        // Test: FileSystems#newFileSystem(FileRef)
-        Map<String,?> env = new HashMap<String,Object>();
-        FileSystems.newFileSystem(zipfile, env, null).close();
-
-        // Test: FileSystems#newFileSystem(URI)
-        URI uri = URI.create("zip" + zipfile.toUri().toString().substring(4));
-        FileSystem fs = FileSystems.newFileSystem(uri, env, null);
-
-        // Test: exercise toUri method
-        String expected = uri.toString() + "#/foo";
-        String actual = fs.getPath("/foo").toUri().toString();
-        if (!actual.equals(expected)) {
-            throw new RuntimeException("toUri returned '" + actual +
-                "', expected '" + expected + "'");
-        }
-
-        // Test: exercise directory iterator and retrieval of basic attributes
-        Files.walkFileTree(fs.getPath("/"), new FileTreePrinter());
-
-        // Test: DirectoryStream
-        found = false;
-        DirectoryStream<Path> stream = fs.getPath("/").newDirectoryStream();
-        try {
-            for (Path entry: stream) {
-                found = entry.toString().equals("/META-INF");
-                if (found) break;
-            }
-        } finally {
-            stream.close();
-        }
-        if (!found)
-            throw new RuntimeException("Expected file not found");
-
-        // Test: copy file from zip file to current (scratch) directory
-        Path source = fs.getPath("/META-INF/services/java.nio.file.spi.FileSystemProvider");
-        if (source.exists()) {
-            Path target = Paths.get(source.getName().toString());
-            source.copyTo(target, StandardCopyOption.REPLACE_EXISTING);
-            try {
-                long s1 = Attributes.readBasicFileAttributes(source).size();
-                long s2 = Attributes.readBasicFileAttributes(target).size();
-                if (s2 != s1)
-                    throw new RuntimeException("target size != source size");
-            } finally {
-                target.delete();
-            }
-        }
-
-        // Test: FileStore
-        FileStore store = fs.getPath("/").getFileStore();
-        if (!store.supportsFileAttributeView("basic"))
-            throw new RuntimeException("BasicFileAttributeView should be supported");
-
-        // Test: ClosedFileSystemException
-        fs.close();
-        if (fs.isOpen())
-            throw new RuntimeException("FileSystem should be closed");
-        try {
-            fs.getPath("/missing").checkAccess(AccessMode.READ);
-        } catch (ClosedFileSystemException x) { }
-    }
-
-    // FileVisitor that pretty prints a file tree
-    static class FileTreePrinter extends SimpleFileVisitor<Path> {
-        private int indent = 0;
-
-        private void indent() {
-            StringBuilder sb = new StringBuilder(indent);
-            for (int i=0; i<indent; i++) sb.append(" ");
-            System.out.print(sb);
-        }
-
-        @Override
-        public FileVisitResult preVisitDirectory(Path dir) {
-            if (dir.getName() != null) {
-                indent();
-                System.out.println(dir.getName() + "/");
-                indent++;
-            }
-            return FileVisitResult.CONTINUE;
-        }
-
-        @Override
-        public FileVisitResult visitFile(Path file,
-                                         BasicFileAttributes attrs)
-        {
-            indent();
-            System.out.print(file.getName());
-            if (attrs.isRegularFile())
-                System.out.format(" (%d)", attrs.size());
-            System.out.println();
-            return FileVisitResult.CONTINUE;
-        }
-
-        @Override
-        public FileVisitResult postVisitDirectory(Path dir, IOException exc) {
-            if (exc != null)
-                super.postVisitDirectory(dir, exc);
-            if (dir.getName() != null)
-                indent--;
-            return FileVisitResult.CONTINUE;
-        }
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/demo/nio/ZipFileSystem/basic.sh	Thu Dec 03 19:44:04 2009 +0000
@@ -0,0 +1,72 @@
+#
+# Copyright 2007-2008 Sun Microsystems, Inc.  All Rights Reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+# CA 95054 USA or visit www.sun.com if you need additional information or
+# have any questions.
+#
+
+# @test
+# @bug 4313887
+# @summary Test ZipFileSystem demo
+# @build Basic PathOps
+# @run shell basic.sh
+
+if [ -z "${TESTJAVA}" ]; then
+    echo "Test must be run with jtreg"
+    exit 0
+fi
+
+ZIPFS="${TESTJAVA}/demo/nio/ZipFileSystem/ZipFileSystem.jar"
+if [ ! -r "${ZIPFS}" ]; then
+    echo "${ZIPFS} not found"
+    exit 0
+fi
+
+OS=`uname -s`
+case "$OS" in
+    Windows_* )
+        CLASSPATH="${TESTCLASSES};${ZIPFS}"
+        ;;
+    * )
+        CLASSPATH="${TESTCLASSES}:${ZIPFS}"
+        ;;
+esac
+export CLASSPATH
+
+failures=0
+
+go() {
+    echo ''
+    ${TESTJAVA}/bin/java $1 $2 $3 2>&1
+    if [ $? != 0 ]; then failures=`expr $failures + 1`; fi
+}
+
+# Run the tests
+
+go Basic "${ZIPFS}"
+go PathOps "${ZIPFS}"
+
+#
+# Results
+#
+echo ''
+if [ $failures -gt 0 ];
+  then echo "$failures test(s) failed";
+  else echo "All test(s) passed"; fi
+exit $failures
--- a/test/demo/nio/ZipFileSystem/sanity.sh	Thu Dec 03 19:36:54 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,71 +0,0 @@
-#
-# Copyright 2007-2008 Sun Microsystems, Inc.  All Rights Reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
-# CA 95054 USA or visit www.sun.com if you need additional information or
-# have any questions.
-#
-
-# @test
-# @bug 4313887
-# @summary Sanity check ZipFileSystem demo
-# @build Sanity
-# @run shell sanity.sh
-
-if [ -z "${TESTJAVA}" ]; then
-    echo "Test must be run with jtreg"
-    exit 0
-fi
-
-ZIPFS="${TESTJAVA}/demo/nio/ZipFileSystem/ZipFileSystem.jar"
-if [ ! -r "${ZIPFS}" ]; then
-    echo "${ZIPFS} not found"
-    exit 0
-fi
-
-OS=`uname -s`
-case "$OS" in
-    Windows_* )
-        CLASSPATH="${TESTCLASSES};${ZIPFS}"
-        ;;
-    * )
-        CLASSPATH="${TESTCLASSES}:${ZIPFS}"
-        ;;
-esac
-export CLASSPATH
-
-failures=0
-
-go() {
-    echo ''
-    ${TESTJAVA}/bin/java $1 $2 $3 2>&1
-    if [ $? != 0 ]; then failures=`expr $failures + 1`; fi
-}
-
-# Run the tests
-
-go Sanity  "${ZIPFS}"
-
-#
-# Results
-#
-echo ''
-if [ $failures -gt 0 ];
-  then echo "$failures test(s) failed";
-  else echo "All test(s) passed"; fi
-exit $failures