Path: blob/master/test/jdk/sun/rmi/runtime/Log/4504153/Test4504153.java
41161 views
/*1* Copyright (c) 2002, 2017, 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*/2223/* @test24* @bug 450415325* @summary RMI implementation should not log to two loggers where one is26* an ancestor of the other, to avoid unintended or duplicate logging27* @author Peter Jones28*29* @library ../../../../../java/rmi/testlibrary30* @modules java.rmi/sun.rmi.registry31* java.rmi/sun.rmi.server32* java.rmi/sun.rmi.transport33* java.rmi/sun.rmi.transport.tcp34* @build JavaVM35* @run main/othervm Test450415336*/3738import java.io.ByteArrayOutputStream;39import java.rmi.registry.LocateRegistry;40import java.rmi.server.RemoteServer;4142public class Test4504153 {4344private final static String DONE = "Done!";4546public static void main(String[] args) throws Exception {4748System.err.println("\nRegression test for bug 4504153\n");4950ByteArrayOutputStream out = new ByteArrayOutputStream();51ByteArrayOutputStream err = new ByteArrayOutputStream();52JavaVM vm = new JavaVM(StartRegistry.class.getName(),53"-Dsun.rmi.transport.logLevel=v", "", out, err);54try {55vm.execute();56} finally {57vm.destroy();58}5960String errString = err.toString();6162System.err.println(63"child process's standard error output:\n\n" + err + "\n");6465if (errString.indexOf(DONE) < 0) {66throw new RuntimeException("TEST FAILED: " +67"failed to collect expected child process output");68}6970if (errString.indexOf("TCPEndpoint") >= 0) {71throw new RuntimeException("TEST FAILED: " +72"unrequested logging output detected");73}7475System.err.println("TEST PASSED");76}7778public static class StartRegistry {79public static void main(String[] args) throws Exception {80LocateRegistry.createRegistry(0);81System.err.println(DONE);82}83}84}858687