1/*
2 * Copyright (C) 2008 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 */
16
17package tests.api.java.net;
18
19import dalvik.annotation.TestTargets;
20import dalvik.annotation.TestLevel;
21import dalvik.annotation.TestTargetNew;
22import dalvik.annotation.TestTargetClass;
23
24import junit.framework.TestCase;
25
26import java.io.IOException;
27import java.io.OutputStream;
28import java.net.CacheRequest;
29
30@TestTargetClass(CacheRequest.class)
31public class CacheRequestTest extends TestCase {
32
33
34    @TestTargets({
35        @TestTargetNew(
36            level = TestLevel.COMPLETE,
37            notes = "",
38            method = "abort",
39            args = {}
40        ),
41        @TestTargetNew(
42            level = TestLevel.COMPLETE,
43            notes = "",
44            method = "CacheRequest",
45            args = {}
46        )
47    })
48    public void test_abort() {
49        MockCacheRequest mcr = new MockCacheRequest();
50        mcr.abort();
51    }
52
53    @TestTargets({
54        @TestTargetNew(
55            level = TestLevel.COMPLETE,
56            notes = "",
57            method = "getBody",
58            args = {}
59        ),
60        @TestTargetNew(
61            level = TestLevel.COMPLETE,
62            notes = "",
63            method = "CacheRequest",
64            args = {}
65        )
66    })
67    public void test_getBody() throws IOException {
68        MockCacheRequest mcr = new MockCacheRequest();
69        assertNull(mcr.getBody());
70    }
71
72    class MockCacheRequest extends CacheRequest {
73
74        MockCacheRequest() {
75            super();
76        }
77
78        @Override
79        public void abort() {
80        }
81
82        @Override
83        public OutputStream getBody() throws IOException {
84            return null;
85        }
86    }
87}
88