/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 6227124
* @summary Test that setting an MBeanServerForwarder on an already
* started RMI connector server has the expected behavior.
* @author Luis-Miguel Alventosa
* @run clean MBSFPreStartPostStartTest
* @run build MBSFPreStartPostStartTest
* @run main MBSFPreStartPostStartTest
*/
public class MBSFPreStartPostStartTest {
final Class[] interfaces =
new Class[] {MBeanServerForwarder.class};
MBeanServerForwarder.class.getClassLoader(),
handler);
}
throws Throwable {
return mbs;
}
throw new IllegalArgumentException("Null MBeanServer");
throw new IllegalArgumentException("MBeanServer object " +
"already initialized");
return null;
}
flag = true;
}
public boolean getFlag() {
return flag;
}
}
private boolean flag;
}
/**
* Run test
*/
echo("=-=-= MBSFPreStartPostStartTest: Set MBSF " +
" starting the connector server =-=-=");
// Create a new MBeanServer
//
try {
// Create the JMXServiceURL
//
// Create a JMXConnectorServer
//
null,
mbs);
// Create MBeanServerForwarder
//
// Set MBeanServerForwarder before start()
//
if (setBeforeStart)
// Start the JMXConnectorServer
//
// Set MBeanServerForwarder after start()
//
if (!setBeforeStart)
// Create a JMXConnector
//
// Connect to the connector server
//
// Get non-secure MBeanServerConnection
//
final MBeanServerConnection mbsc =
// Run method
//
// Check flag in MBeanServerForwarder
//
echo("OK: Did go into MBeanServerForwarder!");
} else {
echo("KO: Didn't go into MBeanServerForwarder!");
return 1;
}
} catch (Exception e) {
echo("Failed to perform operation: " + e);
return 1;
} finally {
// Close the connection
//
// Stop the connector server
//
// Release the MBeanServer
//
}
return 0;
}
/*
* Print message
*/
}
/*
* Standalone entry point.
*
* Run the test and report to stdout.
*/
int error = 0;
// Set MBSF before start()
//
// Set MBSF after start()
//
// Check test results
//
if (error > 0) {
echo(">>> Unhappy Bye, Bye!");
throw new IllegalStateException(
"Test FAILED: Unexpected error!");
} else {
echo(">>> Happy Bye, Bye!");
}
}
}