Increase coverage for Env module
[aaf/authz.git] / misc / env / src / test / java / org / onap / aaf / misc / env / util / JU_ChronoTest.java
1 /**\r
2  * ============LICENSE_START====================================================\r
3  * org.onap.aaf\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
10  * \r
11  *      http://www.apache.org/licenses/LICENSE-2.0\r
12  * \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
19  *\r
20  */\r
21 package org.onap.aaf.misc.env.util;\r
22 \r
23 import static org.junit.Assert.assertEquals;\r
24 \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
30 \r
31 import javax.xml.datatype.XMLGregorianCalendar;\r
32 \r
33 import org.junit.Before;\r
34 import org.junit.Test;\r
35 \r
36 public class JU_ChronoTest {\r
37 \r
38         @Before\r
39         public void setUp() throws Exception {\r
40         }\r
41 \r
42         @Test\r
43         public void testFormatter8601() {\r
44                 Chrono.Formatter8601 formatter = new Chrono.Formatter8601();\r
45 \r
46                 LogRecord record = new LogRecord(Level.WARNING, "Log Record to test log formating");\r
47 \r
48                 Date date = new Date(118, 02, 02);\r
49                 long time = date.getTime();\r
50 \r
51                 record.setMillis(time);\r
52 \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
56         }\r
57 \r
58         @Test\r
59         public void testTimeStampWithDate() {\r
60                 Date date = Calendar.getInstance().getTime();\r
61                 XMLGregorianCalendar timeStamp = Chrono.timeStamp(date);\r
62 \r
63                 GregorianCalendar gc = new GregorianCalendar();\r
64                 gc.setTime(date);\r
65                 XMLGregorianCalendar expectedCalendar = Chrono.xmlDatatypeFactory.newXMLGregorianCalendar(gc);\r
66 \r
67                 assertEquals(expectedCalendar, timeStamp);\r
68         }\r
69 }\r