EMMA Coverage Report (generated Tue Jun 26 14:54:12 CEST 2012)
[all classes][org.tomdroid.sync.web]

COVERAGE SUMMARY FOR SOURCE FILE [AnonymousConnection.java]

nameclass, %method, %block, %line, %
AnonymousConnection.java0%   (0/1)0%   (0/3)0%   (0/46)0%   (0/13)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class AnonymousConnection0%   (0/1)0%   (0/3)0%   (0/46)0%   (0/13)
AnonymousConnection (): void 0%   (0/1)0%   (0/3)0%   (0/1)
get (String): String 0%   (0/1)0%   (0/13)0%   (0/3)
put (String, String): String 0%   (0/1)0%   (0/30)0%   (0/9)

1/*
2 * Tomdroid
3 * Tomboy on Android
4 * http://www.launchpad.net/tomdroid
5 * 
6 * Copyright 2009, Benoit Garret <benoit.garret_launchpad@gadz.org>
7 * 
8 * This file is part of Tomdroid.
9 * 
10 * Tomdroid is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
14 * 
15 * Tomdroid is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 * GNU General Public License for more details.
19 * 
20 * You should have received a copy of the GNU General Public License
21 * along with Tomdroid.  If not, see <http://www.gnu.org/licenses/>.
22 */
23package org.tomdroid.sync.web;
24 
25import java.io.UnsupportedEncodingException;
26import java.net.UnknownHostException;
27 
28import org.apache.http.HttpResponse;
29import org.apache.http.client.methods.HttpGet;
30import org.apache.http.client.methods.HttpPut;
31import org.apache.http.entity.StringEntity;
32 
33public class AnonymousConnection extends WebConnection {
34 
35        @Override
36        public String get(String uri) throws UnknownHostException
37        {
38                // Prepare a request object
39                HttpGet httpGet = new HttpGet(uri);
40                HttpResponse response = execute(httpGet);
41                return parseResponse(response);
42        }
43        
44        @Override
45        public String put(String uri, String data) throws UnknownHostException {
46                
47                // Prepare a request object
48                HttpPut httpPut = new HttpPut(uri);
49                
50                try {
51                        // The default http content charset is ISO-8859-1, JSON requires UTF-8
52                        httpPut.setEntity(new StringEntity(data, "UTF-8"));
53                } catch (UnsupportedEncodingException e1) {
54                        e1.printStackTrace();
55                        return null;
56                }
57                
58                httpPut.setHeader("Content-Type", "application/json");
59                HttpResponse response = execute(httpPut);
60                return parseResponse(response);
61        }
62}

[all classes][org.tomdroid.sync.web]
EMMA 0.0.0 (unsupported private build) (C) Vladimir Roubtsov