@Test public void testGetShortHostnameInvalidPattern() throws IOException { System.out.println("testGetShortHostnameInvalidPattern"); TestJMeterUtils.createJmeterEnv(); JMeterUtils.setProperty("jmeterPlugin.perfmon.label.useHostname.pattern", "([\\w\\-]+\\.region.*"); String host; host = JMeterPluginsUtils.getShortHostname("aaa-bbb-1234.region.com"); assertEquals("aaa-bbb-1234.region.com", host); }
public static String getShortHostname(String host) { log.debug("getShortHostname: " + host); try { String defaultRegex = "([\\w\\-]+)\\..*"; String hostnameRegex = JMeterUtils.getPropDefault("jmeterPlugin.perfmon.label.useHostname.pattern", defaultRegex); log.debug("hostnameRegex: " + hostnameRegex); Pattern p = Pattern.compile(hostnameRegex, Pattern.CASE_INSENSITIVE); Matcher m = p.matcher(host); if (m.matches()) { String shortName = m.group(1); log.debug("shortName of " + host + " is: " + shortName); host = shortName; } } catch (Exception e) { log.warn("getShortHostname exception: " + e.getClass().getName() + " :: " + e.getMessage()); log.debug("getShortHostname exception: ", e); } return host; }
JMeterPluginsUtils { public static String getShortHostname(String host) { log.debug("getShortHostname: " + host); try { String defaultRegex = "([\\w\\-]+)\\..*"; String hostnameRegex = JMeterUtils.getPropDefault("jmeterPlugin.perfmon.label.useHostname.pattern", defaultRegex); log.debug("hostnameRegex: " + hostnameRegex); Pattern p = Pattern.compile(hostnameRegex, Pattern.CASE_INSENSITIVE); Matcher m = p.matcher(host); if (m.matches()) { String shortName = m.group(1); log.debug("shortName of " + host + " is: " + shortName); host = shortName; } } catch (Exception e) { log.warn("getShortHostname exception: " + e.getClass().getName() + " :: " + e.getMessage()); log.debug("getShortHostname exception: ", e); } return host; } }
JMeterPluginsUtils { public static String getShortHostname(String host) { log.debug("getShortHostname: " + host); try { String defaultRegex = "([\\w\\-]+)\\..*"; String hostnameRegex = JMeterUtils.getPropDefault("jmeterPlugin.perfmon.label.useHostname.pattern", defaultRegex); log.debug("hostnameRegex: " + hostnameRegex); Pattern p = Pattern.compile(hostnameRegex, Pattern.CASE_INSENSITIVE); Matcher m = p.matcher(host); if (m.matches()) { String shortName = m.group(1); log.debug("shortName of " + host + " is: " + shortName); host = shortName; } } catch (Exception e) { log.warn("getShortHostname exception: " + e.getClass().getName() + " :: " + e.getMessage()); log.debug("getShortHostname exception: ", e); } return host; }  }
JMeterPluginsUtils { public static String getShortHostname(String host) { log.debug("getShortHostname: " + host); try { String defaultRegex = "([\\w\\-]+)\\..*"; String hostnameRegex = JMeterUtils.getPropDefault("jmeterPlugin.perfmon.label.useHostname.pattern", defaultRegex); log.debug("hostnameRegex: " + hostnameRegex); Pattern p = Pattern.compile(hostnameRegex, Pattern.CASE_INSENSITIVE); Matcher m = p.matcher(host); if (m.matches()) { String shortName = m.group(1); log.debug("shortName of " + host + " is: " + shortName); host = shortName; } } catch (Exception e) { log.warn("getShortHostname exception: " + e.getClass().getName() + " :: " + e.getMessage()); log.debug("getShortHostname exception: ", e); } return host; }  static String prefixLabel(String label); static String getStackTrace(Exception ex); static CollectionProperty tableModelRowsToCollectionProperty(PowerTableModel model, String propname); static CollectionProperty tableModelRowsToCollectionPropertyEval(PowerTableModel model, String propname); static void collectionPropertyToTableModelRows(CollectionProperty prop, PowerTableModel model); static void collectionPropertyToTableModelRows(CollectionProperty prop, PowerTableModel model, Class[] columnClasses); static String replaceRNT(String str); static String getWikiLinkText(String wikiPage); static String buildHelpPageUrl(String helpPage); static Component addHelpLinkToPanel(Container panel, String helpPage); static void doBestCSVSetup(SampleSaveConfiguration conf); static void openInBrowser(String string); static float getFloatFromString(String stringValue, float defaultValue); static int getSecondsForShortString(String string); static String getVersion(); static String getEnvDefault(String propName, String defaultVal); static void prepareJMeterEnv(String homeDir); static String getJMeterHomeFromCP(String classpathSTR); static String getShortHostname(String host); }
JMeterPluginsUtils { public static String getShortHostname(String host) { log.debug("getShortHostname: " + host); try { String defaultRegex = "([\\w\\-]+)\\..*"; String hostnameRegex = JMeterUtils.getPropDefault("jmeterPlugin.perfmon.label.useHostname.pattern", defaultRegex); log.debug("hostnameRegex: " + hostnameRegex); Pattern p = Pattern.compile(hostnameRegex, Pattern.CASE_INSENSITIVE); Matcher m = p.matcher(host); if (m.matches()) { String shortName = m.group(1); log.debug("shortName of " + host + " is: " + shortName); host = shortName; } } catch (Exception e) { log.warn("getShortHostname exception: " + e.getClass().getName() + " :: " + e.getMessage()); log.debug("getShortHostname exception: ", e); } return host; }  static String prefixLabel(String label); static String getStackTrace(Exception ex); static CollectionProperty tableModelRowsToCollectionProperty(PowerTableModel model, String propname); static CollectionProperty tableModelRowsToCollectionPropertyEval(PowerTableModel model, String propname); static void collectionPropertyToTableModelRows(CollectionProperty prop, PowerTableModel model); static void collectionPropertyToTableModelRows(CollectionProperty prop, PowerTableModel model, Class[] columnClasses); static String replaceRNT(String str); static String getWikiLinkText(String wikiPage); static String buildHelpPageUrl(String helpPage); static Component addHelpLinkToPanel(Container panel, String helpPage); static void doBestCSVSetup(SampleSaveConfiguration conf); static void openInBrowser(String string); static float getFloatFromString(String stringValue, float defaultValue); static int getSecondsForShortString(String string); static String getVersion(); static String getEnvDefault(String propName, String defaultVal); static void prepareJMeterEnv(String homeDir); static String getJMeterHomeFromCP(String classpathSTR); static String getShortHostname(String host); static final String WIKI_BASE; static final String ENCODING; static final Charset CHARSET; }