Path: blob/master/test/jdk/jdk/jfr/api/recording/settings/TestGetConfigurations.java
42103 views
/*1* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/22package jdk.jfr.api.recording.settings;2324import java.util.List;2526import jdk.jfr.Configuration;27import jdk.test.lib.Asserts;2829/**30* @test31* @summary Verifies that there is the default config and that it has32* the expected parameters33* @key jfr34* @requires vm.hasJFR35* @library /test/lib36* @run main/othervm jdk.jfr.api.recording.settings.TestGetConfigurations37*/38public class TestGetConfigurations {3940private static final String DEFAULT_CONFIG_NAME = "default";41private static final String DEFAULT_CONFIG_LABEL = "Continuous";42private static final String DEFAULT_CONFIG_DESCRIPTION = "Low overhead configuration safe for continuous use in production environments, typically less than 1 % overhead.";43private static final String DEFAULT_CONFIG_PROVIDER = "Oracle";4445private static final String PROFILE_CONFIG_NAME = "profile";46private static final String PROFILE_CONFIG_LABEL = "Profiling";47private static final String PROFILE_CONFIG_DESCRIPTION = "Low overhead configuration for profiling, typically around 2 % overhead.";48private static final String PROFILE_CONFIG_PROVIDER = "Oracle";4950public static void main(String[] args) throws Throwable {51List<Configuration> predefinedConfigs = Configuration.getConfigurations();52Asserts.assertNotNull(predefinedConfigs, "List of predefined configs is null");53Asserts.assertEquals(predefinedConfigs.size(), 2, "Expected exactly two predefined configurations");5455Configuration defaultConfig = findConfigByName(predefinedConfigs, DEFAULT_CONFIG_NAME);56Asserts.assertNotNull(defaultConfig, "Config '" + DEFAULT_CONFIG_NAME + "' not found");57Asserts.assertEquals(defaultConfig.getLabel(), DEFAULT_CONFIG_LABEL);58Asserts.assertEquals(defaultConfig.getDescription(), DEFAULT_CONFIG_DESCRIPTION);59Asserts.assertEquals(defaultConfig.getProvider(), DEFAULT_CONFIG_PROVIDER);6061Configuration profileConfig = findConfigByName(predefinedConfigs, PROFILE_CONFIG_NAME);62Asserts.assertNotNull(profileConfig, "Config '" + PROFILE_CONFIG_NAME + "' not found");63Asserts.assertEquals(profileConfig.getLabel(), PROFILE_CONFIG_LABEL);64Asserts.assertEquals(profileConfig.getDescription(), PROFILE_CONFIG_DESCRIPTION);65Asserts.assertEquals(profileConfig.getProvider(), PROFILE_CONFIG_PROVIDER);66}6768private static Configuration findConfigByName(List<Configuration> configs, String name) {69for (Configuration config : configs) {70if (name.equals(config.getName())) {71return config;72}73}74return null;75}7677}787980