duke@1: #!/bin/sh duke@1: duke@1: # duke@1: # Copyright 2003-2005 Sun Microsystems, Inc. All Rights Reserved. duke@1: # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@1: # duke@1: # This code is free software; you can redistribute it and/or modify it duke@1: # under the terms of the GNU General Public License version 2 only, as duke@1: # published by the Free Software Foundation. duke@1: # duke@1: # This code is distributed in the hope that it will be useful, but WITHOUT duke@1: # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@1: # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@1: # version 2 for more details (a copy is included in the LICENSE file that duke@1: # accompanied this code). duke@1: # duke@1: # You should have received a copy of the GNU General Public License version duke@1: # 2 along with this work; if not, write to the Free Software Foundation, duke@1: # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@1: # duke@1: # Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, duke@1: # CA 95054 USA or visit www.sun.com if you need additional information or duke@1: # have any questions. duke@1: # duke@1: duke@1: duke@1: # @test @(#)Class-Path.sh 1.3 03/10/31 duke@1: # @bug 4212732 duke@1: # @summary Test handling of the Class-Path attribute in jar file manifests duke@1: # @author Martin Buchholz duke@1: # duke@1: # @run shell Class-Path.sh duke@1: duke@1: # To run this test manually, simply do ./Class-Path.sh duke@1: duke@1: . ${TESTSRC-.}/Util.sh duke@1: duke@1: set -u duke@1: duke@1: Cleanup() { duke@1: Sys rm -rf pkg Main.java Main.class Main.jar jars duke@1: Sys rm -rf MANIFEST.MF A.jar B.zip duke@1: } duke@1: duke@1: Cleanup duke@1: Sys mkdir pkg duke@1: duke@1: #---------------------------------------------------------------- duke@1: # Create mutually referential jar files duke@1: #---------------------------------------------------------------- duke@1: cat >pkg/A.java <pkg/B.java <Main.java <> MANIFEST.MF duke@1: Sys "$jar" cmf MANIFEST.MF Main.jar Main.class duke@1: duke@1: Success "$java" ${TESTVMOPTS} -jar Main.jar duke@1: duke@1: MkManifestWithClassPath "." duke@1: Sys "$jar" cmf MANIFEST.MF A.jar pkg/A.class duke@1: duke@1: Success "$javac" ${TESTTOOLVMOPTS} -cp "A.jar" Main.java duke@1: Success "$java" ${TESTVMOPTS} -jar Main.jar duke@1: duke@1: MkManifestWithClassPath "" duke@1: Sys "$jar" cmf MANIFEST.MF A.jar pkg/A.class duke@1: duke@1: Failure "$javac" ${TESTTOOLVMOPTS} -cp "A.jar" Main.java duke@1: Failure "$java" ${TESTVMOPTS} -jar Main.jar duke@1: duke@1: #---------------------------------------------------------------- duke@1: # Test new flag -e (application entry point) duke@1: #---------------------------------------------------------------- duke@1: duke@1: cat > Hello.java < Bye.java <> MANIFEST.MF duke@1: duke@1: # test for error: " 'e' flag and manifest with the 'Main-Class' duke@1: # attribute cannot be specified together, during creation duke@1: Failure "$jar" cmfe MANIFEST.MF "Bye.jar" "Bye" Bye.class duke@1: duke@1: # test for overriding the manifest when updating the jar duke@1: # duke@1: Success "$jar" cfe "greetings.jar" "Hello" Hello.class duke@1: Success "$jar" ufe "greetings.jar" "Bye" Bye.class duke@1: Success "$java" ${TESTVMOPTS} -jar greetings.jar duke@1: duke@1: # test for error: " 'e' flag and manifest with the 'Main-Class' duke@1: # attribute cannot be specified together, during update duke@1: Failure "$jar" umfe MANIFEST.MF "greetings.jar" "Hello" duke@1: duke@1: # test jar updation when there are no inputfiles duke@1: # duke@1: Success "$jar" ufe "Hello.jar" "Bye" duke@1: Failure "$java" ${TESTVMOPTS} -jar Hello.jar duke@1: Success "$jar" umf MANIFEST.MF "Hello.jar" duke@1: duke@1: # test creating jar when the to-be-archived files duke@1: # do not contain the specified main class, there is no check done duke@1: # for the presence of the main class, so the test will pass duke@1: # duke@1: Success "$jar" cfe "Hello.jar" "Hello" Bye.class duke@1: duke@1: # Jar creation and update when there is no manifest and inputfiles duke@1: specified duke@1: Failure "$jar" cvf "A.jar" duke@1: Failure "$jar" uvf "A.jar" duke@1: duke@1: # error: no such file or directory duke@1: Failure "$jar" cvf "A.jar" non-existing.file duke@1: Failure "$jar" uvf "A.jar" non-existing.file duke@1: duke@1: Cleanup duke@1: duke@1: Bottom Line