Permalink
Browse files

Get the YAML tests to pass, changed a few equals() methods.

Also removed setBeanShellExpression from XmlSuite (should do the same
for XmlTest down the road).
  • Loading branch information...
1 parent 1bc72f1 commit 8fd509b2846a41f0ba428bd2e99e33a3611fc490 @cbeust committed Jan 10, 2011
View
9 .classpath
@@ -5,9 +5,10 @@
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="lib/ant-1.6.5.jar"/>
<classpathentry kind="lib" path="lib/guice-2.0.jar"/>
- <classpathentry kind="lib" path="lib/junit-3.8.1.jar"/>
- <classpathentry kind="lib" path="lib/jcommander-1.13.jar"/>
- <classpathentry kind="lib" path="lib/bsh-2.0b4.jar"/>
- <classpathentry kind="output" path="eclipse-build"/>
+ <classpathentry kind="lib" path="lib/junit-3.8.1.jar" sourcepath="/Users/cbeust/.m2/repository/junit/junit/3.8.1/junit-3.8.1-sources.jar"/>
+ <classpathentry kind="lib" path="lib/jcommander-1.13.jar"/>
+ <classpathentry kind="lib" path="lib/bsh-2.0b4.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/jbus"/>
+ <classpathentry kind="lib" path="lib/snakeyaml-1.6.jar" sourcepath="/Users/cbeust/.m2/repository/org/yaml/snakeyaml/1.6/snakeyaml-1.6-sources.jar"/>
+ <classpathentry kind="output" path="eclipse-build"/>
</classpath>
View
3 src/main/java/org/testng/xml/TestNGContentHandler.java
@@ -224,9 +224,6 @@ private void xmlScript(boolean start, Attributes attributes) {
if (m_inTest) {
m_currentTest.setBeanShellExpression(m_currentExpression);
}
- else {
- m_currentSuite.setBeanShellExpression(m_currentExpression);
- }
m_currentLanguage = null;
m_currentExpression = null;
}
View
4 src/main/java/org/testng/xml/XmlClass.java
@@ -27,7 +27,7 @@
private boolean m_loadClasses = true;
public XmlClass() {
- init("", null, 0, true /* load classes */);
+ init("", null, 0, false /* load classes */);
}
public XmlClass(String name) {
@@ -240,7 +240,7 @@ public boolean equals(Object obj) {
if (other.m_class != null) {
return false;
}
- } else if (!m_class.equals(other.m_class)) {
+ } else if (m_class != null && other.m_class != null && !m_class.equals(other.m_class)) {
return false;
} else if (other.m_loadClasses != m_loadClasses) {
return false;
View
79 src/main/java/org/testng/xml/XmlSuite.java
@@ -59,7 +59,7 @@
private Integer m_verbose = null;
public static String DEFAULT_PARALLEL = "false";
- private String m_parallel = null;
+ private String m_parallel = DEFAULT_PARALLEL;
/** Whether to SKIP or CONTINUE to re-attempt failed configuration methods. */
public static String DEFAULT_CONFIG_FAILURE_POLICY = SKIP;
@@ -248,35 +248,6 @@ public void setMethodSelectors(List<XmlMethodSelector> methodSelectors) {
}
/**
- * Sets the bean shell expression.
- *
- * @param expression the bean shell expression.
- */
- public void setBeanShellExpression(String expression) {
- m_expression = expression;
- }
-
- /**
- * Returns the bean shell expression.
- *
- * @return the bean shell expression.
- * @deprecated use getBeanShelltExpression()
- */
- @Deprecated
- public String getExpression() {
- return m_expression;
- }
-
- /**
- * Returns the bean shell expression.
- *
- * @return the bean shell expression.
- */
- public String getBeanShellExpression() {
- return m_expression;
- }
-
- /**
* Updates the list of parameters that apply to this XML suite. This method
* should be invoked any time there is a change in the state of this suite that
* would affect the parameter list.<br>
@@ -591,7 +562,7 @@ public Object clone() {
result.setParameters(getAllParameters());
result.setVerbose(getVerbose());
result.setXmlPackages(getXmlPackages());
- result.setBeanShellExpression(getExpression());
+// result.setBeanShellExpression(getExpression());
result.setMethodSelectors(getMethodSelectors());
result.setJUnit(isJUnit()); // TESTNG-141
result.setSkipFailedInvocationCounts(skipFailedInvocationCounts());
@@ -746,82 +717,82 @@ public boolean equals(Object obj) {
return true;
}
if (obj == null) {
- return false;
+ return f();
}
if (getClass() != obj.getClass()) {
- return false;
+ return f();
}
XmlSuite other = (XmlSuite) obj;
// if (m_childSuites == null) {
// if (other.m_childSuites != null)
-// return false;
+// return f();
// } else if (!m_childSuites.equals(other.m_childSuites))
-// return false;
+// return f();
if (m_configFailurePolicy == null) {
if (other.m_configFailurePolicy != null) {
- return false;
+ return f();
}
} else if (!m_configFailurePolicy.equals(other.m_configFailurePolicy)) {
- return false;
+ return f();
}
if (m_dataProviderThreadCount != other.m_dataProviderThreadCount) {
- return false;
+ return f();
}
if (m_expression == null) {
if (other.m_expression != null) {
- return false;
+ return f();
}
} else if (!m_expression.equals(other.m_expression)) {
- return false;
+ return f();
}
if (m_isJUnit == null) {
if (other.m_isJUnit != null) {
- return false;
+ return f();
}
} else if (!m_isJUnit.equals(other.m_isJUnit)) {
- return false;
+ return f();
}
if (m_listeners == null) {
if (other.m_listeners != null) {
- return false;
+ return f();
}
} else if (!m_listeners.equals(other.m_listeners)) {
- return false;
+ return f();
}
if (m_methodSelectors == null) {
if (other.m_methodSelectors != null) {
- return false;
+ return f();
}
} else if (!m_methodSelectors.equals(other.m_methodSelectors)) {
- return false;
+ return f();
}
if (m_name == null) {
if (other.m_name != null) {
- return false;
+ return f();
}
} else if (!m_name.equals(other.m_name)) {
- return false;
+ return f();
}
if (m_objectFactory == null) {
if (other.m_objectFactory != null) {
- return false;
+ return f();
}
} else if (!m_objectFactory.equals(other.m_objectFactory)) {
- return false;
+ return f();
}
if (m_parallel == null) {
if (other.m_parallel != null) {
- return false;
+ return f();
}
} else if (!m_parallel.equals(other.m_parallel)) {
- return false;
+ return f();
}
if (m_parameters == null) {
if (other.m_parameters != null) {
- return false;
+ return f();
}
} else if (!m_parameters.equals(other.m_parameters)) {
- return false;
+ return f();
}
// if (m_parentSuite == null) {
// if (other.m_parentSuite != null)
View
27 src/main/java/org/testng/xml/XmlTest.java
@@ -28,7 +28,7 @@
private XmlSuite m_suite;
private String m_name = TestNG.DEFAULT_COMMAND_LINE_SUITE_NAME;
private Integer m_verbose = XmlSuite.DEFAULT_VERBOSE;
- private Boolean m_isJUnit = null;
+ private Boolean m_isJUnit = XmlSuite.DEFAULT_JUNIT;
private int m_threadCount= -1;
private List<XmlClass> m_xmlClasses = Lists.newArrayList();
@@ -43,8 +43,6 @@
/** */
private AnnotationTypeEnum m_annotations;
- // BeanShell expression
- private String m_expression;
private List<XmlMethodSelector> m_methodSelectors = Lists.newArrayList();
// test level packages
private List<XmlPackage> m_xmlPackages = Lists.newArrayList();
@@ -361,12 +359,29 @@ public void setAnnotations(String annotations) {
m_annotations = AnnotationTypeEnum.valueOf(annotations);
}
+ public void setExpression(String expression) {
+ setBeanShellExpression(expression);
+ }
+
public void setBeanShellExpression(String expression) {
- m_expression = expression;
+ List<XmlMethodSelector> selectors = getMethodSelectors();
+ if (selectors.size() > 0) {
+ selectors.get(0).setExpression(expression);
+ } else if (expression != null) {
+ XmlMethodSelector xms = new XmlMethodSelector();
+ xms.setExpression(expression);
+ xms.setLanguage("BeanShell");
+ getMethodSelectors().add(xms);
+ }
}
public String getExpression() {
- return m_expression;
+ List<XmlMethodSelector> selectors = getMethodSelectors();
+ if (selectors.size() > 0) {
+ return selectors.get(0).getExpression();
+ } else {
+ return null;
+ }
}
public String toXml(String indent) {
@@ -608,8 +623,6 @@ public int hashCode() {
int result = 1;
result = prime * result
+ ((m_excludedGroups == null) ? 0 : m_excludedGroups.hashCode());
- result = prime * result
- + ((m_expression == null) ? 0 : m_expression.hashCode());
result = prime
* result
+ ((m_failedInvocationNumbers == null) ? 0 : m_failedInvocationNumbers
View
7 src/test/java/test/yaml/YamlTest.java
@@ -1,7 +1,6 @@
package test.yaml;
-import javax.xml.parsers.ParserConfigurationException;
-
+import org.testng.Assert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import org.testng.xml.Parser;
@@ -10,12 +9,12 @@
import test.SimpleBaseTest;
+import javax.xml.parsers.ParserConfigurationException;
+
import java.io.File;
import java.io.IOException;
import java.util.Collection;
-import junit.framework.Assert;
-
public class YamlTest extends SimpleBaseTest {
@DataProvider
View
7 src/test/resources/testng.xml
@@ -621,5 +621,10 @@
<package name="org.testng.internal.invokers"/>
</packages>
</test>
-
+
+ <test name="YAML">
+ <classes>
+ <class name="test.yaml.YamlTest" />
+ </classes>
+ </test>
</suite>

0 comments on commit 8fd509b

Please sign in to comment.