blob: 4d0ca51564ac78119923cce1701b2ed0b026186e [file] [log] [blame]
Simon Hunt9ffbd8d2015-05-06 12:02:32 -07001/*
2 * Copyright 2015 Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 */
17
18package org.onosproject.ui.table.cell;
19
20import org.joda.time.DateTime;
Simon Hunt5939e652015-05-06 16:20:23 -070021import org.joda.time.DateTimeZone;
Simon Hunt9ffbd8d2015-05-06 12:02:32 -070022import org.junit.Test;
23import org.onosproject.ui.table.CellFormatter;
24
Simon Hunt5939e652015-05-06 16:20:23 -070025import java.util.Locale;
26
Simon Hunt9ffbd8d2015-05-06 12:02:32 -070027import static org.junit.Assert.assertEquals;
28
29/**
30 * Unit tests for {@link TimeFormatter}.
31 */
32public class TimeFormatterTest {
33
Simon Hunt5939e652015-05-06 16:20:23 -070034 private static final Locale LOCALE = Locale.ENGLISH;
35 private static final DateTimeZone ZONE = DateTimeZone.UTC;
Simon Hunt9ffbd8d2015-05-06 12:02:32 -070036
Simon Hunt5939e652015-05-06 16:20:23 -070037 private static final DateTime TIME = new DateTime(2015, 5, 4, 15, 30, ZONE);
38 private static final String EXP_OUTPUT = "3:30:00 PM UTC";
39
40 // Have to use explicit Locale and TimeZone for the unit test, so that
41 // irrespective of which locale and time zone the test is run in, it
42 // always produces the same result...
43 private CellFormatter fmt =
44 new TimeFormatter().withLocale(LOCALE).withZone(ZONE);
Simon Hunt9ffbd8d2015-05-06 12:02:32 -070045
46 @Test
47 public void basic() {
48 assertEquals("wrong format", EXP_OUTPUT, fmt.format(TIME));
49 }
50}