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 Original file line number Diff line number Diff line change 20
20
import static org .junit .jupiter .api .Assertions .assertTrue ;
21
21
22
22
import java .util .UUID ;
23
+ import org .apache .logging .log4j .core .LogEvent ;
24
+ import org .apache .logging .log4j .core .test .layout .LogEventFixtures ;
23
25
import org .junit .jupiter .api .Test ;
24
26
25
27
public class UuidTest {
@@ -107,6 +109,20 @@ public void testThreads() throws Exception {
107
109
assertEquals (0 , errors , errors + " duplicate UUIDS" );
108
110
}
109
111
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
+
110
126
private static class Worker extends Thread {
111
127
112
128
private final UUID [] uuids ;
You can’t perform that action at this time.
0 commit comments