blob: c5c8389ca6f513f72dace88bef2caf43336bf917 [file] [log] [blame]
Dave Borowitz9de65952012-08-13 16:09:45 -07001// Copyright 2012 Google Inc. All Rights Reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package com.google.gitiles;
16
17import static com.google.gitiles.ConfigUtil.getDuration;
Dave Borowitz9de65952012-08-13 16:09:45 -070018import junit.framework.TestCase;
19
20import org.eclipse.jgit.lib.Config;
21import org.joda.time.Duration;
22
23/** Tests for configuration utilities. */
24public class ConfigUtilTest extends TestCase {
25 public void testGetDuration() throws Exception {
26 Duration def = Duration.standardSeconds(2);
27 Config config = new Config();
28 Duration t;
29
30 config.setString("core", "dht", "timeout", "500 ms");
31 t = getDuration(config, "core", "dht", "timeout", def);
32 assertEquals(500, t.getMillis());
33
34 config.setString("core", "dht", "timeout", "5.2 sec");
35 t = getDuration(config, "core", "dht", "timeout", def);
36 assertEquals(5200, t.getMillis());
37
38 config.setString("core", "dht", "timeout", "1 min");
39 t = getDuration(config, "core", "dht", "timeout", def);
40 assertEquals(60000, t.getMillis());
41 }
42}