/** * @return Returns the expression. * @deprecated Use {@link #getScript()} instead. */ @Deprecated public String getExpression() { if (m_script == null) { return null; } return m_script.getExpression(); }
/** * @deprecated Use {@link #getScript()} instead. */ @Deprecated public String getExpression() { XmlScript script = getScript(); if (script == null) { return null; } return script.getExpression(); }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((m_className == null) ? 0 : m_className.hashCode()); if (getScript() != null) { result = prime * result + ((getScript().getExpression() == null) ? 0 : getScript().getExpression().hashCode()); result = prime * result + ((getScript().getLanguage() == null) ? 0 : getScript().getLanguage().hashCode()); } result = prime * result + m_priority; return result; }
public static ScriptMethodSelector getScriptSelector(XmlScript script) { if (script == null || script.getLanguage() == null) { throw new IllegalArgumentException("Language name must not be null"); } String languageName = script.getLanguage().toLowerCase(); ScriptEngineFactory engineFactory = ENGINE_FACTORIES.get(languageName); if (engineFactory == null) { ServiceLoader<ScriptEngineFactory> loader = ServiceLoader.load(ScriptEngineFactory.class); for (ScriptEngineFactory factory : loader) { ENGINE_FACTORIES.put(factory.getLanguageName().toLowerCase(), factory); } engineFactory = ENGINE_FACTORIES.get(languageName); } if (engineFactory == null) { throw new TestNGException("No engine found for language: " + script.getLanguage() + ". " + "Please check your dependencies and have a look at " + "https://github.com/cbeust/testng/wiki/Supported-script-engines"); } return new ScriptMethodSelector(engineFactory.getScriptEngine(), script.getExpression()); } }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return XmlSuite.f(); if (getClass() != obj.getClass()) return XmlSuite.f(); XmlMethodSelector other = (XmlMethodSelector) obj; if (m_className == null) { if (other.m_className != null) return XmlSuite.f(); } else if (!m_className.equals(other.m_className)) return XmlSuite.f(); if (getScript() == null || getScript().getExpression() == null) { if (other.getScript() != null && other.getScript().getExpression() != null) return XmlSuite.f(); } else if (!getScript().getExpression().equals(other.getScript() == null ? null : other.getScript().getExpression())) { return XmlSuite.f(); } if (getScript() == null || getScript().getLanguage() == null) { if (other.getScript() != null && other.getScript().getLanguage() != null) return XmlSuite.f(); } else if (!getScript().getLanguage().equals(other.getScript() == null ? null : other.getScript().getLanguage())) { return XmlSuite.f(); } if (m_priority != other.m_priority) return XmlSuite.f(); return true; } }
public String toXml(String indent) { XMLStringBuffer xsb = new XMLStringBuffer(indent); xsb.push("method-selector"); if (null != m_className) { Properties clsProp = new Properties(); clsProp.setProperty("name", getClassName()); if (getPriority() != -1) { clsProp.setProperty("priority", String.valueOf(getPriority())); } xsb.addEmptyElement("selector-class", clsProp); } else if (getScript() != null && getScript().getLanguage() != null) { Properties scriptProp = new Properties(); scriptProp.setProperty("language", getScript().getLanguage()); xsb.push("script", scriptProp); xsb.addCDATA(getScript().getExpression()); xsb.pop("script"); } else { throw new TestNGException("Invalid Method Selector: found neither class name nor language"); } xsb.pop("method-selector"); return xsb.toXML(); }