1 /* 2 * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 import java.io.EOFException; 25 import java.io.File; 26 import java.io.IOException; 27 import java.lang.reflect.InvocationTargetException; 28 import java.lang.reflect.Method; 29 import java.net.BindException; 30 import java.net.ConnectException; 31 import java.net.ServerSocket; 32 import java.rmi.RemoteException; 33 import java.rmi.registry.LocateRegistry; 34 import java.rmi.registry.Registry; 35 import java.util.ArrayList; 36 import java.util.Arrays; 37 import java.util.List; 38 import java.util.Objects; 39 import java.util.Set; 40 import java.util.concurrent.TimeoutException; 41 import java.util.concurrent.atomic.AtomicBoolean; 42 43 import javax.management.*; 44 import javax.management.remote.*; 45 import javax.net.ssl.SSLHandshakeException; 46 47 import jdk.testlibrary.ProcessTools; 48 import jdk.testlibrary.Utils; 49 import jdk.internal.agent.Agent; 50 import jdk.internal.agent.AgentConfigurationError; 51 import jdk.internal.agent.ConnectorAddressLink; 52 53 /** 54 * @test 55 * @bug 7110104 56 * @key randomness intermittent 57 * @summary Makes sure that enabling/disabling the management agent through JCMD 58 * achieves the desired results 59 * 60 * @library /lib/testlibrary 61 * 62 * @build jdk.testlibrary.* JMXStartStopTest PortAllocator TestApp ManagementAgentJcmd 63 * @run main/othervm/timeout=600 -XX:+UsePerfData JMXStartStopTest 64 */ 65 public class JMXStartStopTest { 66 private static final String TEST_APP_NAME = "TestApp"; 67 68 private static final String TEST_SRC = System.getProperty("test.src"); 69 70 private static final boolean verbose = false; 71 72 private static ManagementAgentJcmd jcmd = new ManagementAgentJcmd(TEST_APP_NAME, verbose); 73 74 private static void dbg_print(String msg) { 75 if (verbose) { 76 System.out.println("DBG: " + msg); 77 } 78 } 79 80 private static int listMBeans(MBeanServerConnection server, 81 ObjectName pattern, 82 QueryExp query) 83 throws Exception { 84 85 Set<ObjectName> names = server.queryNames(pattern,query); 86 for (ObjectName name : names) { 87 MBeanInfo info = server.getMBeanInfo(name); 88 dbg_print("Got MBean: " + name); 89 90 MBeanAttributeInfo[] attrs = info.getAttributes(); 91 if (attrs == null) 92 continue; 93 for (MBeanAttributeInfo attr : attrs) { 94 if (attr.isReadable()) { 95 server.getAttribute(name, attr.getName()); 96 } 97 } 98 } 99 return names.size(); 100 } 101 102 private static void testConnectLocal(long pid) 103 throws Exception { 104 105 String jmxUrlStr = null; 106 107 try { 108 jmxUrlStr = ConnectorAddressLink.importFrom((int)pid); 109 dbg_print("Local Service URL: " +jmxUrlStr); 110 if ( jmxUrlStr == null ) { 111 throw new Exception("No Service URL. Local agent not started?"); 112 } 113 114 JMXServiceURL url = new JMXServiceURL(jmxUrlStr); 115 116 JMXConnector c = JMXConnectorFactory.connect(url, null); 117 118 MBeanServerConnection conn = c.getMBeanServerConnection(); 119 ObjectName pattern = new ObjectName("java.lang:type=Memory,*"); 120 121 int count = listMBeans(conn,pattern,null); 122 if (count == 0) 123 throw new Exception("Expected at least one matching "+ 124 "MBean for "+pattern); 125 126 } catch (IOException e) { 127 dbg_print("Cannot find process : " + pid); 128 throw e; 129 } 130 } 131 132 private static void testNoConnect(int port) throws Exception { 133 testNoConnect(port, 0); 134 } 135 136 private static void testNoConnect(int port, int rmiPort) throws Exception { 137 try { 138 testConnect(port, rmiPort); 139 throw new Exception("Didn't expect the management agent running"); 140 } catch (Exception e) { 141 Throwable t = e; 142 while (t != null) { 143 if (t instanceof RemoteException || 144 t instanceof SSLHandshakeException || 145 t instanceof ConnectException) { 146 break; 147 } 148 t = t.getCause(); 149 } 150 if (t == null) { 151 throw new Exception("Unexpected exception", e); 152 } 153 } 154 } 155 156 private static void testConnect(int port) throws Exception { 157 testConnect(port, 0); 158 } 159 160 private static void testConnect(int port, int rmiPort) throws Exception { 161 EOFException lastException = null; 162 // factor adjusted timeout (5 seconds) for the RMI to become available 163 long timeout = System.currentTimeMillis() + Utils.adjustTimeout(5000); 164 do { 165 try { 166 doTestConnect(port, rmiPort); 167 lastException = null; 168 } catch (EOFException e) { 169 lastException = e; 170 System.out.println("Error establishing RMI connection. Retrying in 500ms."); 171 Thread.sleep(500); 172 } 173 } while (lastException != null && System.currentTimeMillis() < timeout); 174 175 if (lastException != null) { 176 // didn't manage to get the RMI running in time 177 // rethrow the exception 178 throw lastException; 179 } 180 } 181 182 private static void doTestConnect(int port, int rmiPort) throws Exception { 183 dbg_print("RmiRegistry lookup..."); 184 185 dbg_print("Using port: " + port); 186 187 dbg_print("Using rmi port: " + rmiPort); 188 189 Registry registry = LocateRegistry.getRegistry(port); 190 191 // "jmxrmi" 192 String[] relist = registry.list(); 193 for (int i = 0; i < relist.length; ++i) { 194 dbg_print("Got registry: " + relist[i]); 195 } 196 197 String jmxUrlStr = (rmiPort != 0) ? 198 String.format( 199 "service:jmx:rmi://localhost:%d/jndi/rmi://localhost:%d/jmxrmi", 200 rmiPort, 201 port) : 202 String.format( 203 "service:jmx:rmi:///jndi/rmi://localhost:%d/jmxrmi", 204 port); 205 206 JMXServiceURL url = new JMXServiceURL(jmxUrlStr); 207 208 JMXConnector c = JMXConnectorFactory.connect(url, null); 209 210 MBeanServerConnection conn = c.getMBeanServerConnection(); 211 ObjectName pattern = new ObjectName("java.lang:type=Memory,*"); 212 213 int count = listMBeans(conn,pattern,null); 214 if (count == 0) 215 throw new Exception("Expected at least one matching " + 216 "MBean for " + pattern); 217 } 218 219 private static class Failure { 220 private final Throwable cause; 221 private final String msg; 222 223 public Failure(Throwable cause, String msg) { 224 this.cause = cause; 225 this.msg = msg; 226 } 227 228 public Failure(String msg) { 229 this(null, msg); 230 } 231 232 public Throwable getCause() { 233 return cause; 234 } 235 236 public String getMsg() { 237 return msg; 238 } 239 240 @Override 241 public int hashCode() { 242 int hash = 7; 243 hash = 97 * hash + Objects.hashCode(this.cause); 244 hash = 97 * hash + Objects.hashCode(this.msg); 245 return hash; 246 } 247 248 @Override 249 public boolean equals(Object obj) { 250 if (obj == null) { 251 return false; 252 } 253 if (getClass() != obj.getClass()) { 254 return false; 255 } 256 final Failure other = (Failure) obj; 257 if (!Objects.equals(this.cause, other.cause)) { 258 return false; 259 } 260 if (!Objects.equals(this.msg, other.msg)) { 261 return false; 262 } 263 return true; 264 } 265 266 @Override 267 public String toString() { 268 if (cause != null) { 269 return msg + "\n" + cause; 270 } else { 271 return msg; 272 } 273 } 274 } 275 276 private static List<Failure> failures = new ArrayList<>(); 277 278 public static void main(String args[]) throws Exception { 279 for (Method m : JMXStartStopTest.class.getDeclaredMethods()) { 280 if (m.getName().startsWith("test_")) { 281 long t1 = System.currentTimeMillis(); 282 try { 283 boolean retry = false; 284 do { 285 try { 286 m.invoke(null); 287 retry = false; 288 } catch (InvocationTargetException e) { 289 if (e.getCause() instanceof BindException || 290 e.getCause() instanceof java.rmi.ConnectException) { 291 System.out.println("Failed to allocate ports. Retrying ..."); 292 retry = true; 293 } else { 294 throw e; 295 } 296 } 297 } while (retry); 298 System.out.println("=== PASSED"); 299 } catch (Throwable e) { 300 failures.add(new Failure(e, m.getName() + " failed")); 301 } finally { 302 System.out.println("(took " + (System.currentTimeMillis() - t1) + "ms)\n"); 303 } 304 } 305 } 306 307 if (!failures.isEmpty()) { 308 for(Failure f : failures) { 309 System.err.println(f.getMsg()); 310 f.getCause().printStackTrace(System.err); 311 } 312 throw new Error(); 313 } 314 } 315 316 private static class TestAppRun { 317 private Process p; 318 private final ProcessBuilder pb; 319 private final String name; 320 private final AtomicBoolean started = new AtomicBoolean(false); 321 private volatile long pid = -1; 322 323 public TestAppRun(ProcessBuilder pb, String name) { 324 this.pb = pb; 325 this.name = name; 326 } 327 328 public synchronized void start() throws InterruptedException, IOException, TimeoutException { 329 if (started.compareAndSet(false, true)) { 330 try { 331 AtomicBoolean error = new AtomicBoolean(false); 332 p = ProcessTools.startProcess( 333 TEST_APP_NAME + "{" + name + "}", 334 pb, 335 (line) -> { 336 boolean ok = line.equals("main enter"); 337 error.set(line.contains("BindException")); 338 339 return ok || error.get(); 340 } 341 ); 342 if (error.get()) { 343 throw new BindException("Starting process failed due to " + 344 "the requested port not being available"); 345 } 346 pid = p.getPid(); 347 } catch (TimeoutException e) { 348 if (p != null) { 349 p.destroy(); 350 p.waitFor(); 351 } 352 throw e; 353 } 354 } 355 } 356 357 public long getPid() { 358 return pid; 359 } 360 361 public synchronized void stop() 362 throws IOException, InterruptedException { 363 if (started.compareAndSet(true, false)) { 364 p.getOutputStream().write(0); 365 p.getOutputStream().flush(); 366 int ec = p.waitFor(); 367 if (ec != 0) { 368 StringBuilder msg = new StringBuilder(); 369 msg.append("Test application '").append(name); 370 msg.append("' failed with exit code: "); 371 msg.append(ec); 372 373 failures.add(new Failure(msg.toString())); 374 } 375 } 376 } 377 } 378 379 /** 380 * Runs the test application "TestApp" 381 * @param name Test run name 382 * @param args Additional arguments 383 * @return Returns a {@linkplain TestAppRun} instance representing the run 384 * @throws IOException 385 * @throws InterruptedException 386 * @throws TimeoutException 387 */ 388 private static TestAppRun doTest(String name, String ... args) 389 throws Exception { 390 List<String> pbArgs = new ArrayList<>(Arrays.asList( 391 "-cp", 392 System.getProperty("test.class.path"), 393 "-XX:+UsePerfData" 394 )); 395 pbArgs.addAll(Arrays.asList(args)); 396 pbArgs.add(TEST_APP_NAME); 397 398 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( 399 pbArgs.toArray(new String[pbArgs.size()]) 400 ); 401 TestAppRun s = new TestAppRun(pb, name); 402 s.start(); 403 return s; 404 } 405 406 static void test_01() throws Exception { 407 // Run an app with JMX enabled stop it and 408 // restart on other port 409 410 System.out.println("**** Test one ****"); 411 int ports[] = PortAllocator.allocatePorts(2); 412 413 TestAppRun s = doTest( 414 "test_01", 415 "-Dcom.sun.management.jmxremote.port=" + ports[0], 416 "-Dcom.sun.management.jmxremote.authenticate=false", 417 "-Dcom.sun.management.jmxremote.ssl=false"); 418 419 try { 420 testConnect(ports[0]); 421 422 jcmd.stop(); 423 testNoConnect(ports[0]); 424 425 jcmd.start("jmxremote.port=" + ports[1]); 426 testConnect(ports[1]); 427 } finally { 428 s.stop(); 429 } 430 } 431 432 static void test_02() throws Exception { 433 // Run an app without JMX enabled 434 // start JMX by jcmd 435 436 System.out.println("**** Test two ****"); 437 438 int[] ports = PortAllocator.allocatePorts(1); 439 TestAppRun s = doTest("test_02"); 440 try { 441 jcmd.start( 442 "jmxremote.port=" + ports[0], 443 "jmxremote.authenticate=false", 444 "jmxremote.ssl=false" 445 ); 446 447 testConnect(ports[0]); 448 } finally { 449 // debugPortUsage(pa); 450 s.stop(); 451 } 452 } 453 454 static void test_03() throws Exception { 455 // Run an app without JMX enabled 456 // start JMX by jcmd on one port than on other one 457 458 System.out.println("**** Test three ****"); 459 460 int[] ports = PortAllocator.allocatePorts(2); 461 TestAppRun s = doTest("test_03"); 462 try { 463 jcmd.start( 464 "jmxremote.port=" + ports[0], 465 "jmxremote.authenticate=false", 466 "jmxremote.ssl=false" 467 ); 468 469 // Second agent shouldn't start 470 jcmd.start( 471 "jmxremote.port=" + ports[1], 472 "jmxremote.authenticate=false", 473 "jmxremote.ssl=false" 474 ); 475 476 // First agent should connect 477 testConnect(ports[0]); 478 479 // Second agent should not connect 480 testNoConnect(ports[1]); 481 } finally { 482 s.stop(); 483 } 484 } 485 486 static void test_04() throws Exception { 487 // Run an app without JMX enabled 488 // start JMX by jcmd on one port, specify rmi port explicitly 489 490 System.out.println("**** Test four ****"); 491 492 int[] ports = PortAllocator.allocatePorts(2); 493 TestAppRun s = doTest("test_04"); 494 try { 495 jcmd.start( 496 "jmxremote.port=" + ports[0], 497 "jmxremote.rmi.port=" + ports[1], 498 "jmxremote.authenticate=false", 499 "jmxremote.ssl=false" 500 ); 501 502 testConnect(ports[0], ports[1]); 503 } finally { 504 s.stop(); 505 } 506 } 507 508 static void test_05() throws Exception { 509 // Run an app without JMX enabled, it will enable local server 510 // but should leave remote server disabled 511 512 System.out.println("**** Test five ****"); 513 int[] ports = PortAllocator.allocatePorts(1); 514 TestAppRun s = doTest("test_05"); 515 try { 516 jcmd.startLocal(); 517 518 testNoConnect(ports[0]); 519 testConnectLocal(s.getPid()); 520 } finally { 521 s.stop(); 522 } 523 } 524 525 static void test_06() throws Exception { 526 // Run an app without JMX enabled 527 // start JMX by jcmd on one port, specify rmi port explicitly 528 // attempt to start it again with the same port 529 // Check for valid messages in the output 530 531 System.out.println("**** Test six ****"); 532 533 int[] ports = PortAllocator.allocatePorts(2); 534 TestAppRun s = doTest("test_06"); 535 try { 536 jcmd.start( 537 "jmxremote.port=" + ports[0], 538 "jmxremote.authenticate=false", 539 "jmxremote.ssl=false" 540 ); 541 542 testConnect(ports[0], ports[1]); 543 544 final AtomicBoolean checks = new AtomicBoolean(false); 545 jcmd.start( 546 line -> { 547 if (line.contains("java.lang.RuntimeException: Invalid agent state")) { 548 checks.set(true); 549 } 550 }, 551 "jmxremote.port=" + ports[0], 552 "jmxremote.authenticate=false", 553 "jmxremote.ssl=false" 554 ); 555 556 if (!checks.get()) { 557 throw new Exception("Starting agent on port " + ports[0] + " should " 558 + "report an invalid agent state"); 559 } 560 } finally { 561 s.stop(); 562 } 563 } 564 565 static void test_07() throws Exception { 566 // Run an app without JMX enabled 567 // start JMX by jcmd on one port, specify rmi port explicitly 568 // attempt to start it again with other port 569 // Check for valid messages in the output 570 571 System.out.println("**** Test seven ****"); 572 573 int[] ports = PortAllocator.allocatePorts(2); 574 TestAppRun s = doTest("test_07"); 575 try { 576 jcmd.start( 577 "jmxremote.port=" + ports[0], 578 "jmxremote.authenticate=false", 579 "jmxremote.ssl=false" 580 ); 581 582 testConnect(ports[0], ports[1]); 583 584 final AtomicBoolean checks = new AtomicBoolean(false); 585 586 jcmd.start( 587 line -> { 588 if (line.contains("java.lang.RuntimeException: Invalid agent state")) { 589 checks.set(true); 590 } 591 }, 592 "jmxremote.port=" + ports[1], 593 "jmxremote.authenticate=false", 594 "jmxremote.ssl=false" 595 ); 596 597 if (!checks.get()) { 598 throw new Exception("Starting agent on poprt " + ports[1] + " should " 599 + "report an invalid agent state"); 600 } 601 } finally { 602 s.stop(); 603 } 604 } 605 606 static void test_08() throws Exception { 607 // Run an app without JMX enabled 608 // start JMX by jcmd on one port, specify rmi port explicitly 609 // attempt to stop it twice 610 // Check for valid messages in the output 611 612 System.out.println("**** Test eight ****"); 613 614 int[] ports = PortAllocator.allocatePorts(2); 615 TestAppRun s = doTest("test_08"); 616 try { 617 jcmd.start( 618 "jmxremote.port=" + ports[0], 619 "jmxremote.authenticate=false", 620 "jmxremote.ssl=false" 621 ); 622 623 testConnect(ports[0], ports[1]); 624 625 jcmd.stop(); 626 jcmd.stop(); 627 } finally { 628 s.stop(); 629 } 630 } 631 632 static void test_09() throws Exception { 633 // Run an app without JMX enabled 634 // attempt to start JMX using a non-available port 635 // Check for valid messages in the output 636 637 System.out.println("**** Test nine ****"); 638 639 TestAppRun s = doTest("test_09"); 640 641 try (ServerSocket ss = new ServerSocket(0)) { 642 int localPort = ss.getLocalPort(); 643 int[] ports; 644 do { 645 ports = PortAllocator.allocatePorts(1); 646 } while (localPort == ports[0]); 647 648 final AtomicBoolean checks = new AtomicBoolean(false); 649 650 int retryCntr = 1; 651 do { 652 final AtomicBoolean retry = new AtomicBoolean(false); 653 654 try { 655 jcmd.start( 656 line -> { 657 if (line.contains(Agent.getText(AgentConfigurationError.AGENT_EXCEPTION))) { 658 retry.set(true); 659 } 660 }, 661 "jmxremote.port=" + ports[0], 662 "jmxremote.rmi.port=" + localPort, 663 "jmxremote.authenticate=false", 664 "jmxremote.ssl=false" 665 ); 666 } catch (BindException e) { 667 checks.set(true); 668 } 669 if (!retry.get()) { 670 break; 671 } 672 System.out.println("Attempt " + retryCntr + " >>>"); 673 System.out.println("Unexpected reply from the agent. Retrying in 500ms ..."); 674 Thread.sleep(500); 675 } while (retryCntr++ < 10); 676 677 if (!checks.get()) { 678 throw new Exception("Starting agent on port " + ports[0] + " should " 679 + "report port in use"); 680 } 681 } finally { 682 s.stop(); 683 } 684 685 } 686 687 static void test_10() throws Exception { 688 // Run an app without JMX enabled, but with some properties set 689 // in command line. 690 // make sure these properties overridden corectly 691 692 System.out.println("**** Test ten ****"); 693 694 int[] ports = PortAllocator.allocatePorts(2); 695 TestAppRun s = doTest( 696 "test_10", 697 "-Dcom.sun.management.jmxremote.authenticate=false", 698 "-Dcom.sun.management.jmxremote.ssl=true"); 699 700 try { 701 testNoConnect(ports[0]); 702 jcmd.start( 703 "jmxremote.port=" + ports[1], 704 "jmxremote.authenticate=false", 705 "jmxremote.ssl=false" 706 ); 707 testConnect(ports[1]); 708 } finally { 709 s.stop(); 710 } 711 } 712 713 static void test_11() throws Exception { 714 // Run an app with JMX enabled and with some properties set 715 // in command line. 716 // stop JMX agent and then start it again with different property values 717 // make sure these properties overridden corectly 718 719 System.out.println("**** Test eleven ****"); 720 int[] ports = PortAllocator.allocatePorts(2); 721 TestAppRun s = doTest( 722 "test_11", 723 "-Dcom.sun.management.jmxremote.port=" + ports[0], 724 "-Dcom.sun.management.jmxremote.authenticate=false", 725 "-Dcom.sun.management.jmxremote.ssl=true"); 726 727 try { 728 testNoConnect(ports[0]); 729 730 jcmd.stop(); 731 732 testNoConnect(ports[0]); 733 734 jcmd.start( 735 "jmxremote.port=" + ports[1], 736 "jmxremote.authenticate=false", 737 "jmxremote.ssl=false" 738 ); 739 740 testConnect(ports[1]); 741 } finally { 742 s.stop(); 743 } 744 } 745 746 static void test_12() throws Exception { 747 // Run an app with JMX enabled and with some properties set 748 // in command line. 749 // stop JMX agent and then start it again with different property values 750 // specifing some property in management config file and some of them 751 // in command line 752 // make sure these properties overridden corectly 753 754 System.out.println("**** Test twelve ****"); 755 756 int[] ports = PortAllocator.allocatePorts(2); 757 TestAppRun s = doTest("test_12", 758 "-Dcom.sun.management.config.file=" 759 + TEST_SRC + File.separator + "management_cl.properties", 760 "-Dcom.sun.management.jmxremote.authenticate=false" 761 ); 762 763 try { 764 testNoConnect(ports[0]); 765 766 jcmd.stop(); 767 768 testNoConnect(ports[0]); 769 770 jcmd.start( 771 "config.file=" + TEST_SRC + File.separator 772 + "management_jcmd.properties", 773 "jmxremote.authenticate=false", 774 "jmxremote.port=" + ports[1] 775 ); 776 777 testConnect(ports[1]); 778 } finally { 779 s.stop(); 780 } 781 } 782 783 static void test_13() throws Exception { 784 // Run an app with JMX enabled and with some properties set 785 // in command line. 786 // stop JMX agent and then start it again with different property values 787 // stop JMX agent again and then start it without property value 788 // make sure these properties overridden corectly 789 790 System.out.println("**** Test thirteen ****"); 791 int[] ports = PortAllocator.allocatePorts(1); 792 TestAppRun s = doTest( 793 "test_13", 794 "-Dcom.sun.management.jmxremote.port=" + ports[0], 795 "-Dcom.sun.management.jmxremote.authenticate=false", 796 "-Dcom.sun.management.jmxremote.ssl=true"); 797 798 try { 799 testNoConnect(ports[0]); 800 801 jcmd.stop(); 802 jcmd.start( 803 "jmxremote.ssl=false", 804 "jmxremote.port=" + ports[0] 805 ); 806 testConnect(ports[0]); 807 808 jcmd.stop(); 809 jcmd.start( 810 "jmxremote.port=" + ports[0] 811 ); 812 813 testNoConnect(ports[0]); 814 } finally { 815 s.stop(); 816 } 817 } 818 819 static void test_14() throws Exception { 820 // Run an app with JMX enabled 821 // stop remote agent 822 // make sure local agent is not affected 823 824 System.out.println("**** Test fourteen ****"); 825 int[] ports = PortAllocator.allocatePorts(1); 826 TestAppRun s = doTest( 827 "test_14", 828 "-Dcom.sun.management.jmxremote.port=" + ports[0], 829 "-Dcom.sun.management.jmxremote.authenticate=false", 830 "-Dcom.sun.management.jmxremote.ssl=false"); 831 try { 832 testConnect(ports[0]); 833 jcmd.stop(); 834 testConnectLocal(s.getPid()); 835 } finally { 836 s.stop(); 837 } 838 } 839 840 static void test_15() throws Exception { 841 // Run an app with JMX disabled 842 // start local agent only 843 844 System.out.println("**** Test fifteen ****"); 845 846 int[] ports = PortAllocator.allocatePorts(1); 847 TestAppRun s = doTest("test_15"); 848 849 try { 850 testNoConnect(ports[0]); 851 jcmd.startLocal(); 852 853 testConnectLocal(s.getPid()); 854 855 } finally { 856 s.stop(); 857 } 858 } 859 860 }