[testng] 281/355: make guice stage configurable in suite xml tag
Eugene Zhukov
eugene-guest at moszumanska.debian.org
Tue Aug 18 10:20:15 UTC 2015
This is an automated email from the git hooks/post-receive script.
eugene-guest pushed a commit to annotated tag OpenBSD
in repository testng.
commit 1f23509ed2d8806b5bb8c85497fe7027eeee7745
Author: cguillaume <cguillaume at hotpads.com>
Date: Fri May 8 17:10:00 2015 -0700
make guice stage configurable in suite xml tag
---
src/main/java/org/testng/ISuite.java | 2 ++
src/main/java/org/testng/SuiteRunner.java | 5 +++++
src/main/java/org/testng/internal/ClassImpl.java | 12 ++++++++++--
src/main/java/org/testng/remote/SuiteDispatcher.java | 1 +
src/main/java/org/testng/xml/TestNGContentHandler.java | 4 ++++
src/main/java/org/testng/xml/XmlSuite.java | 13 +++++++++++++
src/main/resources/testng-1.0.dtd | 1 +
7 files changed, 36 insertions(+), 2 deletions(-)
diff --git a/src/main/java/org/testng/ISuite.java b/src/main/java/org/testng/ISuite.java
index 3ab5ed0..e5e3380 100755
--- a/src/main/java/org/testng/ISuite.java
+++ b/src/main/java/org/testng/ISuite.java
@@ -46,6 +46,8 @@ public interface ISuite extends IAttributes {
public String getParentModule();
+ public String getGuiceStage();
+
/**
* @return The value of this parameter, or null if none was specified.
*/
diff --git a/src/main/java/org/testng/SuiteRunner.java b/src/main/java/org/testng/SuiteRunner.java
index 94d78d4..fef2fa5 100644
--- a/src/main/java/org/testng/SuiteRunner.java
+++ b/src/main/java/org/testng/SuiteRunner.java
@@ -239,6 +239,11 @@ public class SuiteRunner implements ISuite, Serializable, IInvokedMethodListener
return m_suite.getParentModule();
}
+ @Override
+ public String getGuiceStage() {
+ return m_suite.getGuiceStage();
+ }
+
public Injector getParentInjector() {
return m_parentInjector;
}
diff --git a/src/main/java/org/testng/internal/ClassImpl.java b/src/main/java/org/testng/internal/ClassImpl.java
index 255a7c1..04daf65 100755
--- a/src/main/java/org/testng/internal/ClassImpl.java
+++ b/src/main/java/org/testng/internal/ClassImpl.java
@@ -139,15 +139,23 @@ public class ClassImpl implements IClass {
// Reuse the previous parent injector, if any
Injector injector = suite.getParentInjector();
if (injector == null) {
+ String stageString = suite.getGuiceStage();
+ Stage stage;
+ if (isStringNotEmpty(stageString)) {
+ stage = Stage.valueOf(stageString);
+ } else {
+ stage = Stage.DEVELOPMENT;
+ }
+ System.out.println(stage);
if (m_hasParentModule) {
Class<Module> parentModule = (Class<Module>) ClassHelper.forName(suite.getParentModule());
if (parentModule == null) {
throw new TestNGException("Cannot load parent Guice module class: " + parentModule);
}
Module module = newModule(parentModule);
- injector = com.google.inject.Guice.createInjector(Stage.DEVELOPMENT, module);
+ injector = com.google.inject.Guice.createInjector(stage, module);
} else {
- injector = com.google.inject.Guice.createInjector(Stage.DEVELOPMENT);
+ injector = com.google.inject.Guice.createInjector(stage);
}
suite.setParentInjector(injector);
}
diff --git a/src/main/java/org/testng/remote/SuiteDispatcher.java b/src/main/java/org/testng/remote/SuiteDispatcher.java
index f37bafa..65a08e6 100644
--- a/src/main/java/org/testng/remote/SuiteDispatcher.java
+++ b/src/main/java/org/testng/remote/SuiteDispatcher.java
@@ -115,6 +115,7 @@ public class SuiteDispatcher
tmpSuite.setName("Temporary suite for " + test.getName());
tmpSuite.setParallel(suite.getParallel());
tmpSuite.setParentModule(suite.getParentModule());
+ tmpSuite.setGuiceStage(suite.getGuiceStage());
tmpSuite.setParameters(suite.getParameters());
tmpSuite.setThreadCount(suite.getThreadCount());
tmpSuite.setDataProviderThreadCount(suite.getDataProviderThreadCount());
diff --git a/src/main/java/org/testng/xml/TestNGContentHandler.java b/src/main/java/org/testng/xml/TestNGContentHandler.java
index cfa4654..62951f3 100755
--- a/src/main/java/org/testng/xml/TestNGContentHandler.java
+++ b/src/main/java/org/testng/xml/TestNGContentHandler.java
@@ -164,6 +164,10 @@ public class TestNGContentHandler extends DefaultHandler {
if (parentModule != null) {
m_currentSuite.setParentModule(parentModule);
}
+ String guiceStage = attributes.getValue("guice-stage");
+ if (guiceStage != null) {
+ m_currentSuite.setGuiceStage(guiceStage);
+ }
String configFailurePolicy = attributes.getValue("configfailurepolicy");
if (null != configFailurePolicy) {
if (XmlSuite.SKIP.equals(configFailurePolicy) || XmlSuite.CONTINUE.equals(configFailurePolicy)) {
diff --git a/src/main/java/org/testng/xml/XmlSuite.java b/src/main/java/org/testng/xml/XmlSuite.java
index 32e0b64..4efd874 100755
--- a/src/main/java/org/testng/xml/XmlSuite.java
+++ b/src/main/java/org/testng/xml/XmlSuite.java
@@ -63,6 +63,7 @@ public class XmlSuite implements Serializable, Cloneable {
private String m_parallel = DEFAULT_PARALLEL;
private String m_parentModule = "";
+ private String m_guiceStage = "";
/** Whether to SKIP or CONTINUE to re-attempt failed configuration methods. */
public static String DEFAULT_CONFIG_FAILURE_POLICY = SKIP;
@@ -163,6 +164,10 @@ public class XmlSuite implements Serializable, Cloneable {
return m_parentModule;
}
+ public String getGuiceStage() {
+ return m_guiceStage;
+ }
+
public ITestObjectFactory getObjectFactory() {
return m_objectFactory;
}
@@ -183,6 +188,10 @@ public class XmlSuite implements Serializable, Cloneable {
m_parentModule = parentModule;
}
+ public void setGuiceStage(String guiceStage) {
+ m_guiceStage = guiceStage;
+ }
+
/**
* Sets the configuration failure policy.
* @param configFailurePolicy the config failure policy
@@ -458,6 +467,9 @@ public class XmlSuite implements Serializable, Cloneable {
if (isStringNotEmpty(m_parentModule)) {
p.setProperty("parent-module", getParentModule());
}
+ if (isStringNotEmpty(m_guiceStage)) {
+ p.setProperty("guice-stage", getGuiceStage());
+ }
XmlUtils.setProperty(p, "allow-return-values", String.valueOf(getAllowReturnValues()),
DEFAULT_ALLOW_RETURN_VALUES.toString());
xsb.push("suite", p);
@@ -587,6 +599,7 @@ public class XmlSuite implements Serializable, Cloneable {
result.setListeners(getListeners());
result.setParallel(getParallel());
result.setParentModule(getParentModule());
+ result.setGuiceStage(getGuiceStage());
result.setConfigFailurePolicy(getConfigFailurePolicy());
result.setThreadCount(getThreadCount());
result.setDataProviderThreadCount(getDataProviderThreadCount());
diff --git a/src/main/resources/testng-1.0.dtd b/src/main/resources/testng-1.0.dtd
index 3e039f6..7993989 100755
--- a/src/main/resources/testng-1.0.dtd
+++ b/src/main/resources/testng-1.0.dtd
@@ -62,6 +62,7 @@ Cedric Beust & Alexandru Popescu
verbose CDATA #IMPLIED
parallel (false | methods | tests | classes | instances) "false"
parent-module CDATA #IMPLIED
+ guice-stage CDATA #IMPLIED
configfailurepolicy (skip | continue) "skip"
thread-count CDATA "5"
annotations CDATA #IMPLIED
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/testng.git
More information about the pkg-java-commits
mailing list