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