-
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.
- Loading branch information
1 parent
a3ec3a3
commit afc7b6c
Showing
7 changed files
with
39 additions
and
15 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
30 changes: 30 additions & 0 deletions
30
testng-core/src/main/java/org/testng/internal/IInstanceIdentity.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,30 @@ | ||
package org.testng.internal; | ||
|
||
import java.util.Optional; | ||
import java.util.UUID; | ||
import org.testng.log4testng.Logger; | ||
|
||
public interface IInstanceIdentity { | ||
|
||
/** | ||
* @return - A <code>{@link UUID}</code> that represents a unique id which is associated with | ||
* every test class object. | ||
*/ | ||
UUID getInstanceId(); | ||
|
||
String fmt = "[Attention] %s does not implement %s. Generating an on the fly UUID."; | ||
Logger logger = Logger.getLogger(IInstanceIdentity.class); | ||
|
||
static UUID getInstanceId(Object object) { | ||
if (object instanceof IInstanceIdentity) { | ||
return ((IInstanceIdentity) object).getInstanceId(); | ||
} | ||
if (logger.isDebugEnabled()) { | ||
String className = | ||
Optional.ofNullable(object).map(it -> it.getClass().getName()).orElse("[Unknown Class]"); | ||
String msg = String.format(fmt, className, IInstanceIdentity.class.getName()); | ||
logger.debug(msg); | ||
} | ||
return UUID.randomUUID(); | ||
} | ||
} |
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
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