/*
* 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 ServerNotifs.java
* @bug 7654321
* @summary Tests the reception of the notifications for opened and closed
* connections
* @author sjiang
* @run clean ServerNotifs
* @run build ServerNotifs
* @run main ServerNotifs
*/
// JAVA
// JMX
import javax.management.*;
// RJMX
public class ServerNotifs {
}
try {
// Create MBeanServer
//
echo("---Create the MBeanServer...");
// Create RMIConnectorServer
//
echo("---Instantiate the RMIConnectorServer...");
null,
mbs);
echo("---Register the RMIConnectorServer in the MBeanServer...");
ObjectName on =
new ObjectName("JMXConnectors:name=RMIConnectorServer");
echo("---Start the RMIConnectorServer...");
echo("---Add a local listener to the RMIConnectorServer...");
// Create RMI connector
//
echo("---Instantiate the RMIConnector...");
// Expect to get a "jmx.remote.connection.opened" notification
//
echo("---Open connection...");
// Expect to get a "jmx.remote.connection.closed" notification
//
echo("---Close connection...");
c.close();
// Waiting for all notifications
//
synchronized(waiting) {
if (!succeeded) {
final long waitingTime = 10000;
long remainingTime = waitingTime;
}
}
}
// Stop the RMIConnectorServer
//
echo("---Stop the RMIConnectorServer...");
if (!succeeded) {
}
} catch (MBeanException mbe) {
echo("---Test failed.");
} catch (RuntimeOperationsException roe) {
echo("---Test failed.");
} catch (Throwable t) {
echo("---Test failed.");
echo("---Got throwable: " + t);
t.printStackTrace();
}
}
return;
}
echo(n.getMessage());
if (n instanceof JMXConnectionNotification) {
"got one with type: " + n.getType());
}
synchronized(waiting) {
succeeded = true;
}
}
}
}
}
private static boolean succeeded = false;
}