test/tools/pack200/Pack200Props.java

Print this page


   1 /*
   2  * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */


  37 import java.util.List;
  38 import java.util.Map;
  39 import java.util.jar.Pack200;
  40 import java.util.jar.Pack200.Packer;
  41 
  42 /*
  43  * Run this against a large jar file, by default the packer should generate only
  44  * one segment, parse the output of the packer to verify if this is indeed true.
  45  */
  46 
  47 public class Pack200Props {
  48 
  49     public static void main(String... args) throws IOException {
  50         verifyDefaults();
  51         File out = new File("test" + Utils.PACK_FILE_EXT);
  52         out.delete();
  53         verifySegmentLimit(out);
  54         Utils.cleanup();
  55     }
  56 
  57     static void verifySegmentLimit(File outFile) {
  58         File sdkHome = Utils.JavaSDK;
  59         File testJar = new File(new File(sdkHome, "lib"), "tools.jar");
  60 
  61         System.out.println("using pack200: " + Utils.getPack200Cmd());
  62 
  63         List<String> cmdsList = new ArrayList<>();
  64         cmdsList.add(Utils.getPack200Cmd());
  65         cmdsList.add("--effort=1");
  66         cmdsList.add("--verbose");
  67         cmdsList.add("--no-gzip");
  68         cmdsList.add(outFile.getName());
  69         cmdsList.add(testJar.getAbsolutePath());
  70         List<String> outList = Utils.runExec(cmdsList);
  71 
  72         int count = 0;
  73         for (String line : outList) {
  74             System.out.println(line);
  75             if (line.matches(".*Transmitted.*files of.*input bytes in a segment of.*bytes")) {
  76                 count++;
  77             }
  78         }
  79         if (count == 0) {


   1 /*
   2  * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */


  37 import java.util.List;
  38 import java.util.Map;
  39 import java.util.jar.Pack200;
  40 import java.util.jar.Pack200.Packer;
  41 
  42 /*
  43  * Run this against a large jar file, by default the packer should generate only
  44  * one segment, parse the output of the packer to verify if this is indeed true.
  45  */
  46 
  47 public class Pack200Props {
  48 
  49     public static void main(String... args) throws IOException {
  50         verifyDefaults();
  51         File out = new File("test" + Utils.PACK_FILE_EXT);
  52         out.delete();
  53         verifySegmentLimit(out);
  54         Utils.cleanup();
  55     }
  56 
  57     static void verifySegmentLimit(File outFile) throws IOException {
  58         File sdkHome = Utils.JavaSDK;
  59         File testJar = Utils.createRtJar();
  60 
  61         System.out.println("using pack200: " + Utils.getPack200Cmd());
  62 
  63         List<String> cmdsList = new ArrayList<>();
  64         cmdsList.add(Utils.getPack200Cmd());
  65         cmdsList.add("--effort=1");
  66         cmdsList.add("--verbose");
  67         cmdsList.add("--no-gzip");
  68         cmdsList.add(outFile.getName());
  69         cmdsList.add(testJar.getAbsolutePath());
  70         List<String> outList = Utils.runExec(cmdsList);
  71 
  72         int count = 0;
  73         for (String line : outList) {
  74             System.out.println(line);
  75             if (line.matches(".*Transmitted.*files of.*input bytes in a segment of.*bytes")) {
  76                 count++;
  77             }
  78         }
  79         if (count == 0) {