blob: 96439c2a77d063436e7acef9e959485d42d98b4f [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;
18
19import junit.framework.TestCase;
20
21import org.eclipse.jgit.lib.Config;
22import org.joda.time.Duration;
23
24/** Tests for configuration utilities. */
25public class ConfigUtilTest extends TestCase {
26 public void testGetDuration() throws Exception {
27 Duration def = Duration.standardSeconds(2);
28 Config config = new Config();
29 Duration t;
30
31 config.setString("core", "dht", "timeout", "500 ms");
32 t = getDuration(config, "core", "dht", "timeout", def);
33 assertEquals(500, t.getMillis());
34
35 config.setString("core", "dht", "timeout", "5.2 sec");
36 t = getDuration(config, "core", "dht", "timeout", def);
37 assertEquals(5200, t.getMillis());
38
39 config.setString("core", "dht", "timeout", "1 min");
40 t = getDuration(config, "core", "dht", "timeout", def);
41 assertEquals(60000, t.getMillis());
42 }
43}