author | ssadetsky |
Mon, 24 Apr 2017 07:10:37 -0700 | |
changeset 45013 | 03094cd3458e |
parent 25182 | 1f6766bac82c |
permissions | -rw-r--r-- |
2 | 1 |
/* |
21367
679b312e3c5b
8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
5506
diff
changeset
|
2 |
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. |
2 | 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 |
* |
|
5506 | 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. |
|
2 | 22 |
*/ |
23 |
||
24 |
/* |
|
25 |
* |
|
26 |
* |
|
21367
679b312e3c5b
8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
5506
diff
changeset
|
27 |
* A test "application" used by unit tests - |
679b312e3c5b
8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
5506
diff
changeset
|
28 |
* LocalManagementTest.java, CustomLauncherTest.java. |
25182
1f6766bac82c
8048193: [tests] Replace JPS and stdout based PID retrieval by Process.getPid()
jbachorik
parents:
21367
diff
changeset
|
29 |
* This application binds to some random port, prints the port number |
1f6766bac82c
8048193: [tests] Replace JPS and stdout based PID retrieval by Process.getPid()
jbachorik
parents:
21367
diff
changeset
|
30 |
* to standard output, waits for somebody to connect, and then shuts down. |
2 | 31 |
*/ |
32 |
import java.io.IOException; |
|
33 |
import java.net.ServerSocket; |
|
34 |
import java.net.Socket; |
|
35 |
||
36 |
public class TestApplication { |
|
37 |
public static void main(String[] args) throws IOException { |
|
38 |
// Some tests require the application to exit immediately |
|
39 |
if (args.length > 0 && args[0].equals("-exit")) { |
|
40 |
return; |
|
41 |
} |
|
42 |
||
43 |
// bind to a random port |
|
44 |
ServerSocket ss = new ServerSocket(0); |
|
45 |
int port = ss.getLocalPort(); |
|
46 |
||
21367
679b312e3c5b
8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
5506
diff
changeset
|
47 |
// signal test that we are started - do not remove these lines!! |
679b312e3c5b
8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
5506
diff
changeset
|
48 |
System.out.println("port:" + port); |
679b312e3c5b
8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
5506
diff
changeset
|
49 |
System.out.println("waiting for the manager ..."); |
2 | 50 |
System.out.flush(); |
51 |
||
52 |
// wait for manager to connect |
|
53 |
Socket s = ss.accept(); |
|
54 |
s.close(); |
|
55 |
ss.close(); |
|
56 |
} |
|
57 |
} |