forked from stleary/JSON-java
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathTestCookieList.java
More file actions
68 lines (59 loc) · 1.67 KB
/
TestCookieList.java
File metadata and controls
68 lines (59 loc) · 1.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
/*
* File: TestCookieList.java Author: JSON.org
*/
package org.json;
import org.json.CookieList;
import org.json.JSONException;
import org.json.JSONObject;
import junit.framework.TestCase;
/**
* The Class TestCookieList.
*/
public class TestCookieList extends TestCase
{
/** The jsonobject. */
JSONObject jsonobject = new JSONObject();
/**
* Tests the toJsonObject method using random cookie list.
*/
public void testToJsonObject_RandomCookieList()
{
try
{
jsonobject = CookieList
.toJSONObject(" f%oo = b+l=ah ; o;n%40e = t.wo ");
assertEquals("{\n \"o;n@e\": \"t.wo\",\n \"f%oo\": \"b l=ah\"\n}",
jsonobject.toString(2));
assertEquals("o%3bn@e=t.wo;f%25oo=b l%3dah",
CookieList.toString(jsonobject));
} catch (JSONException e)
{
fail(e.getMessage());
}
}
/**
* Tests the toJsonObject method using null key.
*/
public void testToJsonObject_NullKey()
{
try
{
jsonobject = CookieList
.toJSONObject(" f%oo = b+l=ah ; o;n%40e = t.wo ");
jsonobject.put("abc", JSONObject.NULL);
assertEquals("o%3bn@e=t.wo;f%25oo=b l%3dah",
CookieList.toString(jsonobject));
} catch (JSONException e)
{
fail(e.getMessage());
}
}
/**
* Tests the constructor method.
*/
public static void testConstructor()
{
CookieList cookielist = new CookieList();
assertEquals("CookieList", cookielist.getClass().getSimpleName());
}
}