Example usage for org.json JSONObject append

List of usage examples for org.json JSONObject append

Introduction

In this page you can find the example usage for org.json JSONObject append.

Prototype

public JSONObject append(String key, Object value) throws JSONException 

Source Link

Document

Append values to the array under a key.

Usage

From source file:org.wso2.carbon.connector.integration.test.gplus.GooglePlusTestCase.java

/**
 * Optional parameter test case for searchActivities method with language,maxResults,orderBy,pageToken .
 *//*  ww  w  .  j a  va2s . co m*/
@Test(groups = { "wso2.esb" }, dependsOnMethods = {
        "testSearchActivityWithMandatoryParams" }, description = "GooglePlus {searchActivities} integration test with mandatory and language,maxResults,orderBy,pageToken optional parameters.")
public void testSearchActivityWithFourOptionalParams1() throws Exception {
    String jsonRequestFilePath = pathToRequestsDirectory + "searchActivitiesOptionalParams.txt";
    String methodName = "searchActivities";
    final String requestJsonString = ConnectorIntegrationUtil.getFileContent(jsonRequestFilePath);
    final String proxyFilePath = "file:///" + pathToProxiesDirectory + methodName + ".xml";
    proxyAdmin.addProxyService(new DataHandler(new URL(proxyFilePath)));
    JSONObject jsonObject = new JSONObject(requestJsonString);
    jsonObject.append("pageToken", googlePlusConnectorProperties.getProperty("searchActivitiesPageToken"));
    jsonObject.append("apiUrl", googlePlusConnectorProperties.getProperty("apiUrl"));
    jsonObject.append("clientId", googlePlusConnectorProperties.getProperty("clientId"));
    jsonObject.append("clientSecret", googlePlusConnectorProperties.getProperty("clientSecret"));
    jsonObject.append("refreshToken", googlePlusConnectorProperties.getProperty("refreshToken"));
    String modifiedJsonString = jsonObject.toString().replace("[", "").replace("]", "");
    try {
        String[] unneededOptionalParameters = { "fields" };
        String requiredJsonString = ConnectorIntegrationUtil.getRequiredJsonString(modifiedJsonString,
                unneededOptionalParameters);
        JSONObject responseJson = ConnectorIntegrationUtil.sendRequest(getProxyServiceURL(methodName),
                requiredJsonString);
        Assert.assertEquals("plus#activityFeed", responseJson.getString("kind"));
    } finally {
        proxyAdmin.deleteProxy(methodName);
    }
}

From source file:org.wso2.carbon.connector.integration.test.gplus.GooglePlusTestCase.java

/**
 * Optional parameter test case for searchActivities method with language,maxResults,orderBy,fields .
 *//*from   ww  w .  ja  v a  2 s . c  o m*/
@Test(groups = { "wso2.esb" }, dependsOnMethods = {
        "testSearchActivityWithMandatoryParams" }, description = "GooglePlus {searchActivities} integration test with mandatory and language,maxResults,orderBy,fields optional parameters.")
public void testSearchActivityWithFourOptionalParams2() throws Exception {
    String jsonRequestFilePath = pathToRequestsDirectory + "searchActivitiesOptionalParams.txt";
    String methodName = "searchActivities";
    final String requestJsonString = ConnectorIntegrationUtil.getFileContent(jsonRequestFilePath);
    final String proxyFilePath = "file:///" + pathToProxiesDirectory + methodName + ".xml";
    proxyAdmin.addProxyService(new DataHandler(new URL(proxyFilePath)));
    JSONObject jsonObject = new JSONObject(requestJsonString);
    jsonObject.append("pageToken", googlePlusConnectorProperties.getProperty("searchActivitiesPageToken"));
    jsonObject.append("apiUrl", googlePlusConnectorProperties.getProperty("apiUrl"));
    jsonObject.append("clientId", googlePlusConnectorProperties.getProperty("clientId"));
    jsonObject.append("clientSecret", googlePlusConnectorProperties.getProperty("clientSecret"));
    jsonObject.append("refreshToken", googlePlusConnectorProperties.getProperty("refreshToken"));
    String modifiedJsonString = jsonObject.toString().replace("[", "").replace("]", "");
    try {
        String[] unneededOptionalParameters = { "pageToken" };
        String requiredJsonString = ConnectorIntegrationUtil.getRequiredJsonString(modifiedJsonString,
                unneededOptionalParameters);
        JSONObject responseJson = ConnectorIntegrationUtil.sendRequest(getProxyServiceURL(methodName),
                requiredJsonString);
        Assert.assertEquals("plus#activityFeed", responseJson.getString("kind"));
    } finally {
        proxyAdmin.deleteProxy(methodName);
    }
}

From source file:org.wso2.carbon.connector.integration.test.gplus.GooglePlusTestCase.java

/**
 * Optional parameter test case for searchActivities method with language,maxResults,pageToken,fields .
 *//*  w w w .ja  va 2s  . c o m*/
@Test(groups = { "wso2.esb" }, dependsOnMethods = {
        "testSearchActivityWithMandatoryParams" }, description = "GooglePlus {searchActivities} integration test with mandatory and language,maxResults,pageToken,fields optional parameters.")
public void testSearchActivityWithFourOptionalParams3() throws Exception {
    String jsonRequestFilePath = pathToRequestsDirectory + "searchActivitiesOptionalParams.txt";
    String methodName = "searchActivities";
    final String requestJsonString = ConnectorIntegrationUtil.getFileContent(jsonRequestFilePath);
    final String proxyFilePath = "file:///" + pathToProxiesDirectory + methodName + ".xml";
    proxyAdmin.addProxyService(new DataHandler(new URL(proxyFilePath)));
    JSONObject jsonObject = new JSONObject(requestJsonString);
    jsonObject.append("pageToken", googlePlusConnectorProperties.getProperty("searchActivitiesPageToken"));
    jsonObject.append("apiUrl", googlePlusConnectorProperties.getProperty("apiUrl"));
    jsonObject.append("clientId", googlePlusConnectorProperties.getProperty("clientId"));
    jsonObject.append("clientSecret", googlePlusConnectorProperties.getProperty("clientSecret"));
    jsonObject.append("refreshToken", googlePlusConnectorProperties.getProperty("refreshToken"));
    String modifiedJsonString = jsonObject.toString().replace("[", "").replace("]", "");
    try {
        String[] unneededOptionalParameters = { "orderBy" };
        String requiredJsonString = ConnectorIntegrationUtil.getRequiredJsonString(modifiedJsonString,
                unneededOptionalParameters);
        JSONObject responseJson = ConnectorIntegrationUtil.sendRequest(getProxyServiceURL(methodName),
                requiredJsonString);
        Assert.assertEquals("plus#activityFeed", responseJson.getString("kind"));
    } finally {
        proxyAdmin.deleteProxy(methodName);
    }
}

From source file:org.wso2.carbon.connector.integration.test.gplus.GooglePlusTestCase.java

/**
 * Optional parameter test case for searchActivities method with language,orderBy,pageToken,fields .
 *///from w w w .  j  a va  2  s  .  co  m

@Test(groups = { "wso2.esb" }, dependsOnMethods = {
        "testSearchActivityWithMandatoryParams" }, description = "GooglePlus {searchActivities} integration test with mandatory and language,orderBy,pageToken,fields optional parameters.")
public void testSearchActivityWithFourOptionalParams4() throws Exception {
    String jsonRequestFilePath = pathToRequestsDirectory + "searchActivitiesOptionalParams.txt";
    String methodName = "searchActivities";
    final String requestJsonString = ConnectorIntegrationUtil.getFileContent(jsonRequestFilePath);
    final String proxyFilePath = "file:///" + pathToProxiesDirectory + methodName + ".xml";
    proxyAdmin.addProxyService(new DataHandler(new URL(proxyFilePath)));
    JSONObject jsonObject = new JSONObject(requestJsonString);
    jsonObject.append("pageToken", googlePlusConnectorProperties.getProperty("searchActivitiesPageToken"));
    jsonObject.append("apiUrl", googlePlusConnectorProperties.getProperty("apiUrl"));
    jsonObject.append("clientId", googlePlusConnectorProperties.getProperty("clientId"));
    jsonObject.append("clientSecret", googlePlusConnectorProperties.getProperty("clientSecret"));
    jsonObject.append("refreshToken", googlePlusConnectorProperties.getProperty("refreshToken"));
    String modifiedJsonString = jsonObject.toString().replace("[", "").replace("]", "");
    try {
        String[] unneededOptionalParameters = { "maxResults" };
        String requiredJsonString = ConnectorIntegrationUtil.getRequiredJsonString(modifiedJsonString,
                unneededOptionalParameters);
        JSONObject responseJson = ConnectorIntegrationUtil.sendRequest(getProxyServiceURL(methodName),
                requiredJsonString);
        Assert.assertEquals("plus#activityFeed", responseJson.getString("kind"));
    } finally {
        proxyAdmin.deleteProxy(methodName);
    }
}

From source file:org.wso2.carbon.connector.integration.test.gplus.GooglePlusTestCase.java

/**
 * Optional parameter test case for searchActivities method with maxResults,orderBy,pageToken,fields.
 *///from   w  ww.  jav a 2s  .co  m
@Test(groups = { "wso2.esb" }, dependsOnMethods = {
        "testSearchActivityWithMandatoryParams" }, description = "GooglePlus {searchActivities} integration test with mandatory and maxResults,orderBy,pageToken,fields optional parameters.")
public void testSearchActivityWithFourOptionalParams5() throws Exception {
    String jsonRequestFilePath = pathToRequestsDirectory + "searchActivitiesOptionalParams.txt";
    String methodName = "searchActivities";
    final String requestJsonString = ConnectorIntegrationUtil.getFileContent(jsonRequestFilePath);
    final String proxyFilePath = "file:///" + pathToProxiesDirectory + methodName + ".xml";
    proxyAdmin.addProxyService(new DataHandler(new URL(proxyFilePath)));
    JSONObject jsonObject = new JSONObject(requestJsonString);
    jsonObject.append("pageToken", googlePlusConnectorProperties.getProperty("searchActivitiesPageToken"));
    jsonObject.append("apiUrl", googlePlusConnectorProperties.getProperty("apiUrl"));
    jsonObject.append("clientId", googlePlusConnectorProperties.getProperty("clientId"));
    jsonObject.append("clientSecret", googlePlusConnectorProperties.getProperty("clientSecret"));
    jsonObject.append("refreshToken", googlePlusConnectorProperties.getProperty("refreshToken"));
    String modifiedJsonString = jsonObject.toString().replace("[", "").replace("]", "");
    try {
        String[] unneededOptionalParameters = { "language" };
        String requiredJsonString = ConnectorIntegrationUtil.getRequiredJsonString(modifiedJsonString,
                unneededOptionalParameters);
        JSONObject responseJson = ConnectorIntegrationUtil.sendRequest(getProxyServiceURL(methodName),
                requiredJsonString);
        Assert.assertEquals("plus#activityFeed", responseJson.getString("kind"));
    } finally {
        proxyAdmin.deleteProxy(methodName);
    }
}

From source file:org.wso2.carbon.connector.integration.test.gplus.GooglePlusTestCase.java

/**
 * Optional parameter test case for searchActivities method with language,maxResults,fields optional parameter.
 *//* w w  w. j  av a2  s . c o  m*/
@Test(groups = { "wso2.esb" }, dependsOnMethods = {
        "testSearchActivityWithMandatoryParams" }, description = "GooglePlus {searchActivities} integration test with mandatory and language,maxResults,fields optional parameters.")
public void testSearchActivityWithThreeOptionalParams1() throws Exception {
    String jsonRequestFilePath = pathToRequestsDirectory + "searchActivitiesOptionalParams.txt";
    String methodName = "searchActivities";
    final String requestJsonString = ConnectorIntegrationUtil.getFileContent(jsonRequestFilePath);
    final String proxyFilePath = "file:///" + pathToProxiesDirectory + methodName + ".xml";
    proxyAdmin.addProxyService(new DataHandler(new URL(proxyFilePath)));
    JSONObject jsonObject = new JSONObject(requestJsonString);
    jsonObject.append("pageToken", googlePlusConnectorProperties.getProperty("searchActivitiesPageToken"));
    jsonObject.append("apiUrl", googlePlusConnectorProperties.getProperty("apiUrl"));
    jsonObject.append("clientId", googlePlusConnectorProperties.getProperty("clientId"));
    jsonObject.append("clientSecret", googlePlusConnectorProperties.getProperty("clientSecret"));
    jsonObject.append("refreshToken", googlePlusConnectorProperties.getProperty("refreshToken"));
    String modifiedJsonString = jsonObject.toString().replace("[", "").replace("]", "");
    try {
        String[] unneededOptionalParameters = { "orderBy", "pageToken" };
        String requiredJsonString = ConnectorIntegrationUtil.getRequiredJsonString(modifiedJsonString,
                unneededOptionalParameters);
        JSONObject responseJson = ConnectorIntegrationUtil.sendRequest(getProxyServiceURL(methodName),
                requiredJsonString);
        Assert.assertEquals("plus#activityFeed", responseJson.getString("kind"));
    } finally {
        proxyAdmin.deleteProxy(methodName);
    }
}

From source file:org.wso2.carbon.connector.integration.test.gplus.GooglePlusTestCase.java

/**
 * Optional parameter test case for searchActivities method with language,orderBy,pageToken optional parameter.
 *//* www  . j a v  a2  s  . co m*/
@Test(groups = { "wso2.esb" }, dependsOnMethods = {
        "testSearchActivityWithMandatoryParams" }, description = "GooglePlus {searchActivities} integration test with mandatory and language,orderBy,pageToken optional parameters.")
public void testSearchActivityWithThreeOptionalParams2() throws Exception {
    String jsonRequestFilePath = pathToRequestsDirectory + "searchActivitiesOptionalParams.txt";
    String methodName = "searchActivities";
    final String requestJsonString = ConnectorIntegrationUtil.getFileContent(jsonRequestFilePath);
    final String proxyFilePath = "file:///" + pathToProxiesDirectory + methodName + ".xml";
    proxyAdmin.addProxyService(new DataHandler(new URL(proxyFilePath)));
    JSONObject jsonObject = new JSONObject(requestJsonString);
    jsonObject.append("pageToken", googlePlusConnectorProperties.getProperty("searchActivitiesPageToken"));
    jsonObject.append("apiUrl", googlePlusConnectorProperties.getProperty("apiUrl"));
    jsonObject.append("clientId", googlePlusConnectorProperties.getProperty("clientId"));
    jsonObject.append("clientSecret", googlePlusConnectorProperties.getProperty("clientSecret"));
    jsonObject.append("refreshToken", googlePlusConnectorProperties.getProperty("refreshToken"));
    String modifiedJsonString = jsonObject.toString().replace("[", "").replace("]", "");
    try {
        String[] unneededOptionalParameters = { "maxResults", "fields" };
        String requiredJsonString = ConnectorIntegrationUtil.getRequiredJsonString(modifiedJsonString,
                unneededOptionalParameters);
        JSONObject responseJson = ConnectorIntegrationUtil.sendRequest(getProxyServiceURL(methodName),
                requiredJsonString);
        Assert.assertEquals("plus#activityFeed", responseJson.getString("kind"));
    } finally {
        proxyAdmin.deleteProxy(methodName);
    }
}

From source file:org.wso2.carbon.connector.integration.test.gplus.GooglePlusTestCase.java

/**
 * Optional parameter test case for searchActivities method with language,orderBy,fields optional parameter.
 *///  w  ww .  j  ava  2 s.c  o  m
@Test(groups = { "wso2.esb" }, dependsOnMethods = {
        "testSearchActivityWithMandatoryParams" }, description = "GooglePlus {searchActivities} integration test with mandatory and language,orderBy,fields optional parameters.")
public void testSearchActivityWithThreeOptionalParams3() throws Exception {
    String jsonRequestFilePath = pathToRequestsDirectory + "searchActivitiesOptionalParams.txt";
    String methodName = "searchActivities";
    final String requestJsonString = ConnectorIntegrationUtil.getFileContent(jsonRequestFilePath);
    final String proxyFilePath = "file:///" + pathToProxiesDirectory + methodName + ".xml";
    proxyAdmin.addProxyService(new DataHandler(new URL(proxyFilePath)));
    JSONObject jsonObject = new JSONObject(requestJsonString);
    jsonObject.append("pageToken", googlePlusConnectorProperties.getProperty("searchActivitiesPageToken"));
    jsonObject.append("apiUrl", googlePlusConnectorProperties.getProperty("apiUrl"));
    jsonObject.append("clientId", googlePlusConnectorProperties.getProperty("clientId"));
    jsonObject.append("clientSecret", googlePlusConnectorProperties.getProperty("clientSecret"));
    jsonObject.append("refreshToken", googlePlusConnectorProperties.getProperty("refreshToken"));
    String modifiedJsonString = jsonObject.toString().replace("[", "").replace("]", "");
    try {
        String[] unneededOptionalParameters = { "maxResults", "pageToken" };
        String requiredJsonString = ConnectorIntegrationUtil.getRequiredJsonString(modifiedJsonString,
                unneededOptionalParameters);
        JSONObject responseJson = ConnectorIntegrationUtil.sendRequest(getProxyServiceURL(methodName),
                requiredJsonString);
        Assert.assertEquals("plus#activityFeed", responseJson.getString("kind"));
    } finally {
        proxyAdmin.deleteProxy(methodName);
    }
}

From source file:org.wso2.carbon.connector.integration.test.gplus.GooglePlusTestCase.java

/**
 * Optional parameter test case for searchActivities method with language,pageToken,fields.
 */// www.  j av  a  2  s .  co  m
@Test(groups = { "wso2.esb" }, dependsOnMethods = {
        "testSearchActivityWithMandatoryParams" }, description = "GooglePlus {searchActivities} integration test with mandatory and language,pageToken,fields optional parameters.")
public void testSearchActivityWithThreeOptionalParams4() throws Exception {
    String jsonRequestFilePath = pathToRequestsDirectory + "searchActivitiesOptionalParams.txt";
    String methodName = "searchActivities";
    final String requestJsonString = ConnectorIntegrationUtil.getFileContent(jsonRequestFilePath);
    final String proxyFilePath = "file:///" + pathToProxiesDirectory + methodName + ".xml";
    proxyAdmin.addProxyService(new DataHandler(new URL(proxyFilePath)));
    JSONObject jsonObject = new JSONObject(requestJsonString);
    jsonObject.append("pageToken", googlePlusConnectorProperties.getProperty("searchActivitiesPageToken"));
    jsonObject.append("apiUrl", googlePlusConnectorProperties.getProperty("apiUrl"));
    jsonObject.append("clientId", googlePlusConnectorProperties.getProperty("clientId"));
    jsonObject.append("clientSecret", googlePlusConnectorProperties.getProperty("clientSecret"));
    jsonObject.append("refreshToken", googlePlusConnectorProperties.getProperty("refreshToken"));
    String modifiedJsonString = jsonObject.toString().replace("[", "").replace("]", "");
    try {
        String[] unneededOptionalParameters = { "maxResults", "orderBy" };
        String requiredJsonString = ConnectorIntegrationUtil.getRequiredJsonString(modifiedJsonString,
                unneededOptionalParameters);
        JSONObject responseJson = ConnectorIntegrationUtil.sendRequest(getProxyServiceURL(methodName),
                requiredJsonString);
        Assert.assertEquals("plus#activityFeed", responseJson.getString("kind"));
    } finally {
        proxyAdmin.deleteProxy(methodName);
    }
}

From source file:org.wso2.carbon.connector.integration.test.gplus.GooglePlusTestCase.java

/**
 * Optional parameter test case for searchActivities method with maxResults,orderBy,pageToken optional parameter
 *///from w ww .j  a v  a  2  s .  c  o m
@Test(groups = { "wso2.esb" }, dependsOnMethods = {
        "testSearchActivityWithMandatoryParams" }, description = "GooglePlus {searchActivities} integration test with mandatory and maxResults,orderBy,pageToken optional parameters.")
public void testSearchActivityWithThreeOptionalParams5() throws Exception {
    String jsonRequestFilePath = pathToRequestsDirectory + "searchActivitiesOptionalParams.txt";
    String methodName = "searchActivities";
    final String requestJsonString = ConnectorIntegrationUtil.getFileContent(jsonRequestFilePath);
    final String proxyFilePath = "file:///" + pathToProxiesDirectory + methodName + ".xml";
    proxyAdmin.addProxyService(new DataHandler(new URL(proxyFilePath)));
    JSONObject jsonObject = new JSONObject(requestJsonString);
    jsonObject.append("pageToken", googlePlusConnectorProperties.getProperty("searchActivitiesPageToken"));
    jsonObject.append("apiUrl", googlePlusConnectorProperties.getProperty("apiUrl"));
    jsonObject.append("clientId", googlePlusConnectorProperties.getProperty("clientId"));
    jsonObject.append("clientSecret", googlePlusConnectorProperties.getProperty("clientSecret"));
    jsonObject.append("refreshToken", googlePlusConnectorProperties.getProperty("refreshToken"));
    String modifiedJsonString = jsonObject.toString().replace("[", "").replace("]", "");
    try {
        String[] unneededOptionalParameters = { "language", "fields" };
        String requiredJsonString = ConnectorIntegrationUtil.getRequiredJsonString(modifiedJsonString,
                unneededOptionalParameters);
        JSONObject responseJson = ConnectorIntegrationUtil.sendRequest(getProxyServiceURL(methodName),
                requiredJsonString);
        Assert.assertEquals("plus#activityFeed", responseJson.getString("kind"));
    } finally {
        proxyAdmin.deleteProxy(methodName);
    }
}