2 * ============LICENSE_START====================================================
\r
4 * ===========================================================================
\r
5 * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
\r
6 * ===========================================================================
\r
7 * Licensed under the Apache License, Version 2.0 (the "License");
\r
8 * you may not use this file except in compliance with the License.
\r
9 * You may obtain a copy of the License at
\r
11 * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * Unless required by applicable law or agreed to in writing, software
\r
14 * distributed under the License is distributed on an "AS IS" BASIS,
\r
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 * See the License for the specific language governing permissions and
\r
17 * limitations under the License.
\r
18 * ============LICENSE_END====================================================
\r
21 package org.onap.aaf.misc.env.util;
\r
23 import static org.junit.Assert.assertEquals;
\r
25 import java.util.Calendar;
\r
26 import java.util.Date;
\r
27 import java.util.GregorianCalendar;
\r
28 import java.util.logging.Level;
\r
29 import java.util.logging.LogRecord;
\r
31 import javax.xml.datatype.XMLGregorianCalendar;
\r
33 import org.junit.Before;
\r
34 import org.junit.Test;
\r
36 public class JU_ChronoTest {
\r
39 public void setUp() throws Exception {
\r
43 public void testFormatter8601() {
\r
44 Chrono.Formatter8601 formatter = new Chrono.Formatter8601();
\r
46 LogRecord record = new LogRecord(Level.WARNING, "Log Record to test log formating");
\r
48 Date date = new Date(118, 02, 02);
\r
49 long time = date.getTime();
\r
51 record.setMillis(time);
\r
53 String expectedString = Chrono.dateFmt.format(date) + " " + record.getThreadID() + " " + record.getLevel()
\r
54 + ": " + record.getMessage() + "\n";
\r
55 assertEquals(expectedString, formatter.format(record));
\r
59 public void testTimeStampWithDate() {
\r
60 Date date = Calendar.getInstance().getTime();
\r
61 XMLGregorianCalendar timeStamp = Chrono.timeStamp(date);
\r
63 GregorianCalendar gc = new GregorianCalendar();
\r
65 XMLGregorianCalendar expectedCalendar = Chrono.xmlDatatypeFactory.newXMLGregorianCalendar(gc);
\r
67 assertEquals(expectedCalendar, timeStamp);
\r