Repository: logging-log4j2
Updated Branches:
  refs/heads/LOG4J2-1883-instant-field b8b519e5b -> 773012e52


LOG4J2-1883 renamed DummyPreciseClock to FixedPreciseClock


Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/773012e5
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/773012e5
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/773012e5

Branch: refs/heads/LOG4J2-1883-instant-field
Commit: 773012e52f2b6f2c9e243f55c0d6c5e7abb7b95e
Parents: b8b519e
Author: rpopma <[email protected]>
Authored: Fri Jan 26 20:56:15 2018 +0900
Committer: rpopma <[email protected]>
Committed: Fri Jan 26 20:56:15 2018 +0900

----------------------------------------------------------------------
 .../log4j/core/util/DummyPreciseClock.java      | 49 ----------------
 .../log4j/core/util/FixedPreciseClock.java      | 62 ++++++++++++++++++++
 .../core/async/RingBufferLogEventTest.java      | 12 ++--
 .../log4j/core/util/MutableInstantTest.java     |  2 +-
 4 files changed, 69 insertions(+), 56 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/773012e5/log4j-core/src/main/java/org/apache/logging/log4j/core/util/DummyPreciseClock.java
----------------------------------------------------------------------
diff --git 
a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/DummyPreciseClock.java
 
b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/DummyPreciseClock.java
deleted file mode 100644
index 2c88640..0000000
--- 
a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/DummyPreciseClock.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-package org.apache.logging.log4j.core.util;
-
-/**
- * Implementation of the {@code PreciseClock} interface that always returns a 
fixed value.
- * @since 2.11
- */
-public class DummyPreciseClock implements PreciseClock {
-    private final long currentTimeMillis;
-    private final int nanosOfMillisecond;
-
-    public DummyPreciseClock() {
-        this(0);
-    }
-
-    public DummyPreciseClock(final long currentTimeMillis) {
-        this(currentTimeMillis, 0);
-    }
-
-    public DummyPreciseClock(final long currentTimeMillis, final int 
nanosOfMillisecond) {
-        this.currentTimeMillis = currentTimeMillis;
-        this.nanosOfMillisecond = nanosOfMillisecond;
-    }
-
-    @Override
-    public void init(final MutableInstant instant) {
-        instant.initFromEpochMilli(currentTimeMillis, nanosOfMillisecond);
-    }
-
-    @Override
-    public long currentTimeMillis() {
-        return currentTimeMillis;
-    }
-}

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/773012e5/log4j-core/src/main/java/org/apache/logging/log4j/core/util/FixedPreciseClock.java
----------------------------------------------------------------------
diff --git 
a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/FixedPreciseClock.java
 
b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/FixedPreciseClock.java
new file mode 100644
index 0000000..57ba2ec
--- /dev/null
+++ 
b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/FixedPreciseClock.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.core.util;
+
+/**
+ * Implementation of the {@code PreciseClock} interface that always returns a 
fixed time value.
+ * @since 2.11
+ */
+public class FixedPreciseClock implements PreciseClock {
+    private final long currentTimeMillis;
+    private final int nanosOfMillisecond;
+
+    /**
+     * Constructs a {@code FixedPreciseClock} that always returns the epoch.
+     */
+    public FixedPreciseClock() {
+        this(0);
+    }
+
+    /**
+     * Constructs a {@code FixedPreciseClock} that always returns the 
specified time in milliseconds since the epoch.
+     * @param currentTimeMillis milliseconds since the epoch
+     */
+    public FixedPreciseClock(final long currentTimeMillis) {
+        this(currentTimeMillis, 0);
+    }
+
+    /**
+     * Constructs a {@code FixedPreciseClock} that always returns the 
specified time in milliseconds since the epoch
+     * and nanosecond of the millisecond.
+     * @param currentTimeMillis milliseconds since the epoch
+     * @param nanosOfMillisecond nanosecond of the specified millisecond
+     */
+    public FixedPreciseClock(final long currentTimeMillis, final int 
nanosOfMillisecond) {
+        this.currentTimeMillis = currentTimeMillis;
+        this.nanosOfMillisecond = nanosOfMillisecond;
+    }
+
+    @Override
+    public void init(final MutableInstant instant) {
+        instant.initFromEpochMilli(currentTimeMillis, nanosOfMillisecond);
+    }
+
+    @Override
+    public long currentTimeMillis() {
+        return currentTimeMillis;
+    }
+}

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/773012e5/log4j-core/src/test/java/org/apache/logging/log4j/core/async/RingBufferLogEventTest.java
----------------------------------------------------------------------
diff --git 
a/log4j-core/src/test/java/org/apache/logging/log4j/core/async/RingBufferLogEventTest.java
 
b/log4j-core/src/test/java/org/apache/logging/log4j/core/async/RingBufferLogEventTest.java
index 4dea6a5..82fab17 100644
--- 
a/log4j-core/src/test/java/org/apache/logging/log4j/core/async/RingBufferLogEventTest.java
+++ 
b/log4j-core/src/test/java/org/apache/logging/log4j/core/async/RingBufferLogEventTest.java
@@ -31,7 +31,7 @@ import org.apache.logging.log4j.ThreadContext.ContextStack;
 import org.apache.logging.log4j.categories.AsyncLoggers;
 import org.apache.logging.log4j.core.LogEvent;
 import org.apache.logging.log4j.core.util.DummyNanoClock;
-import org.apache.logging.log4j.core.util.DummyPreciseClock;
+import org.apache.logging.log4j.core.util.FixedPreciseClock;
 import org.apache.logging.log4j.util.FilteredObjectInputStream;
 import org.apache.logging.log4j.util.StringMap;
 import org.apache.logging.log4j.core.impl.ThrowableProxy;
@@ -69,7 +69,7 @@ public class RingBufferLogEventTest {
         final String threadName = null;
         final StackTraceElement location = null;
         evt.setValues(null, loggerName, marker, fqcn, level, data, t, 
(StringMap) evt.getContextData(),
-                contextStack, -1, threadName, -1, location, new 
DummyPreciseClock(), new DummyNanoClock(1));
+                contextStack, -1, threadName, -1, location, new 
FixedPreciseClock(), new DummyNanoClock(1));
         assertEquals(Level.OFF, evt.getLevel());
     }
 
@@ -86,7 +86,7 @@ public class RingBufferLogEventTest {
         final String threadName = null;
         final StackTraceElement location = null;
         evt.setValues(null, loggerName, marker, fqcn, level, data, t, 
(StringMap) evt.getContextData(),
-                contextStack, -1, threadName, -1, location, new 
DummyPreciseClock(), new DummyNanoClock(1));
+                contextStack, -1, threadName, -1, location, new 
FixedPreciseClock(), new DummyNanoClock(1));
         assertNotNull(evt.getMessage());
     }
 
@@ -103,7 +103,7 @@ public class RingBufferLogEventTest {
         final String threadName = null;
         final StackTraceElement location = null;
         evt.setValues(null, loggerName, marker, fqcn, level, data, t, 
(StringMap) evt.getContextData(),
-                contextStack, -1, threadName, -1, location, new 
DummyPreciseClock(123, 456), new DummyNanoClock(1));
+                contextStack, -1, threadName, -1, location, new 
FixedPreciseClock(123, 456), new DummyNanoClock(1));
         assertEquals(123, evt.getTimeMillis());
         assertEquals(456, evt.getInstant().getNanoOfMillisecond());
     }
@@ -122,7 +122,7 @@ public class RingBufferLogEventTest {
         final StackTraceElement location = null;
         evt.setValues(null, loggerName, marker, fqcn, level, data, t, 
(StringMap) evt.getContextData(),
                 contextStack, -1, threadName, -1, location,
-                new DummyPreciseClock(12345, 678), new DummyNanoClock(1));
+                new FixedPreciseClock(12345, 678), new DummyNanoClock(1));
         ((StringMap) evt.getContextData()).putValue("key", "value");
 
         final ByteArrayOutputStream baos = new ByteArrayOutputStream();
@@ -160,7 +160,7 @@ public class RingBufferLogEventTest {
         final String threadName = "main";
         final StackTraceElement location = null;
         evt.setValues(null, loggerName, marker, fqcn, level, data, t, 
(StringMap) evt.getContextData(),
-                contextStack, -1, threadName, -1, location, new 
DummyPreciseClock(12345, 678), new DummyNanoClock(1));
+                contextStack, -1, threadName, -1, location, new 
FixedPreciseClock(12345, 678), new DummyNanoClock(1));
         ((StringMap) evt.getContextData()).putValue("key", "value");
 
         final LogEvent actual = evt.createMemento();

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/773012e5/log4j-core/src/test/java/org/apache/logging/log4j/core/util/MutableInstantTest.java
----------------------------------------------------------------------
diff --git 
a/log4j-core/src/test/java/org/apache/logging/log4j/core/util/MutableInstantTest.java
 
b/log4j-core/src/test/java/org/apache/logging/log4j/core/util/MutableInstantTest.java
index 1715fc6..7bd6e6a 100644
--- 
a/log4j-core/src/test/java/org/apache/logging/log4j/core/util/MutableInstantTest.java
+++ 
b/log4j-core/src/test/java/org/apache/logging/log4j/core/util/MutableInstantTest.java
@@ -183,7 +183,7 @@ public class MutableInstantTest {
     public void testInitFromClock() {
         MutableInstant instant = new MutableInstant();
 
-        PreciseClock clock = new DummyPreciseClock(123456, 789012);
+        PreciseClock clock = new FixedPreciseClock(123456, 789012);
         instant.initFrom(clock);
 
         assertEquals(123456, instant.getEpochMillisecond());

Reply via email to