Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
23410 tejbeer 1
/*
2
 * Copyright (C) 2012 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
 
17
package com.android.volley.mock;
18
 
19
import java.io.ByteArrayOutputStream;
20
import java.io.IOException;
21
import java.io.OutputStream;
22
import java.net.HttpURLConnection;
23
import java.net.MalformedURLException;
24
import java.net.URL;
25
 
26
public class MockHttpURLConnection extends HttpURLConnection {
27
 
28
    private boolean mDoOutput;
29
    private String mRequestMethod;
30
    private OutputStream mOutputStream;
31
 
32
    public MockHttpURLConnection() throws MalformedURLException {
33
        super(new URL("http://foo.com"));
34
        mDoOutput = false;
35
        mRequestMethod = "GET";
36
        mOutputStream = new ByteArrayOutputStream();
37
    }
38
 
39
    @Override
40
    public void setDoOutput(boolean flag) {
41
        mDoOutput = flag;
42
    }
43
 
44
    @Override
45
    public boolean getDoOutput() {
46
        return mDoOutput;
47
    }
48
 
49
    @Override
50
    public void setRequestMethod(String method) {
51
        mRequestMethod = method;
52
    }
53
 
54
    @Override
55
    public String getRequestMethod() {
56
        return mRequestMethod;
57
    }
58
 
59
    @Override
60
    public OutputStream getOutputStream() {
61
        return mOutputStream;
62
    }
63
 
64
    @Override
65
    public void disconnect() {
66
    }
67
 
68
    @Override
69
    public boolean usingProxy() {
70
        return false;
71
    }
72
 
73
    @Override
74
    public void connect() throws IOException {
75
    }
76
 
77
}