本文整理匯總了Java中net.sf.json.JSONObject.clear方法的典型用法代碼示例。如果您正苦於以下問題:Java JSONObject.clear方法的具體用法?Java JSONObject.clear怎麽用?Java JSONObject.clear使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.sf.json.JSONObject
的用法示例。
在下文中一共展示了JSONObject.clear方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testFlow
import net.sf.json.JSONObject; //導入方法依賴的package包/類
@org.junit.Test
public void testFlow() throws Exception {
StatusNotifierCallbackTest.StatusNotifierCallbackImpl notifier = new StatusNotifierCallbackTest.StatusNotifierCallbackImpl();
BlazeMeterHttpUtilsEmul emul = new BlazeMeterHttpUtilsEmul(notifier, "test_address", "test_data_address", new BlazeMeterReport());
JSONObject result = new JSONObject();
result.put("id", "100");
result.put("name", "NEW_TEST");
JSONObject response = new JSONObject();
response.put("result", result);
Project project = new Project(emul, "10", "projectName");
emul.addEmul(response);
Test test = project.createTest("NEW_WORKSPACE");
assertEquals("100", test.getId());
assertEquals("NEW_TEST", test.getName());
response.clear();
JSONArray results = new JSONArray();
results.add(result);
results.add(result);
response.put("result", results);
emul.addEmul(response);
List<Test> tests = project.getTests();
assertEquals(2, tests.size());
for (Test t :tests) {
assertEquals("100", t.getId());
assertEquals("NEW_TEST", t.getName());
}
}
示例2: testFlow
import net.sf.json.JSONObject; //導入方法依賴的package包/類
@org.junit.Test
public void testFlow() throws Exception {
StatusNotifierCallbackTest.StatusNotifierCallbackImpl notifier = new StatusNotifierCallbackTest.StatusNotifierCallbackImpl();
BlazeMeterHttpUtilsEmul emul = new BlazeMeterHttpUtilsEmul(notifier, "test_address", "test_data_address", new BlazeMeterReport());
JSONObject result = new JSONObject();
result.put("id", "999");
result.put("name", "NEW_PROJECT");
JSONObject response = new JSONObject();
response.put("result", result);
Workspace workspace = new Workspace(emul, "888", "workspace_name");
emul.addEmul(response);
Project project = workspace.createProject("NEW_PROJECT");
assertEquals("999", project.getId());
assertEquals("NEW_PROJECT", project.getName());
response.clear();
JSONArray results = new JSONArray();
results.add(result);
results.add(result);
response.put("result", results);
emul.addEmul(response);
List<Project> projects = workspace.getProjects();
assertEquals(2, projects.size());
for (Project p :projects) {
assertEquals("999", p.getId());
assertEquals("NEW_PROJECT", p.getName());
}
}
示例3: testFlow
import net.sf.json.JSONObject; //導入方法依賴的package包/類
@Test
public void testFlow() throws Exception {
StatusNotifierCallbackTest.StatusNotifierCallbackImpl notifier = new StatusNotifierCallbackTest.StatusNotifierCallbackImpl();
BlazeMeterHttpUtilsEmul emul = new BlazeMeterHttpUtilsEmul(notifier, "test_address", "test_data_address", new BlazeMeterReport());
JSONObject result = new JSONObject();
result.put("id", "100");
result.put("name", "NEW_WORKSPACE");
JSONObject response = new JSONObject();
response.put("result", result);
Account account = new Account(emul, "777", "account_name");
emul.addEmul(response);
Workspace workspace = account.createWorkspace("NEW_WORKSPACE");
assertEquals("100", workspace.getId());
assertEquals("NEW_WORKSPACE", workspace.getName());
response.clear();
JSONArray results = new JSONArray();
results.add(result);
results.add(result);
response.put("result", results);
emul.addEmul(response);
List<Workspace> workspaces = account.getWorkspaces();
assertEquals(2, workspaces.size());
for (Workspace wsp :workspaces) {
assertEquals("100", wsp.getId());
assertEquals("NEW_WORKSPACE", wsp.getName());
}
}