/*
* 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 4981215
* @summary Tests that the jvmstat counters published by the out-of-the-box
* management agent for the JMX connection details are correct.
* @author Luis-Miguel Alventosa
* @run clean JvmstatCountersTest
* @run build JvmstatCountersTest
* @run main/othervm -Dcom.sun.management.jmxremote.port=0 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false JvmstatCountersTest 3
*/
import javax.management.*;
public class JvmstatCountersTest {
}
throw new IllegalArgumentException("Test case failed");
}
throw new IllegalArgumentException("Test case failed");
}
}
switch (testCase) {
case 1:
"agent didn't publish any jvmstat counter.");
} else {
"agent unexpectedly published jvmstat counters.");
throw new IllegalArgumentException("Test case 1 failed");
}
break;
case 2:
if (localAddress == null) {
"agent didn't publish the local connector.");
throw new IllegalArgumentException("Test case 2 failed");
}
if (!remoteData.isEmpty()) {
"agent shouldn't publish the remote connector.");
throw new IllegalArgumentException("Test case 2 failed");
}
"agent only publishes the local connector through " +
"a jvmstat counter.");
break;
case 3:
if (localAddress == null) {
"agent didn't publish the local connector.");
throw new IllegalArgumentException("Test case 3 failed");
}
if (remoteData.isEmpty()) {
"agent didnn't publish the remote connector.");
throw new IllegalArgumentException("Test case 3 failed");
}
"agent shouldn't publish anything which isn't " +
"related to the remote connector.");
throw new IllegalArgumentException("Test case 3 failed");
}
}
"agent publishes both the local and remote " +
"connector info through jvmstat counters.");
break;
case 4:
"agent unexpectedly published jvmstat counters.");
throw new IllegalArgumentException("Test case 4 failed");
}
vm.loadAgent(agent, "com.sun.management.jmxremote.port=0,com.sun.management.jmxremote.authenticate=false,com.sun.management.jmxremote.ssl=false");
if (localAddress2 == null) {
"agent didn't publish the local connector.");
throw new IllegalArgumentException("Test case 4 failed");
}
if (remoteData2.isEmpty()) {
"agent didnn't publish the remote connector.");
throw new IllegalArgumentException("Test case 4 failed");
}
"agent shouldn't publish anything which isn't " +
"related to the remote connector.");
throw new IllegalArgumentException("Test case 4 failed");
}
}
"publishes both the local and remote connector " +
"info through jvmstat counters when the agent is " +
"loaded through the Attach API.");
}
}
}