Skip to content

Commit 7f126de

Browse files
committed
Add test
1 parent efbc3e9 commit 7f126de

File tree

1 file changed

+16
-0
lines changed
  • log4j-core-test/src/test/java/org/apache/logging/log4j/core/util

1 file changed

+16
-0
lines changed

log4j-core-test/src/test/java/org/apache/logging/log4j/core/util/UuidTest.java

+16
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
import static org.junit.jupiter.api.Assertions.assertTrue;
2121

2222
import java.util.UUID;
23+
import org.apache.logging.log4j.core.LogEvent;
24+
import org.apache.logging.log4j.core.test.layout.LogEventFixtures;
2325
import org.junit.jupiter.api.Test;
2426

2527
public class UuidTest {
@@ -107,6 +109,20 @@ public void testThreads() throws Exception {
107109
assertEquals(0, errors, errors + " duplicate UUIDS");
108110
}
109111

112+
@Test
113+
public void testHashBasedUuid() {
114+
LogEvent event1 = LogEventFixtures.createLogEvent();
115+
LogEvent event2 = LogEventFixtures.createLogEvent()
116+
.asBuilder()
117+
.setThrown(event1.getThrown())
118+
.build();
119+
UUID uuid1 = UuidUtil.getHashBasedUuid(event1);
120+
UUID uuid2 = UuidUtil.getHashBasedUuid(event2);
121+
assertEquals(uuid1, uuid2, "UUIDs don't match");
122+
assertEquals(8, uuid1.version(), "Wrong version");
123+
assertEquals(2, uuid1.variant(), "Wrong variant");
124+
}
125+
110126
private static class Worker extends Thread {
111127

112128
private final UUID[] uuids;

0 commit comments

Comments
 (0)