blob: f11617184e43b61368e19c910a8b6c06552b03b8 [file] [log] [blame]
David Ostrovsky2536d062013-11-14 00:35:07 +01001#!/usr/bin/python
2# Copyright (C) 2013 The Android Open Source Project
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
16import unittest
17from util import resolve_url
18
19class TestResolveUrl(unittest.TestCase):
20 """ run to test:
21 python -m unittest -v util_test
22 """
23
24 def testKnown(self):
25 url = resolve_url('GERRIT:foo.jar', {})
26 self.assertEqual(url, 'http://gerrit-maven.storage.googleapis.com/foo.jar')
27
28 def testKnownRedirect(self):
29 url = resolve_url('MAVEN_CENTRAL:foo.jar',
30 {'MAVEN_CENTRAL': 'http://my.company.mirror/maven2'})
31 self.assertEqual(url, 'http://my.company.mirror/maven2/foo.jar')
32
33 def testCustom(self):
34 url = resolve_url('http://maven.example.com/release/foo.jar', {})
35 self.assertEqual(url, 'http://maven.example.com/release/foo.jar')
36
37 def testCustomRedirect(self):
38 url = resolve_url('MAVEN_EXAMPLE:foo.jar',
39 {'MAVEN_EXAMPLE': 'http://maven.example.com/release'})
40 self.assertEqual(url, 'http://maven.example.com/release/foo.jar')
41
42if __name__ == '__main__':
43 unittest.main()