test/sun/rmi/runtime/Log/6409194/NoConsoleOutput.java

Print this page




  43 import java.rmi.registry.LocateRegistry;
  44 import java.rmi.registry.Registry;
  45 import java.rmi.server.UnicastRemoteObject;
  46 
  47 public class NoConsoleOutput {
  48 
  49     public static void main(String[] args) throws Exception {
  50         System.err.println("\nRegression test for bug 6409194\n");
  51 
  52         /*
  53          * Exdecute a subprocess VM that does a bunch of RMI activity
  54          * with a logging configuration file that does not specify a
  55          * ConsoleHandler and with no legacy sun.rmi.*.logLevel system
  56          * properties set.
  57          */
  58         String loggingPropertiesFile =
  59             System.getProperty("test.src", ".") +
  60             File.separatorChar + "logging.properties";
  61         ByteArrayOutputStream out = new ByteArrayOutputStream();
  62         ByteArrayOutputStream err = new ByteArrayOutputStream();



  63         JavaVM vm = new JavaVM(DoRMIStuff.class.getName(),
  64             "-Djava.util.logging.config.file=" + loggingPropertiesFile,
  65                                "", out, err);
  66         vm.start();
  67         vm.getVM().waitFor();
  68 
  69         /*
  70          * Verify that the subprocess had no System.out or System.err
  71          * output.
  72          */
  73         String outString = out.toString();
  74         String errString = err.toString();
  75 
  76         System.err.println("-------- subprocess standard output: --------");
  77         System.err.print(out);
  78         System.err.println("-------- subprocess standard error:  --------");
  79         System.err.print(err);
  80         System.err.println("---------------------------------------------");
  81 
  82         if (outString.length() > 0 || errString.length() > 0) {
  83             throw new Error("TEST FAILED: unexpected subprocess output");
  84         }
  85 




  43 import java.rmi.registry.LocateRegistry;
  44 import java.rmi.registry.Registry;
  45 import java.rmi.server.UnicastRemoteObject;
  46 
  47 public class NoConsoleOutput {
  48 
  49     public static void main(String[] args) throws Exception {
  50         System.err.println("\nRegression test for bug 6409194\n");
  51 
  52         /*
  53          * Exdecute a subprocess VM that does a bunch of RMI activity
  54          * with a logging configuration file that does not specify a
  55          * ConsoleHandler and with no legacy sun.rmi.*.logLevel system
  56          * properties set.
  57          */
  58         String loggingPropertiesFile =
  59             System.getProperty("test.src", ".") +
  60             File.separatorChar + "logging.properties";
  61         ByteArrayOutputStream out = new ByteArrayOutputStream();
  62         ByteArrayOutputStream err = new ByteArrayOutputStream();
  63 
  64         // We instantiate a JavaVM that should not produce any console output
  65         // (neither on standard output, nor on standard err streams).
  66         JavaVM vm = new JavaVM(DoRMIStuff.class.getName(),
  67             "-Djava.util.logging.config.file=" + loggingPropertiesFile,
  68                                "", out, err, false);
  69         vm.start();
  70         vm.getVM().waitFor();
  71 
  72         /*
  73          * Verify that the subprocess had no System.out or System.err
  74          * output.
  75          */
  76         String outString = out.toString();
  77         String errString = err.toString();
  78 
  79         System.err.println("-------- subprocess standard output: --------");
  80         System.err.print(out);
  81         System.err.println("-------- subprocess standard error:  --------");
  82         System.err.print(err);
  83         System.err.println("---------------------------------------------");
  84 
  85         if (outString.length() > 0 || errString.length() > 0) {
  86             throw new Error("TEST FAILED: unexpected subprocess output");
  87         }
  88