< prev index next >

test/jdk/jdk/jfr/event/runtime/TestActiveSettingEvent.java

Print this page


   1 /*
   2  * Copyright (c) 2017, 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.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 188         return false;
 189     }
 190 
 191     private static void testSettingConfiguration(String configurationName) throws Exception {
 192         System.out.println("Testing configuration " + configurationName);
 193         Configuration c = Configuration.getConfiguration(configurationName);
 194         Map<String, String> settingValues = c.getSettings();
 195         // Don't want to add these settings to the jfc-files we ship since they
 196         // are not useful to configure. They are however needed to make the test
 197         // pass.
 198         settingValues.put(EventNames.ActiveSetting + "#stackTrace", "false");
 199         settingValues.put(EventNames.ActiveSetting + "#threshold", "0 ns");
 200         settingValues.put(EventNames.ActiveRecording + "#stackTrace", "false");
 201         settingValues.put(EventNames.ActiveRecording + "#threshold", "0 ns");
 202         settingValues.put(EventNames.JavaExceptionThrow + "#threshold", "0 ns");
 203         settingValues.put(EventNames.JavaErrorThrow + "#threshold", "0 ns");
 204         settingValues.put(EventNames.SecurityProperty + "#threshold", "0 ns");
 205         settingValues.put(EventNames.TLSHandshake + "#threshold", "0 ns");
 206         settingValues.put(EventNames.X509Certificate + "#threshold", "0 ns");
 207         settingValues.put(EventNames.X509Validation + "#threshold", "0 ns");

 208 
 209         try (Recording recording = new Recording(c)) {
 210             Map<Long, EventType> eventTypes = new HashMap<>();
 211             for (EventType et : FlightRecorder.getFlightRecorder().getEventTypes()) {
 212                 eventTypes.put(et.getId(), et);
 213             }
 214             recording.start();
 215             Map<String, String> expectedSettings = new HashMap<>();
 216             for (EventType type : FlightRecorder.getFlightRecorder().getEventTypes()) {
 217                 for (SettingDescriptor s : type.getSettingDescriptors()) {
 218                     String settingName = type.getName() + "#" + s.getName();
 219                     String value = settingValues.get(settingName);
 220                     if (value == null) {
 221                         throw new Exception("Could not find setting with name " + settingName);
 222                     }
 223                     // Prefer to have ms unit in jfc file
 224                     if (value.equals("0 ms")) {
 225                         value = "0 ns";
 226                     }
 227                     expectedSettings.put(settingName, value);


   1 /*
   2  * Copyright (c) 2017, 2020, 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.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 188         return false;
 189     }
 190 
 191     private static void testSettingConfiguration(String configurationName) throws Exception {
 192         System.out.println("Testing configuration " + configurationName);
 193         Configuration c = Configuration.getConfiguration(configurationName);
 194         Map<String, String> settingValues = c.getSettings();
 195         // Don't want to add these settings to the jfc-files we ship since they
 196         // are not useful to configure. They are however needed to make the test
 197         // pass.
 198         settingValues.put(EventNames.ActiveSetting + "#stackTrace", "false");
 199         settingValues.put(EventNames.ActiveSetting + "#threshold", "0 ns");
 200         settingValues.put(EventNames.ActiveRecording + "#stackTrace", "false");
 201         settingValues.put(EventNames.ActiveRecording + "#threshold", "0 ns");
 202         settingValues.put(EventNames.JavaExceptionThrow + "#threshold", "0 ns");
 203         settingValues.put(EventNames.JavaErrorThrow + "#threshold", "0 ns");
 204         settingValues.put(EventNames.SecurityProperty + "#threshold", "0 ns");
 205         settingValues.put(EventNames.TLSHandshake + "#threshold", "0 ns");
 206         settingValues.put(EventNames.X509Certificate + "#threshold", "0 ns");
 207         settingValues.put(EventNames.X509Validation + "#threshold", "0 ns");
 208         settingValues.put(EventNames.ProcessStart + "#threshold", "0 ns");
 209 
 210         try (Recording recording = new Recording(c)) {
 211             Map<Long, EventType> eventTypes = new HashMap<>();
 212             for (EventType et : FlightRecorder.getFlightRecorder().getEventTypes()) {
 213                 eventTypes.put(et.getId(), et);
 214             }
 215             recording.start();
 216             Map<String, String> expectedSettings = new HashMap<>();
 217             for (EventType type : FlightRecorder.getFlightRecorder().getEventTypes()) {
 218                 for (SettingDescriptor s : type.getSettingDescriptors()) {
 219                     String settingName = type.getName() + "#" + s.getName();
 220                     String value = settingValues.get(settingName);
 221                     if (value == null) {
 222                         throw new Exception("Could not find setting with name " + settingName);
 223                     }
 224                     // Prefer to have ms unit in jfc file
 225                     if (value.equals("0 ms")) {
 226                         value = "0 ns";
 227                     }
 228                     expectedSettings.put(settingName, value);


< prev index next >