[testng] 01/01: update to the new upstream release 6.8.8
Eugene Zhukov
eugene-guest at moszumanska.debian.org
Fri Mar 14 12:23:14 UTC 2014
This is an automated email from the git hooks/post-receive script.
eugene-guest pushed a commit to branch master
in repository testng.
commit c914c5e31b31e80d72b837d125192df48f3407f8
Author: Eugene Zhukov <jevgeni.zh at gmail.com>
Date: Fri Mar 14 12:22:27 2014 +0000
update to the new upstream release 6.8.8
---
build-tests.xml | 1 +
build.properties | 2 +-
debian/changelog | 9 +++
debian/control | 8 +--
doc/documentation-main.html | 66 ++++++++++++++++++++++
doc/download.html | 3 +-
pom-test.xml | 7 ++-
pom.xml | 5 +-
src/main/java/org/testng/ISuite.java | 14 ++++-
src/main/java/org/testng/SuiteRunner.java | 14 +++++
.../java/org/testng/internal/BaseTestMethod.java | 4 +-
src/main/java/org/testng/internal/ClassImpl.java | 66 +++++++++++++---------
src/main/java/org/testng/internal/Version.java | 2 +-
.../annotations/JDK15AnnotationFinder.java | 3 +-
.../java/org/testng/remote/SuiteDispatcher.java | 1 +
.../java/org/testng/xml/TestNGContentHandler.java | 41 +++++++++-----
src/main/java/org/testng/xml/XmlSuite.java | 15 +++++
src/main/resources/testng-1.0.dtd | 1 +
src/test/java/test/guice/GuiceParentModule.java | 13 +++++
.../java/test/guice/GuiceParentModuleTest.java | 22 ++++++++
src/test/java/test/guice/GuiceTestModule.java | 18 ++++++
src/test/java/test/guice/MyContext.java | 6 ++
src/test/java/test/guice/MyContextImpl.java | 11 ++++
src/test/java/test/guice/MyService.java | 6 ++
src/test/java/test/guice/MyServiceProvider.java | 15 +++++
src/test/java/test/guice/MySession.java | 5 ++
src/test/resources/parent-module-suite.xml | 9 +++
src/test/resources/testng.xml | 2 +
upload-beta | 4 +-
29 files changed, 316 insertions(+), 57 deletions(-)
diff --git a/build-tests.xml b/build-tests.xml
index 3b3485d..d0ccfd7 100644
--- a/build-tests.xml
+++ b/build-tests.xml
@@ -15,6 +15,7 @@
<pathelement location="${testng.jar}" />
<fileset dir="${lib.dir}" includes="${guice2.jar}" />
<fileset dir="${lib.dir}" includes="${junit.jar}" />
+ <fileset dir="${lib.dir}" includes="aopalliance-1.0.jar" />
</path>
<target name="env:info">
diff --git a/build.properties b/build.properties
index c6c2ea7..1840023 100644
--- a/build.properties
+++ b/build.properties
@@ -2,7 +2,7 @@
# TestNG distribution
#
testng.basename=testng
-testng.version=6.8.7beta
+testng.version=6.8.8
testng.fullname=${testng.basename}-${testng.version}
#
diff --git a/debian/changelog b/debian/changelog
index 965e28d..b6366bb 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,12 @@
+testng (6.8.8-1) unstable; urgency=low
+
+ * Team upload
+ * New upstream release
+ * Removed orig-tar.sh in favor of jh_repack in d/watch
+ * Standards-Version updated to version 3.9.5
+
+ -- Eugene Zhukov <jevgeni.zh at gmail.com> Fri, 14 Mar 2014 12:08:55 +0000
+
testng (6.8.7-2) unstable; urgency=low
* Team upload
diff --git a/debian/control b/debian/control
index 02c5b96..221eda6 100644
--- a/debian/control
+++ b/debian/control
@@ -4,12 +4,12 @@ Priority: optional
Maintainer: Debian Java Maintainers <pkg-java-maintainers at lists.alioth.debian.org>
Uploaders: Eugene Zhukov <jevgeni.zh at gmail.com>
Build-Depends: debhelper (>= 7), cdbs, default-jdk, maven-debian-helper (>= 1.5)
-Build-Depends-Indep: libmaven-bundle-plugin-java, bsh, junit4, libguice-java, libjcommander-java,
- libyaml-snake-java
-Standards-Version: 3.9.4
+Build-Depends-Indep: libmaven-bundle-plugin-java, bsh, junit4, libguice-java,
+ libjcommander-java, libyaml-snake-java
+Standards-Version: 3.9.5
Vcs-Git: git://anonscm.debian.org/pkg-java/testng.git
Vcs-Browser: http://anonscm.debian.org/gitweb/?p=pkg-java/testng.git
-Homepage: http://testng.org
+Homepage: http://testng.org
Package: testng
Architecture: all
diff --git a/doc/documentation-main.html b/doc/documentation-main.html
index 0a8bd32..4473eb5 100644
--- a/doc/documentation-main.html
+++ b/doc/documentation-main.html
@@ -2226,7 +2226,73 @@ public interface IModuleFactory {
Your factory will be passed an instance of the test context and the test class that TestNG needs to instantiate. Your <tt>createModule</tt> method should return a Guice Module that will know how to instantiate this test class. You can use the test context to find out more information about your environment, such as parameters specified in <tt>testng.xml</tt>, etc...
+You will get even more flexibility and Guice power with parent-module suite parameter. Here is how you can define parent-module in your test.xml file:
+<pre class="brush: xml">
+<suite parent-module="com.example.SuiteParenModule">
+</suite>
+</pre>
+
+TestNG will create this module only once for given suite. Will also use this module for obtaining instances of test specific Guice modules and module factories, then will create child injector for each test class.
+
+With such approach you can declare all common bindings in parent-module also you can inject binding declared in parent-module in module and module factory. Here is an example of this functionality:
+
+<pre class="brush: java">
+package com.example;
+
+public class ParentModule extends AbstractModule {
+ @Override
+ protected void conigure() {
+ bind(MyService.class).toProvider(MyServiceProvider.class);
+ bind(MyContext.class).to(MyContextImpl.class).in(Singleton.class);
+ }
+}
+</pre>
+
+<pre class="brush: java">
+package com.example;
+
+public class TestModule extends AbstractModule {
+ private final MyContext myContext;
+
+ @Inject
+ TestModule(MyContext myContext) {
+ this.myContext = myContext
+ }
+
+ @Override
+ protected void configure() {
+ bind(MySession.class).toInstance(myContext.getSession());
+ }
+}
+</pre>
+
+<pre class="brush: xml">
+<suite parent-module="com.example.ParentModule">
+</suite>
+</pre>
+
+<pre class="brush: java">
+package com.example;
+
+ at Test
+ at Guice(modules = TestModule.class)
+public class TestClass {
+ @Inject
+ MyService myService;
+ @Inject
+ MySession mySession;
+
+ public void testServiceWithSession() {
+ myService.serve(mySession);
+ }
+}
+</pre>
+
+As you see ParentModule declares binding for MyService and MyContext classes. Then MyContext is injected using constructor injection into TestModule class, which also declare binding for MySession. Then parent-module in test XML file is set to ParentModule class, this enables injection in TestModule. Later in TestClass you see two injections:
+ * MyService - binding taken from ParentModule
+ * MySession - binding taken from TestModule
+This configuration ensures you that all tests in this suite will be run with same session instance, the MyContextImpl object is only created once per suite, this give you possibility to configure common environment state for all tests in suite.
<!-------------------------------------
INVOKED METHOD LISTENERS
diff --git a/doc/download.html b/doc/download.html
index da8070c..8d73e9c 100644
--- a/doc/download.html
+++ b/doc/download.html
@@ -39,8 +39,7 @@
<pre class="brush: plain">
$ git clone git://github.com/cbeust/testng.git
$ cd testng
-$ cp ivy-2.1.0.jar ~/.ant/lib
-$ ant
+$ mvn package
</pre>
<p>You will then find the jar file in the <tt>target</tt> directory</p>
diff --git a/pom-test.xml b/pom-test.xml
index 0af9d07..8a29968 100644
--- a/pom-test.xml
+++ b/pom-test.xml
@@ -65,9 +65,14 @@
<version>1.27</version>
</dependency>
<dependency>
+ <groupId>org.yaml</groupId>
+ <artifactId>snakeyaml</artifactId>
+ <version>1.12</version>
+ </dependency>
+ <dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
- <version>6.8.6-SNAPSHOT</version>
+ <version>6.8.8-SNAPSHOT</version>
<scope>test</scope>
</dependency>
</dependencies>
diff --git a/pom.xml b/pom.xml
index 7d424a2..7a380c3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -7,7 +7,7 @@
<artifactId>testng</artifactId>
<packaging>jar</packaging>
<name>TestNG</name>
- <version>6.8.7</version>
+ <version>6.8.8</version>
<description>TestNG is a testing framework.</description>
<url>http://testng.org</url>
@@ -60,6 +60,7 @@
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
+ <optional>true</optional>
</dependency>
<dependency>
<groupId>org.beanshell</groupId>
@@ -97,6 +98,7 @@
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
+ <optional>true</optional>
</dependency>
<dependency>
@@ -125,6 +127,7 @@
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>1.12</version>
+ <optional>true</optional>
</dependency>
</dependencies>
diff --git a/src/main/java/org/testng/ISuite.java b/src/main/java/org/testng/ISuite.java
index e24587f..3ab5ed0 100755
--- a/src/main/java/org/testng/ISuite.java
+++ b/src/main/java/org/testng/ISuite.java
@@ -1,13 +1,15 @@
package org.testng;
-import org.testng.internal.annotations.IAnnotationFinder;
-import org.testng.xml.XmlSuite;
-
import java.util.Collection;
import java.util.List;
import java.util.Map;
+import org.testng.internal.annotations.IAnnotationFinder;
+import org.testng.xml.XmlSuite;
+
+import com.google.inject.Injector;
+
/**
* Interface defining a Test Suite.
*
@@ -42,6 +44,8 @@ public interface ISuite extends IAttributes {
*/
public String getParallel();
+ public String getParentModule();
+
/**
* @return The value of this parameter, or null if none was specified.
*/
@@ -103,6 +107,10 @@ public interface ISuite extends IAttributes {
public void addListener(ITestNGListener listener);
+ public Injector getParentInjector();
+
+ public void setParentInjector(Injector injector);
+
/**
* @return the total number of methods found in this suite. The presence of
* factories or data providers might cause the actual number of test methods
diff --git a/src/main/java/org/testng/SuiteRunner.java b/src/main/java/org/testng/SuiteRunner.java
index 5919893..d1fa95c 100644
--- a/src/main/java/org/testng/SuiteRunner.java
+++ b/src/main/java/org/testng/SuiteRunner.java
@@ -27,6 +27,7 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import com.google.inject.Injector;
/**
* <CODE>SuiteRunner</CODE> is responsible for running all the tests included in one
@@ -48,6 +49,7 @@ public class SuiteRunner implements ISuite, Serializable, IInvokedMethodListener
private String m_outputDir; // DEFAULT_OUTPUT_DIR;
private XmlSuite m_suite;
+ private Injector m_parentInjector;
transient private List<ITestListener> m_testListeners = Lists.newArrayList();
transient private ITestRunnerFactory m_tmpRunnerFactory;
@@ -233,6 +235,18 @@ public class SuiteRunner implements ISuite, Serializable, IInvokedMethodListener
return m_suite.getParallel();
}
+ public String getParentModule() {
+ return m_suite.getParentModule();
+ }
+
+ public Injector getParentInjector() {
+ return m_parentInjector;
+ }
+
+ public void setParentInjector(Injector injector) {
+ m_parentInjector = injector;
+ }
+
@Override
public void run() {
invokeListeners(true /* start */);
diff --git a/src/main/java/org/testng/internal/BaseTestMethod.java b/src/main/java/org/testng/internal/BaseTestMethod.java
index 8aa78a7..5257ebd 100755
--- a/src/main/java/org/testng/internal/BaseTestMethod.java
+++ b/src/main/java/org/testng/internal/BaseTestMethod.java
@@ -153,7 +153,9 @@ public abstract class BaseTestMethod implements ITestNGMethod {
int result = -2;
Class<?> thisClass = getRealClass();
Class<?> otherClass = ((ITestNGMethod) o).getRealClass();
- if (thisClass.isAssignableFrom(otherClass)) {
+ if (this == o) {
+ result = 0;
+ } else if (thisClass.isAssignableFrom(otherClass)) {
result = -1;
} else if (otherClass.isAssignableFrom(thisClass)) {
result = 1;
diff --git a/src/main/java/org/testng/internal/ClassImpl.java b/src/main/java/org/testng/internal/ClassImpl.java
index 2f6eabe..a687dce 100755
--- a/src/main/java/org/testng/internal/ClassImpl.java
+++ b/src/main/java/org/testng/internal/ClassImpl.java
@@ -1,10 +1,13 @@
package org.testng.internal;
+import static org.testng.internal.Utils.isStringNotEmpty;
+
import com.google.inject.Injector;
import com.google.inject.Module;
import org.testng.IClass;
import org.testng.IModuleFactory;
+import org.testng.ISuite;
import org.testng.ITest;
import org.testng.ITestContext;
import org.testng.ITestObjectFactory;
@@ -41,6 +44,7 @@ public class ClassImpl implements IClass {
private String m_testName = null;
private XmlClass m_xmlClass;
private ITestContext m_testContext;
+ private final boolean m_hasParentModule;
public ClassImpl(ITestContext context, Class cls, XmlClass xmlClass, Object instance,
Map<Class, IClass> classes, XmlTest xmlTest, IAnnotationFinder annotationFinder,
@@ -56,6 +60,7 @@ public class ClassImpl implements IClass {
if (instance instanceof ITest) {
m_testName = ((ITest) instance).getTestName();
}
+ m_hasParentModule = isStringNotEmpty(m_testContext.getSuite().getParentModule());
}
private static void ppp(String s) {
@@ -124,49 +129,58 @@ public class ClassImpl implements IClass {
private Object getInstanceFromGuice() {
Annotation annotation = AnnotationHelper.findAnnotationSuperClasses(Guice.class, m_class);
if (annotation == null) return null;
+ Injector parentInjector = getParentInjector();
Guice guice = (Guice) annotation;
- List<Module> moduleInstances = Lists.newArrayList(getModules(guice, m_class));
+ List<Module> moduleInstances = Lists.newArrayList(getModules(guice, parentInjector, m_class));
// Reuse the previous injector, if any
Injector injector = m_testContext.getInjector(moduleInstances);
if (injector == null) {
- injector = com.google.inject.Guice.createInjector(moduleInstances);
+ injector = parentInjector.createChildInjector(moduleInstances);
m_testContext.addInjector(moduleInstances, injector);
}
return injector.getInstance(m_class);
}
- private Module[] getModules(Guice guice, Class<?> testClass) {
+ public Injector getParentInjector() {
+ ISuite suite = m_testContext.getSuite();
+ // Reuse the previous parent injector, if any
+ Injector injector = suite.getParentInjector();
+ if (injector == null) {
+ if (m_hasParentModule) {
+ Class<?> parentModule = ClassHelper.forName(suite.getParentModule());
+ if (parentModule == null) {
+ throw new TestNGException("Cannot load parent Guice module class: " + parentModule);
+ }
+ Module module = (Module) ClassHelper.newInstance(parentModule);
+ injector = com.google.inject.Guice.createInjector(module);
+ } else {
+ injector = com.google.inject.Guice.createInjector();
+ }
+ suite.setParentInjector(injector);
+ }
+ return injector;
+ }
+
+ private Module[] getModules(Guice guice, Injector parentInejctor, Class<?> testClass) {
List<Module> result = Lists.newArrayList();
for (Class<? extends Module> moduleClass : guice.modules()) {
- try {
- List<Module> modules = m_testContext.getGuiceModules(moduleClass);
- if (modules != null && modules.size() > 0) {
- result.addAll(modules);
- } else {
- Module instance = moduleClass.newInstance();
- result.add(instance);
- m_testContext.addGuiceModule(moduleClass, instance);
- }
- } catch (InstantiationException e) {
- throw new TestNGException(e);
- } catch (IllegalAccessException e) {
- throw new TestNGException(e);
+ List<Module> modules = m_testContext.getGuiceModules(moduleClass);
+ if (modules != null && modules.size() > 0) {
+ result.addAll(modules);
+ } else {
+ Module instance = parentInejctor.getInstance(moduleClass);
+ result.add(instance);
+ m_testContext.addGuiceModule(moduleClass, instance);
}
}
Class<? extends IModuleFactory> factory = guice.moduleFactory();
if (factory != IModuleFactory.class) {
- try {
- IModuleFactory factoryInstance = factory.newInstance();
- Module moduleClass = factoryInstance.createModule(m_testContext, testClass);
- if (moduleClass != null) {
- result.add(moduleClass);
- }
- } catch (InstantiationException e) {
- throw new TestNGException(e);
- } catch (IllegalAccessException e) {
- throw new TestNGException(e);
+ IModuleFactory factoryInstance = parentInejctor.getInstance(factory);
+ Module moduleClass = factoryInstance.createModule(m_testContext, testClass);
+ if (moduleClass != null) {
+ result.add(moduleClass);
}
}
diff --git a/src/main/java/org/testng/internal/Version.java b/src/main/java/org/testng/internal/Version.java
index a6ba2d6..f861d9d 100644
--- a/src/main/java/org/testng/internal/Version.java
+++ b/src/main/java/org/testng/internal/Version.java
@@ -1,7 +1,7 @@
package org.testng.internal;
public class Version {
- public static final String VERSION = "6.8.2beta_20130330_0839";
+ public static final String VERSION = "6.8.9beta";
public static void displayBanner() {
System.out.println("...\n... TestNG " + VERSION + " by Cédric Beust (cedric at beust.com)\n...\n");
diff --git a/src/main/java/org/testng/internal/annotations/JDK15AnnotationFinder.java b/src/main/java/org/testng/internal/annotations/JDK15AnnotationFinder.java
index c313774..b3ef0bf 100755
--- a/src/main/java/org/testng/internal/annotations/JDK15AnnotationFinder.java
+++ b/src/main/java/org/testng/internal/annotations/JDK15AnnotationFinder.java
@@ -3,6 +3,7 @@ package org.testng.internal.annotations;
import java.lang.annotation.Annotation;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
+import java.util.Collections;
import java.util.Map;
import org.testng.IAnnotationTransformer;
@@ -46,7 +47,7 @@ import org.testng.internal.collections.Pair;
*/
public class JDK15AnnotationFinder implements IAnnotationFinder {
private JDK15TagFactory m_tagFactory = new JDK15TagFactory();
- private Map<Class<? extends IAnnotation>, Class<? extends Annotation>> m_annotationMap = Maps.newHashMap();
+ private Map<Class<? extends IAnnotation>, Class<? extends Annotation>> m_annotationMap = Collections.synchronizedMap(Maps.<Class<? extends IAnnotation>, Class<? extends Annotation>>newHashMap());
private IAnnotationTransformer m_transformer = null;
@SuppressWarnings({"deprecation"})
diff --git a/src/main/java/org/testng/remote/SuiteDispatcher.java b/src/main/java/org/testng/remote/SuiteDispatcher.java
index c5e9635..f37bafa 100644
--- a/src/main/java/org/testng/remote/SuiteDispatcher.java
+++ b/src/main/java/org/testng/remote/SuiteDispatcher.java
@@ -114,6 +114,7 @@ public class SuiteDispatcher
tmpSuite.setSkipFailedInvocationCounts(suite.skipFailedInvocationCounts());
tmpSuite.setName("Temporary suite for " + test.getName());
tmpSuite.setParallel(suite.getParallel());
+ tmpSuite.setParentModule(suite.getParentModule());
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 5a7d113..cfa4654 100755
--- a/src/main/java/org/testng/xml/TestNGContentHandler.java
+++ b/src/main/java/org/testng/xml/TestNGContentHandler.java
@@ -18,11 +18,7 @@ import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-import java.util.Map.Entry;
import java.util.Stack;
-import java.util.Properties;
-import java.util.HashMap;
-import java.util.Set;
/**
* Suite definition parser utility.
@@ -55,7 +51,8 @@ public class TestNGContentHandler extends DefaultHandler {
SUITE,
TEST,
CLASS,
- INCLUDE
+ INCLUDE,
+ EXCLUDE
}
private Stack<Location> m_locations = new Stack<Location>();
@@ -163,6 +160,10 @@ public class TestNGContentHandler extends DefaultHandler {
Utils.log("Parser", 1, "[WARN] Unknown value of attribute 'parallel' at suite level: '" + parallel + "'.");
}
}
+ String parentModule = attributes.getValue("parent-module");
+ if (parentModule != null) {
+ m_currentSuite.setParentModule(parentModule);
+ }
String configFailurePolicy = attributes.getValue("configfailurepolicy");
if (null != configFailurePolicy) {
if (XmlSuite.SKIP.equals(configFailurePolicy) || XmlSuite.CONTINUE.equals(configFailurePolicy)) {
@@ -574,15 +575,7 @@ public class TestNGContentHandler extends DefaultHandler {
xmlInclude(true, attributes);
}
else if ("exclude".equals(qName)) {
- if (null != m_currentExcludedMethods) {
- m_currentExcludedMethods.add(name);
- }
- else if (null != m_currentRuns) {
- m_currentExcludedGroups.add(name);
- }
- else if (null != m_currentPackage) {
- m_currentPackage.getExclude().add(name);
- }
+ xmlExclude(true, attributes);
}
else if ("parameter".equals(qName)) {
String value = expandValue(attributes.getValue("value"));
@@ -652,6 +645,24 @@ public class TestNGContentHandler extends DefaultHandler {
}
}
+ private void xmlExclude(boolean start, Attributes attributes) {
+ if (start) {
+ m_locations.push(Location.EXCLUDE);
+ String name = attributes.getValue("name");
+ if (null != m_currentExcludedMethods) {
+ m_currentExcludedMethods.add(name);
+ }
+ else if (null != m_currentRuns) {
+ m_currentExcludedGroups.add(name);
+ }
+ else if (null != m_currentPackage) {
+ m_currentPackage.getExclude().add(name);
+ }
+ } else {
+ popLocation(Location.EXCLUDE);
+ }
+ }
+
private void pushLocation(Location l) {
m_locations.push(l);
}
@@ -720,6 +731,8 @@ public class TestNGContentHandler extends DefaultHandler {
}
else if ("include".equals(qName)) {
xmlInclude(false, null);
+ } else if ("exclude".equals(qName)){
+ xmlExclude(false, null);
}
}
diff --git a/src/main/java/org/testng/xml/XmlSuite.java b/src/main/java/org/testng/xml/XmlSuite.java
index c0aa2de..61612eb 100755
--- a/src/main/java/org/testng/xml/XmlSuite.java
+++ b/src/main/java/org/testng/xml/XmlSuite.java
@@ -62,6 +62,8 @@ public class XmlSuite implements Serializable, Cloneable {
public static String DEFAULT_PARALLEL = "false";
private String m_parallel = DEFAULT_PARALLEL;
+ private String m_parentModule = "";
+
/** Whether to SKIP or CONTINUE to re-attempt failed configuration methods. */
public static String DEFAULT_CONFIG_FAILURE_POLICY = SKIP;
private String m_configFailurePolicy = DEFAULT_CONFIG_FAILURE_POLICY;
@@ -156,6 +158,11 @@ public class XmlSuite implements Serializable, Cloneable {
return m_parallel;
}
+
+ public String getParentModule() {
+ return m_parentModule;
+ }
+
public ITestObjectFactory getObjectFactory() {
return m_objectFactory;
}
@@ -172,6 +179,10 @@ public class XmlSuite implements Serializable, Cloneable {
m_parallel = parallel;
}
+ public void setParentModule(String parentModule) {
+ m_parentModule = parentModule;
+ }
+
/**
* Sets the configuration failure policy.
* @param configFailurePolicy the config failure policy
@@ -442,6 +453,9 @@ public class XmlSuite implements Serializable, Cloneable {
if(null != m_objectFactory) {
p.setProperty("object-factory", m_objectFactory.getClass().getName());
}
+ if (isStringNotEmpty(m_parentModule)) {
+ p.setProperty("parent-module", getParentModule());
+ }
XmlUtils.setProperty(p, "allow-return-values", String.valueOf(getAllowReturnValues()),
DEFAULT_ALLOW_RETURN_VALUES.toString());
xsb.push("suite", p);
@@ -570,6 +584,7 @@ public class XmlSuite implements Serializable, Cloneable {
result.setName(getName());
result.setListeners(getListeners());
result.setParallel(getParallel());
+ result.setParentModule(getParentModule());
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 ff85283..f6920a3 100755
--- a/src/main/resources/testng-1.0.dtd
+++ b/src/main/resources/testng-1.0.dtd
@@ -61,6 +61,7 @@ Cedric Beust & Alexandru Popescu
junit (true | false) "false"
verbose CDATA #IMPLIED
parallel (false | methods | tests | classes | instances) "false"
+ parent-module CDATA #IMPLIED
configfailurepolicy (skip | continue) "skip"
thread-count CDATA "5"
annotations CDATA #IMPLIED
diff --git a/src/test/java/test/guice/GuiceParentModule.java b/src/test/java/test/guice/GuiceParentModule.java
new file mode 100644
index 0000000..989438f
--- /dev/null
+++ b/src/test/java/test/guice/GuiceParentModule.java
@@ -0,0 +1,13 @@
+package test.guice;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.Singleton;
+
+public class GuiceParentModule extends AbstractModule {
+
+ @Override
+ protected void configure() {
+ bind(MyService.class).toProvider(MyServiceProvider.class);
+ bind(MyContext.class).to(MyContextImpl.class).in(Singleton.class);
+ }
+}
diff --git a/src/test/java/test/guice/GuiceParentModuleTest.java b/src/test/java/test/guice/GuiceParentModuleTest.java
new file mode 100644
index 0000000..9279961
--- /dev/null
+++ b/src/test/java/test/guice/GuiceParentModuleTest.java
@@ -0,0 +1,22 @@
+package test.guice;
+
+import org.testng.Assert;
+import org.testng.annotations.Guice;
+import org.testng.annotations.Test;
+
+import com.google.inject.Inject;
+
+ at Test
+ at Guice(modules = GuiceTestModule.class)
+public class GuiceParentModuleTest {
+ @Inject
+ MySession mySession;
+ @Inject
+ MyService myService;
+
+ public void testService() {
+ Assert.assertNotNull(myService);
+ Assert.assertNotNull(mySession);
+ myService.serve(mySession);
+ }
+}
diff --git a/src/test/java/test/guice/GuiceTestModule.java b/src/test/java/test/guice/GuiceTestModule.java
new file mode 100644
index 0000000..204404c
--- /dev/null
+++ b/src/test/java/test/guice/GuiceTestModule.java
@@ -0,0 +1,18 @@
+package test.guice;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.Inject;
+
+public class GuiceTestModule extends AbstractModule {
+ private final MyContext myContext;
+
+ @Inject
+ GuiceTestModule(MyContext myContext) {
+ this.myContext = myContext;
+ }
+
+ @Override
+ protected void configure() {
+ bind(MySession.class).toInstance(myContext.getSession());
+ }
+}
diff --git a/src/test/java/test/guice/MyContext.java b/src/test/java/test/guice/MyContext.java
new file mode 100644
index 0000000..7378395
--- /dev/null
+++ b/src/test/java/test/guice/MyContext.java
@@ -0,0 +1,6 @@
+package test.guice;
+
+public interface MyContext {
+
+ MySession getSession();
+}
diff --git a/src/test/java/test/guice/MyContextImpl.java b/src/test/java/test/guice/MyContextImpl.java
new file mode 100644
index 0000000..18c21fb
--- /dev/null
+++ b/src/test/java/test/guice/MyContextImpl.java
@@ -0,0 +1,11 @@
+package test.guice;
+
+
+public class MyContextImpl implements MyContext {
+ private final MySession mySession = new MySession();
+
+ @Override
+ public MySession getSession() {
+ return mySession;
+ }
+}
diff --git a/src/test/java/test/guice/MyService.java b/src/test/java/test/guice/MyService.java
new file mode 100644
index 0000000..ef782ae
--- /dev/null
+++ b/src/test/java/test/guice/MyService.java
@@ -0,0 +1,6 @@
+package test.guice;
+
+public interface MyService {
+
+ void serve(MySession mySession);
+}
diff --git a/src/test/java/test/guice/MyServiceProvider.java b/src/test/java/test/guice/MyServiceProvider.java
new file mode 100644
index 0000000..868f83c
--- /dev/null
+++ b/src/test/java/test/guice/MyServiceProvider.java
@@ -0,0 +1,15 @@
+package test.guice;
+
+import com.google.inject.Provider;
+
+public class MyServiceProvider implements Provider<MyService> {
+
+ @Override
+ public MyService get() {
+ return new MyService() {
+ @Override
+ public void serve(MySession mySession) {
+ }
+ };
+ }
+}
diff --git a/src/test/java/test/guice/MySession.java b/src/test/java/test/guice/MySession.java
new file mode 100644
index 0000000..515c55d
--- /dev/null
+++ b/src/test/java/test/guice/MySession.java
@@ -0,0 +1,5 @@
+package test.guice;
+
+public class MySession {
+
+}
diff --git a/src/test/resources/parent-module-suite.xml b/src/test/resources/parent-module-suite.xml
new file mode 100644
index 0000000..b3ea096
--- /dev/null
+++ b/src/test/resources/parent-module-suite.xml
@@ -0,0 +1,9 @@
+<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
+
+<suite name="parent-module-suite" parent-module="test.guice.GuiceParentModule">
+ <test name="Guice">
+ <classes>
+ <class name="test.guice.GuiceParentModuleTest" />
+ </classes>
+ </test>
+</suite>
\ No newline at end of file
diff --git a/src/test/resources/testng.xml b/src/test/resources/testng.xml
index d58ff0b..ca8b566 100644
--- a/src/test/resources/testng.xml
+++ b/src/test/resources/testng.xml
@@ -5,6 +5,7 @@
<suite-files>
<suite-file path="./junit-suite.xml" />
+ <suite-file path="./parent-module-suite.xml" />
</suite-files>
<test name="Nopackage">
@@ -731,3 +732,4 @@
</test>
</suite>
+
diff --git a/upload-beta b/upload-beta
index faa8713..17a6bce 100755
--- a/upload-beta
+++ b/upload-beta
@@ -1,4 +1,4 @@
#scp `ls -tr *beta.zip|tail -1` cedric at beust.com:w/testng
-scp `ls -tr target/*beta.zip|tail -1` beust.com at beust.com:domains/testng.org/html
-ssh beust.com at beust.com cat testng/beta/index.html
+scp `ls -tr target/*beta.zip|tail -1` beust:domains/testng.org/html
+ssh beust cat testng/beta/index.html
--
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