aboutsummaryrefslogtreecommitdiffstats
path: root/container-core/src/test/java/com/yahoo/container/logging/test/LogFormatterTestCase.java
blob: c3526b42f558132ff4cc51383a983d8468376a71 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.container.logging.test;

import com.yahoo.container.logging.LogFormatter;
import org.junit.jupiter.api.Test;

import java.util.Date;

import static org.junit.jupiter.api.Assertions.assertEquals;

/**
 * @author Bob Travis
 */
public class LogFormatterTestCase {

    @Test
    void testIt() {
        java.util.TimeZone.setDefault(java.util.TimeZone.getTimeZone("UTC"));
        @SuppressWarnings("deprecation")
        long time = new Date(103, 7, 25, 13, 30, 35).getTime();
        String result = LogFormatter.insertDate("test%Y%m%d%H%M%S%x", time);
        assertEquals("test20030825133035Aug", result);
        result = LogFormatter.insertDate("test%s%T", time);
        assertEquals("test000" + time, result);
    }

}