Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/sun/management/jdp/JdpOffTestCase.java
41149 views
1
/*
2
* Copyright (c) 2013, 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
/**
25
* A JVM with JDP off should not send multicast JDP packets at all.
26
* com.sun.management.jmxremote.autodiscovery=false should be respected.
27
*/
28
29
import java.net.SocketTimeoutException;
30
import java.util.Map;
31
32
public class JdpOffTestCase extends JdpTestCase {
33
34
private boolean testPassed = false;
35
36
public JdpOffTestCase(ClientConnection connection) {
37
super(connection);
38
}
39
40
/**
41
* Subclasses: JdpOnTestCase and JdpOffTestCase have different messages.
42
*/
43
@Override
44
protected String initialLogMessage() {
45
return "Expecting NOT to receive any packets with jdp.name=" + connection.instanceName;
46
}
47
48
/**
49
* The socket has not received anything, and this is the expected behavior.
50
*/
51
@Override
52
protected void onSocketTimeOut(SocketTimeoutException e) throws Exception {
53
log.fine("No packages received. Test passed!");
54
testPassed = true;
55
}
56
57
/**
58
* The socket did not timeout and no valid JDP packets were received.
59
*/
60
@Override
61
protected void shutdown() throws Exception {
62
log.fine("Test timed out. Test passed!");
63
testPassed = true;
64
}
65
66
/**
67
* This method is executed after a correct Jdp packet, coming from this VM has been received.
68
*
69
* @param payload A dictionary containing the data if the received Jdp packet.
70
*/
71
@Override
72
protected void packetFromThisVMReceived(Map<String, String> payload) throws Exception {
73
String message = "Jdp packet from this VM received. This should not happen!";
74
log.severe(message);
75
throw new Exception(message);
76
}
77
78
79
/**
80
* The test should stop after the socket has timed out. See onSocketTimeOut {@link}.
81
*/
82
@Override
83
protected boolean shouldContinue() {
84
return !testPassed;
85
}
86
87
public static void main(String[] args) throws Exception {
88
JdpTestCase client = new JdpOffTestCase(new ClientConnection());
89
client.run();
90
}
91
92
}
93
94