3038N/A/*
3038N/A * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
3038N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3038N/A *
3038N/A * This code is free software; you can redistribute it and/or modify it
3038N/A * under the terms of the GNU General Public License version 2 only, as
3038N/A * published by the Free Software Foundation.
3038N/A *
3038N/A * This code is distributed in the hope that it will be useful, but WITHOUT
3038N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3038N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3038N/A * version 2 for more details (a copy is included in the LICENSE file that
3038N/A * accompanied this code).
3038N/A *
3038N/A * You should have received a copy of the GNU General Public License version
3038N/A * 2 along with this work; if not, write to the Free Software Foundation,
3038N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
3038N/A *
3038N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
3038N/A * or visit www.oracle.com if you need additional information or have any
3038N/A * questions.
3038N/A */
3038N/A
3038N/A/*
3038N/A * @test
3038N/A * @summary NPE IN RMIConnector.connect
3038N/A * @bug 6984520
3038N/A * @run clean RMIConnector_NPETest
3038N/A * @run build RMIConnector_NPETest
3038N/A * @run main RMIConnector_NPETest
3038N/A */
3038N/A
3038N/Aimport java.io.*;
3038N/Aimport java.lang.management.*;
3038N/Aimport java.rmi.registry.*;
3038N/Aimport javax.management.*;
3038N/Aimport javax.management.remote.*;
3038N/Aimport javax.management.remote.rmi.*;
3038N/A
3038N/Apublic class RMIConnector_NPETest {
3038N/A
3038N/A public static void main(String argv[]) throws Exception {
3038N/A boolean testFailed = false;
3038N/A String rmidCmd = System.getProperty("java.home") + File.separator +
3038N/A "bin" + File.separator + "rmid -port 3333";
3038N/A String stopRmidCmd = System.getProperty("java.home") + File.separator +
3038N/A "bin" + File.separator + "rmid -stop -port 3333";
3038N/A try {
3038N/A //start an rmid daemon and give it some time
3038N/A System.out.println("Starting rmid");
3038N/A Runtime.getRuntime().exec(rmidCmd);
3038N/A Thread.sleep(5000);
3038N/A
3038N/A MBeanServer mbs = MBeanServerFactory.createMBeanServer();
3038N/A RMIJRMPServerImpl rmiserver = new RMIJRMPServerImpl(3333, null, null, null);
3038N/A rmiserver.setMBeanServer(mbs);
3038N/A RMIConnector agent = new RMIConnector(rmiserver, null);
3038N/A agent.connect();
3038N/A } catch(NullPointerException npe) {
3038N/A npe.printStackTrace();
3038N/A testFailed = true;
3038N/A } catch (Exception e) {
3038N/A // OK
3038N/A } finally {
3038N/A System.out.println("Stopping rmid");
3038N/A Runtime.getRuntime().exec(stopRmidCmd);
3038N/A }
3038N/A
3038N/A if(testFailed)
3038N/A throw new Exception("Test failed");
3038N/A
3038N/A }
3038N/A}