jdk/test/sun/rmi/rmic/RMIGenerator/RmicDefault.java
changeset 2 90ce3da70b43
child 5506 202f599c92aa
equal deleted inserted replaced
0:fd16c54261b3 2:90ce3da70b43
       
     1 /*
       
     2  * Copyright 1999-2003 Sun Microsystems, Inc.  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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
       
    20  * CA 95054 USA or visit www.sun.com if you need additional information or
       
    21  * have any questions.
       
    22  */
       
    23 
       
    24 /* @test
       
    25  * @bug 4236543
       
    26  * @summary rmic w/o -d should put class files in package directory
       
    27  * @author Dana Burns
       
    28  * @library ../../../../java/rmi/testlibrary
       
    29  *
       
    30  * @build StreamPipe
       
    31  * @build RmicDefault
       
    32  * @run main RmicDefault
       
    33  */
       
    34 
       
    35 /*
       
    36  * Ensure that, in the absence of a -d argument, rmic will deposit
       
    37  * the generated class files in the package directory as opposed
       
    38  * to the old behaviour of depositing them in the local directory.
       
    39  * JavaTest/jtreg does not support setting the classpath yet, so do
       
    40  * the javac directly.
       
    41  */
       
    42 
       
    43 import java.io.File;
       
    44 import java.io.IOException;
       
    45 
       
    46 public class RmicDefault {
       
    47     public static void main(String args[]) throws Exception {
       
    48         String javahome = System.getProperty("java.home");
       
    49         String testclasses = System.getProperty("test.classes");
       
    50         String userDir = System.getProperty("user.dir");
       
    51 
       
    52         if (javahome.regionMatches(true, javahome.length() - 4,
       
    53                                    File.separator + "jre", 0, 4))
       
    54         {
       
    55             javahome = javahome.substring(0, javahome.length() - 4);
       
    56         }
       
    57 
       
    58         Process javacProcess = Runtime.getRuntime().exec(
       
    59             javahome + File.separator + "bin" + File.separator +
       
    60             "javac -d " + testclasses + " " +
       
    61             System.getProperty("test.src") + File.separator + "packagedir" +
       
    62             File.separator + "RmicMeImpl.java");
       
    63 
       
    64         StreamPipe.plugTogether(javacProcess.getInputStream(), System.out);
       
    65         StreamPipe.plugTogether(javacProcess.getErrorStream(), System.out);
       
    66 
       
    67         javacProcess.waitFor();
       
    68 
       
    69         Process rmicProcess = Runtime.getRuntime().exec(
       
    70             javahome + File.separator + "bin" + File.separator +
       
    71             "rmic -classpath " + testclasses + " packagedir.RmicMeImpl");
       
    72 
       
    73         StreamPipe.plugTogether(rmicProcess.getInputStream(), System.out);
       
    74         StreamPipe.plugTogether(rmicProcess.getErrorStream(), System.err);
       
    75 
       
    76         rmicProcess.waitFor();
       
    77 
       
    78         File stub = new File(userDir + File.separator + "packagedir" +
       
    79                              File.separator + "RmicMeImpl_Stub.class");
       
    80         if (!stub.exists()) {
       
    81             throw new RuntimeException("TEST FAILED: could not find stub");
       
    82         }
       
    83 
       
    84         System.err.println("TEST PASSED");
       
    85     }
       
    86 }