Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/tools/pack200/RepackTest.java
38833 views
/*1* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/22import java.io.File;23import java.io.IOException;24import java.util.ArrayList;25import java.util.List;26/*27* @test28* @bug 718414529* @summary tests repacking of a simple named jarfile.30* @compile -XDignore.symbol.file Utils.java RepackTest.java31* @run main RepackTest32* @author ksrini33*/34public class RepackTest {3536public static void main(String... args) throws Exception {37testRepack();38Utils.cleanup();39}4041/*42* there are two cases we need to test, where the file in question is43* orpaned, ie. without a parent ie. not qualified by a parent path44* relative nor absolute45* case 1: src and dest are the same46* case 2: src and dest are different47*/48static void testRepack() throws IOException {4950// make a copy of the test specimen to local directory51File testFile = new File("src_tools.jar");52Utils.copyFile(Utils.locateJar("golden.jar"), testFile);53List<String> cmdsList = new ArrayList<>();5455// case 1:56cmdsList.add(Utils.getPack200Cmd());57cmdsList.add("--repack");58cmdsList.add(testFile.getName());59Utils.runExec(cmdsList);6061// case 2:62File dstFile = new File("dst_tools.jar");63cmdsList.clear();64cmdsList.add(Utils.getPack200Cmd());65cmdsList.add("--repack");66cmdsList.add(dstFile.getName());67cmdsList.add(testFile.getName());68Utils.runExec(cmdsList);6970// tidy up71testFile.delete();72dstFile.delete();73}74}757677