blob: ab1133b22e0084a15ecb1c3eb1452fc10167d556 [file] [log] [blame]
David Ostrovsky2b5fe092021-03-03 11:52:30 +01001#!/usr/bin/env python3
David Ostrovsky2536d062013-11-14 00:35:07 +01002# 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
Chad Horohoedd224702018-05-16 22:33:06 -040019
David Ostrovsky2536d062013-11-14 00:35:07 +010020class TestResolveUrl(unittest.TestCase):
Chad Horohoedd224702018-05-16 22:33:06 -040021 """ run to test:
22 python -m unittest -v util_test
23 """
David Ostrovsky2536d062013-11-14 00:35:07 +010024
Chad Horohoedd224702018-05-16 22:33:06 -040025 def testKnown(self):
26 url = resolve_url('GERRIT:foo.jar', {})
Chad Horohoe69142322018-05-17 10:19:22 -070027 self.assertEqual(url,
28 'http://gerrit-maven.storage.googleapis.com/foo.jar')
David Ostrovsky2536d062013-11-14 00:35:07 +010029
Chad Horohoedd224702018-05-16 22:33:06 -040030 def testKnownRedirect(self):
31 url = resolve_url('MAVEN_CENTRAL:foo.jar',
David Pursehouse4dab1bb2019-04-23 19:41:20 +090032 {'MAVEN_CENTRAL': 'https://my.company.mirror/maven2'})
33 self.assertEqual(url, 'https://my.company.mirror/maven2/foo.jar')
David Ostrovsky2536d062013-11-14 00:35:07 +010034
Chad Horohoedd224702018-05-16 22:33:06 -040035 def testCustom(self):
David Pursehouse4dab1bb2019-04-23 19:41:20 +090036 url = resolve_url('https://maven.example.com/release/foo.jar', {})
37 self.assertEqual(url, 'https://maven.example.com/release/foo.jar')
David Ostrovsky2536d062013-11-14 00:35:07 +010038
Chad Horohoedd224702018-05-16 22:33:06 -040039 def testCustomRedirect(self):
40 url = resolve_url('MAVEN_EXAMPLE:foo.jar',
Chad Horohoe69142322018-05-17 10:19:22 -070041 {'MAVEN_EXAMPLE':
David Pursehouse4dab1bb2019-04-23 19:41:20 +090042 'https://maven.example.com/release'})
43 self.assertEqual(url, 'https://maven.example.com/release/foo.jar')
Chad Horohoedd224702018-05-16 22:33:06 -040044
David Ostrovsky2536d062013-11-14 00:35:07 +010045
46if __name__ == '__main__':
Chad Horohoedd224702018-05-16 22:33:06 -040047 unittest.main()