Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/jdk/jfr/api/recording/settings/TestGetConfigurations.java
42103 views
1
/*
2
* Copyright (c) 2016, 2018, 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
package jdk.jfr.api.recording.settings;
24
25
import java.util.List;
26
27
import jdk.jfr.Configuration;
28
import jdk.test.lib.Asserts;
29
30
/**
31
* @test
32
* @summary Verifies that there is the default config and that it has
33
* the expected parameters
34
* @key jfr
35
* @requires vm.hasJFR
36
* @library /test/lib
37
* @run main/othervm jdk.jfr.api.recording.settings.TestGetConfigurations
38
*/
39
public class TestGetConfigurations {
40
41
private static final String DEFAULT_CONFIG_NAME = "default";
42
private static final String DEFAULT_CONFIG_LABEL = "Continuous";
43
private static final String DEFAULT_CONFIG_DESCRIPTION = "Low overhead configuration safe for continuous use in production environments, typically less than 1 % overhead.";
44
private static final String DEFAULT_CONFIG_PROVIDER = "Oracle";
45
46
private static final String PROFILE_CONFIG_NAME = "profile";
47
private static final String PROFILE_CONFIG_LABEL = "Profiling";
48
private static final String PROFILE_CONFIG_DESCRIPTION = "Low overhead configuration for profiling, typically around 2 % overhead.";
49
private static final String PROFILE_CONFIG_PROVIDER = "Oracle";
50
51
public static void main(String[] args) throws Throwable {
52
List<Configuration> predefinedConfigs = Configuration.getConfigurations();
53
Asserts.assertNotNull(predefinedConfigs, "List of predefined configs is null");
54
Asserts.assertEquals(predefinedConfigs.size(), 2, "Expected exactly two predefined configurations");
55
56
Configuration defaultConfig = findConfigByName(predefinedConfigs, DEFAULT_CONFIG_NAME);
57
Asserts.assertNotNull(defaultConfig, "Config '" + DEFAULT_CONFIG_NAME + "' not found");
58
Asserts.assertEquals(defaultConfig.getLabel(), DEFAULT_CONFIG_LABEL);
59
Asserts.assertEquals(defaultConfig.getDescription(), DEFAULT_CONFIG_DESCRIPTION);
60
Asserts.assertEquals(defaultConfig.getProvider(), DEFAULT_CONFIG_PROVIDER);
61
62
Configuration profileConfig = findConfigByName(predefinedConfigs, PROFILE_CONFIG_NAME);
63
Asserts.assertNotNull(profileConfig, "Config '" + PROFILE_CONFIG_NAME + "' not found");
64
Asserts.assertEquals(profileConfig.getLabel(), PROFILE_CONFIG_LABEL);
65
Asserts.assertEquals(profileConfig.getDescription(), PROFILE_CONFIG_DESCRIPTION);
66
Asserts.assertEquals(profileConfig.getProvider(), PROFILE_CONFIG_PROVIDER);
67
}
68
69
private static Configuration findConfigByName(List<Configuration> configs, String name) {
70
for (Configuration config : configs) {
71
if (name.equals(config.getName())) {
72
return config;
73
}
74
}
75
return null;
76
}
77
78
}
79
80