这是场景:我有:
public class RandomStringUUID {
public RandomStringUUID() {
final String uuidstring = UUID.randomUUID().toString().replaceAll("-", "");
}
public String getRandomStringUUID() {
final String uuidst = UUID.randomUUID().toString().replaceAll("-", "");
return uuidst;
}
}
我在哪里产生一个独特的价值。
然后在:
public class AddSingleDomain {
public static RandomStringUUID RUUID = new RandomStringUUID();
@Test
public void addSingleDomain() {
AssertJUnit.assertEquals(DomainsPage.getTitle(), "View Account");
String randomUIDSeed = RUUID.getRandomStringUUID();
System.out.println("Random Domanin Name Prefix: "
+ randomUIDSeed);
System.out.println("Random Domanin Name Prefix: " + RUUID);
getDriver().findElement(By.name("vo.zoneName")).sendKeys(
randomUIDSeed + ".tv");
我使用它,然后在另一个类中:
公共类验证DBSingleDomain {
String url = "jdbc:oracle:thin:@a.b.c.d:1521:ms";
@Test
public void VerifyDBSingleDomainTest() {
Properties props = new Properties();
props.setProperty("user", "user");
props.setProperty("password", "pass");
String sql = "Select zoneid from zone where zonename =" + randomUIDSeed + ".tv";
如果在类 VerifyDBSingleDomain i 中,我想使用相同的值“randomUIDSeed”: String randomUIDSeed = RUUID.getRandomStringUUID(); 它会是同一个对象吗?我如何将其用作相同的对象,从而保证在运行时跨所有类的相同值。