This repository was archived by the owner on May 20, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.java
More file actions
90 lines (69 loc) · 2.67 KB
/
test.java
File metadata and controls
90 lines (69 loc) · 2.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import couch.Couch;
import couch.Client;
import couch.http.Request;
import couch.http.Response;
import couch.Query;
import couch.util.*;
import org.json.*;
import java.io.*;
import java.util.*;
import java.net.URL;
class Test
{
public static void main(String[] args) throws Exception {
Couch couch = new Couch();
// Couch couch = new Couch(null, true);
// Couch couch = new Couch(Util.paramList("debug", true));
Client client = new Client(couch);
Request request = new Request(client);
// request.setMethod("GET");
// request.setUri("/", null);
// request.send("");
// System.out.println(request.toString());
// Response response = client.request("GET /", null, null, null);
Response response = client.head("/", null, null);
System.out.println(client.getRequest().toString());
System.out.println(client.getResponse().toString());
System.out.println("---");
// JSONObject jo = (JSONObject) response.getBodyData();
// System.out.println(jo.get("couchdb"));
// System.out.println(((JSONObject)jo.get("vendor")).get("name"));
// request.setMethod("GET");
// request.setUri("/", null);
// System.out.println(request.getHeaderAll());
// HashMap query = Util.paramList(
// "foo", "bar",
// "x", true,
// "y", 1,
// "z", "[hello][boo]"
// );
// // System.out.println(map);
// // Query query = new Query(map);
// Query query = new Query();
// query.set("111");
// System.out.println(query.toString());
// request.setUri("/", query);
// HashMap map = new HashMap();
// map.put("name", "kerem");
// request.setBody(map);
// System.out.println(request.getBody());
// HashMap map = new HashMap();
// map.put("name", "foo");
// String json = JSONValue.toJSONString(map);
// HashMap map = Util.paramList("name", "foo");
// String js = Util.toJsonString(map);
// System.out.println(js);
// JSONObject jo = Util.jsonObject(js);
// System.out.println(jo.get("name"));
// JSONObject js = new JSONObject(map);
// System.out.println(js.get("name") == 1);
// Json json = Util.jsonObject("{\"foo\":123}");
// System.out.println(json.get("foo"));
// URL url = Util.parseUrl("localhost/foo");
// System.out.println(url.getHost());
// Map p = Util.paramList("debug", 1);
// Map p = Util.param(new HashMap<String,Object>());
// System.out.println(p);
}
}
// @SuppressWarnings("unchecked")