1582deec1f3c8f51b431bb2ad685c9217ffd9eaadSteve Block/*
2582deec1f3c8f51b431bb2ad685c9217ffd9eaadSteve Block * Copyright (C) 2010 The Android Open Source Project
3582deec1f3c8f51b431bb2ad685c9217ffd9eaadSteve Block *
4582deec1f3c8f51b431bb2ad685c9217ffd9eaadSteve Block * Licensed under the Apache License, Version 2.0 (the "License");
5582deec1f3c8f51b431bb2ad685c9217ffd9eaadSteve Block * you may not use this file except in compliance with the License.
6582deec1f3c8f51b431bb2ad685c9217ffd9eaadSteve Block * You may obtain a copy of the License at
7582deec1f3c8f51b431bb2ad685c9217ffd9eaadSteve Block *
8582deec1f3c8f51b431bb2ad685c9217ffd9eaadSteve Block *      http://www.apache.org/licenses/LICENSE-2.0
9582deec1f3c8f51b431bb2ad685c9217ffd9eaadSteve Block *
10582deec1f3c8f51b431bb2ad685c9217ffd9eaadSteve Block * Unless required by applicable law or agreed to in writing, software
11582deec1f3c8f51b431bb2ad685c9217ffd9eaadSteve Block * distributed under the License is distributed on an "AS IS" BASIS,
12582deec1f3c8f51b431bb2ad685c9217ffd9eaadSteve Block * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13582deec1f3c8f51b431bb2ad685c9217ffd9eaadSteve Block * See the License for the specific language governing permissions and
14582deec1f3c8f51b431bb2ad685c9217ffd9eaadSteve Block * limitations under the License.
15582deec1f3c8f51b431bb2ad685c9217ffd9eaadSteve Block */
16582deec1f3c8f51b431bb2ad685c9217ffd9eaadSteve Block
17582deec1f3c8f51b431bb2ad685c9217ffd9eaadSteve Blockpackage android.net;
18582deec1f3c8f51b431bb2ad685c9217ffd9eaadSteve Block
19582deec1f3c8f51b431bb2ad685c9217ffd9eaadSteve Blockimport android.net.WebAddress;
20582deec1f3c8f51b431bb2ad685c9217ffd9eaadSteve Blockimport android.test.suitebuilder.annotation.SmallTest;
21582deec1f3c8f51b431bb2ad685c9217ffd9eaadSteve Blockimport junit.framework.TestCase;
22582deec1f3c8f51b431bb2ad685c9217ffd9eaadSteve Block
23582deec1f3c8f51b431bb2ad685c9217ffd9eaadSteve Blockpublic class WebAddressTest extends TestCase {
24582deec1f3c8f51b431bb2ad685c9217ffd9eaadSteve Block
258bb37f7ffb24ab06576dd4225ab0a5e1828a0d07Steve Block    // http://b/2337042
26582deec1f3c8f51b431bb2ad685c9217ffd9eaadSteve Block    @SmallTest
27582deec1f3c8f51b431bb2ad685c9217ffd9eaadSteve Block    public void testHostWithTrailingDot() {
28582deec1f3c8f51b431bb2ad685c9217ffd9eaadSteve Block        WebAddress webAddress = new WebAddress("http://google.com./b/c/g");
29eb8be973c7982fe3ece0aeaeca379c3b3cdced0cBjorn Bringert        assertEquals("google.com.", webAddress.getHost());
30eb8be973c7982fe3ece0aeaeca379c3b3cdced0cBjorn Bringert        assertEquals("/b/c/g", webAddress.getPath());
31582deec1f3c8f51b431bb2ad685c9217ffd9eaadSteve Block    }
328bb37f7ffb24ab06576dd4225ab0a5e1828a0d07Steve Block
338bb37f7ffb24ab06576dd4225ab0a5e1828a0d07Steve Block    // http://b/1011602
348bb37f7ffb24ab06576dd4225ab0a5e1828a0d07Steve Block    @SmallTest
358bb37f7ffb24ab06576dd4225ab0a5e1828a0d07Steve Block    public void testPathWithoutLeadingSlash() {
368bb37f7ffb24ab06576dd4225ab0a5e1828a0d07Steve Block        WebAddress webAddress = new WebAddress("http://www.myspace.com?si=1");
37eb8be973c7982fe3ece0aeaeca379c3b3cdced0cBjorn Bringert        assertEquals("www.myspace.com", webAddress.getHost());
38eb8be973c7982fe3ece0aeaeca379c3b3cdced0cBjorn Bringert        assertEquals("/?si=1", webAddress.getPath());
398bb37f7ffb24ab06576dd4225ab0a5e1828a0d07Steve Block    }
40582deec1f3c8f51b431bb2ad685c9217ffd9eaadSteve Block}
41