|
32 | 32 | import java.io.PrintStream;
|
33 | 33 | import java.nio.charset.StandardCharsets;
|
34 | 34 | import java.util.List;
|
| 35 | +import java.util.UUID; |
35 | 36 | import org.eclipse.paho.client.mqttv3.MqttClient;
|
36 | 37 | import org.junit.After;
|
37 | 38 | import org.junit.Assert;
|
|
45 | 46 | @RunWith(JUnit4.class)
|
46 | 47 | @SuppressWarnings("checkstyle:abbreviationaswordinname")
|
47 | 48 | public class ManagerIT {
|
48 |
| - private ByteArrayOutputStream bout; |
49 |
| - private PrintStream out; |
50 |
| - private DeviceRegistryExample app; |
51 |
| - |
52 | 49 | private static final String CLOUD_REGION = "us-central1";
|
53 | 50 | private static final String ES_PATH = "resources/ec_public.pem";
|
54 | 51 | private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT");
|
55 |
| - private static final String REGISTRY_ID = "java-reg-" + (System.currentTimeMillis() / 100L); |
| 52 | + private static final String REGISTRY_ID = |
| 53 | + "java-reg-" |
| 54 | + + UUID.randomUUID().toString().substring(0, 10) + "-" |
| 55 | + + (System.currentTimeMillis() / 100L); |
56 | 56 | private static final String RSA_PATH = "resources/rsa_cert.pem";
|
57 | 57 | private static final String PKCS_PATH = "resources/rsa_private_pkcs8";
|
58 |
| - private static final String TOPIC_ID = "java-pst-" + (System.currentTimeMillis() / 100L); |
| 58 | + private static final String TOPIC_ID = |
| 59 | + "java-pst-" |
| 60 | + + UUID.randomUUID().toString().substring(0, 20); |
59 | 61 | private static final String MEMBER = "group:dpebot@google.com";
|
60 | 62 | private static final String ROLE = "roles/viewer";
|
61 |
| - |
62 | 63 | private static Topic topic;
|
63 | 64 | private static boolean hasCleared = false;
|
| 65 | + private ByteArrayOutputStream bout; |
| 66 | + private PrintStream out; |
| 67 | + private DeviceRegistryExample app; |
64 | 68 |
|
65 | 69 | @Before
|
66 | 70 | public void setUp() throws Exception {
|
@@ -105,7 +109,7 @@ public void clearTestRegistries() throws Exception {
|
105 | 109 | if (registryId.startsWith("java-reg-")) {
|
106 | 110 | long currSecs = System.currentTimeMillis() / 1000L;
|
107 | 111 | long regSecs =
|
108 |
| - Long.parseLong(registryId.substring("java-reg-".length(), registryId.length())); |
| 112 | + Long.parseLong(registryId.substring("java-reg-".length() + 11, registryId.length())); |
109 | 113 | long diffSecs = currSecs - regSecs;
|
110 | 114 | if (diffSecs > (60 * 60 * 24 * 7 * 10)) { // tests from last week or older
|
111 | 115 | System.out.println("Remove Id: " + r.getId());
|
|
0 commit comments