1 /* 2 * Copyright (c) 2015, 2017, 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 */ 23 24 /** 25 * @test 26 * @bug 7130985 27 * @summary Four helper classes missing in Sun JDK 28 * @library /lib/testlibrary /test/lib 29 * @modules java.corba 30 * @build jdk.test.lib.Platform 31 * jdk.test.lib.util.FileUtils 32 * jdk.testlibrary.* 33 * @run main CorbaExceptionsCompileTest 34 */ 35 36 import java.io.*; 37 import java.nio.file.Files; 38 import java.nio.file.Path; 39 import java.nio.file.Paths; 40 41 import org.omg.CORBA.ORBPackage.InvalidName; 42 import org.omg.CORBA.TypeCodePackage.BadKind; 43 import org.omg.CORBA.TypeCodePackage.Bounds; 44 45 import jdk.test.lib.util.FileUtils; 46 import jdk.testlibrary.JDKToolLauncher; 47 48 public class CorbaExceptionsCompileTest implements CorbaExceptionsTest { 49 50 public CorbaExceptionsCompileTest() { 51 super(); 52 } 53 54 public void testExceptionInvalidName() 55 throws java.rmi.RemoteException, InvalidName {} 56 57 public void testExceptionBounds() 58 throws java.rmi.RemoteException, Bounds {} 59 60 public void testExceptionBadKind() 61 throws java.rmi.RemoteException, BadKind {} 62 63 public void testExceptionCorba_Bounds() 64 throws java.rmi.RemoteException, org.omg.CORBA.Bounds {} 65 66 public static void main(String[] args) throws Exception { 67 final File f = new File( 68 CorbaExceptionsCompileTest.class.getProtectionDomain() 69 .getCodeSource().getLocation().getPath()); 70 System.out.println(f.getCanonicalPath()); 71 ProcessBuilder pb = new ProcessBuilder("ls", "-l"); 72 pb.directory(f); 73 Process p = pb.start(); 74 p.waitFor(); 75 if (p.exitValue() == 0) { 76 try (BufferedReader br = new BufferedReader( 77 new InputStreamReader(p.getInputStream()))) { 78 StringBuilder builder = new StringBuilder(); 79 String line = null; 80 while ( (line = br.readLine()) != null) { 81 builder.append(line + "\n"); 82 } 83 String result = builder.toString(); 84 System.out.println(result); 85 } 86 } 87 88 Path outDir = Paths.get("CorbaExceptionsCompileTest-compiled"); 89 outDir = Files.createDirectory(outDir).toAbsolutePath(); 90 JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("rmic"); 91 launcher.addToolArg("-classpath").addToolArg(f.getCanonicalPath()) 92 .addToolArg("-d").addToolArg(outDir.toString()) 93 .addToolArg("-iiop").addToolArg("CorbaExceptionsCompileTest"); 94 95 pb = new ProcessBuilder(launcher.getCommand()); 96 pb.directory(f); 97 System.out.println("Working Directory: " + pb.directory()); 98 System.out.println("CorbaExceptionsCompileTest.class exists: " 99 + new File(f, "CorbaExceptionsCompileTest.class").exists()); 100 101 p = pb.start(); 102 p.waitFor(); 103 if (p.exitValue() != 0) { 104 try (BufferedReader br = new BufferedReader( 105 new InputStreamReader(p.getInputStream()))) { 106 StringBuilder builder = new StringBuilder(); 107 String line = null; 108 while ( (line = br.readLine()) != null) { 109 builder.append(line + "\n"); 110 } 111 String result = builder.toString(); 112 System.out.println(result); 113 throw new RuntimeException(launcher.getCommand() + 114 " -iiop CorbaExceptionsCompileTest failed with status: " 115 + p.exitValue()); 116 } 117 } 118 119 if (Files.exists(outDir)) 120 FileUtils.deleteFileTreeWithRetry(outDir); 121 } 122 }