-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Streamline Guice Module creation in concurrency
- Loading branch information
1 parent
3b3d67c
commit 1774b2c
Showing
8 changed files
with
198 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
testng-core/src/test/java/test/guice/issue3050/EvidenceModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package test.guice.issue3050; | ||
|
||
import com.google.inject.AbstractModule; | ||
import com.google.inject.Provides; | ||
import com.google.inject.Singleton; | ||
import java.util.UUID; | ||
|
||
public class EvidenceModule extends AbstractModule { | ||
|
||
@Provides | ||
@Singleton | ||
private UUID randomUUID() { | ||
return UUID.randomUUID(); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
testng-core/src/test/java/test/guice/issue3050/EvidenceRetryAnalyzer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package test.guice.issue3050; | ||
|
||
import com.google.inject.Inject; | ||
import java.util.Set; | ||
import java.util.UUID; | ||
import java.util.concurrent.ConcurrentHashMap; | ||
import org.testng.IRetryAnalyzer; | ||
import org.testng.ITestResult; | ||
import org.testng.annotations.Guice; | ||
|
||
@Guice(modules = EvidenceModule.class) | ||
public class EvidenceRetryAnalyzer implements IRetryAnalyzer { | ||
|
||
public static Set<UUID> uuids = ConcurrentHashMap.newKeySet(); | ||
|
||
public static boolean hasOnlyOneUuid() { | ||
return uuids.size() == 1; | ||
} | ||
|
||
@Inject private UUID injectedUUID; | ||
|
||
@Override | ||
public boolean retry(ITestResult result) { | ||
uuids.add(injectedUUID); | ||
return false; | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
testng-core/src/test/java/test/guice/issue3050/EvidenceTestOneSample.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package test.guice.issue3050; | ||
|
||
import static org.testng.Assert.fail; | ||
|
||
import org.testng.ITestContext; | ||
import org.testng.ITestNGMethod; | ||
import org.testng.Reporter; | ||
import org.testng.annotations.BeforeSuite; | ||
import org.testng.annotations.Test; | ||
|
||
@Test | ||
public class EvidenceTestOneSample { | ||
|
||
@BeforeSuite(alwaysRun = true) | ||
public void suiteSetup() { | ||
ITestContext context = Reporter.getCurrentTestResult().getTestContext(); | ||
for (ITestNGMethod method : context.getAllTestMethods()) { | ||
method.setRetryAnalyzerClass(EvidenceRetryAnalyzer.class); | ||
} | ||
} | ||
|
||
@Test | ||
public void testOne() { | ||
fail(); | ||
} | ||
|
||
@Test | ||
public void testTwo() { | ||
fail(); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
testng-core/src/test/java/test/guice/issue3050/EvidenceTestThreeSample.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package test.guice.issue3050; | ||
|
||
import static org.testng.Assert.fail; | ||
|
||
import org.testng.ITestContext; | ||
import org.testng.ITestNGMethod; | ||
import org.testng.Reporter; | ||
import org.testng.annotations.BeforeSuite; | ||
import org.testng.annotations.Test; | ||
|
||
@Test | ||
public class EvidenceTestThreeSample { | ||
|
||
@BeforeSuite(alwaysRun = true) | ||
public void suiteSetup() { | ||
ITestContext context = Reporter.getCurrentTestResult().getTestContext(); | ||
for (ITestNGMethod method : context.getAllTestMethods()) { | ||
method.setRetryAnalyzerClass(EvidenceRetryAnalyzer.class); | ||
} | ||
} | ||
|
||
@Test | ||
public void testOne() { | ||
fail(); | ||
} | ||
|
||
@Test | ||
public void testTwo() { | ||
fail(); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
testng-core/src/test/java/test/guice/issue3050/EvidenceTestTwoSample.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package test.guice.issue3050; | ||
|
||
import static org.testng.Assert.fail; | ||
|
||
import org.testng.ITestContext; | ||
import org.testng.ITestNGMethod; | ||
import org.testng.Reporter; | ||
import org.testng.annotations.BeforeSuite; | ||
import org.testng.annotations.Test; | ||
|
||
@Test | ||
public class EvidenceTestTwoSample { | ||
|
||
@BeforeSuite(alwaysRun = true) | ||
public void suiteSetup() { | ||
ITestContext context = Reporter.getCurrentTestResult().getTestContext(); | ||
for (ITestNGMethod method : context.getAllTestMethods()) { | ||
method.setRetryAnalyzerClass(EvidenceRetryAnalyzer.class); | ||
} | ||
} | ||
|
||
@Test | ||
public void testOne() { | ||
fail(); | ||
} | ||
|
||
@Test | ||
public void testTwo() { | ||
fail(); | ||
} | ||
} |