List of usage examples for org.json JSONObject append
public JSONObject append(String key, Object value) throws JSONException
From source file:org.wso2.carbon.connector.integration.test.gplus.GooglePlusTestCase.java
/** * Optional parameter pageToken check//from w w w . j a v a 2 s . com * * @throws Exception */ @Test(groups = { "wso2.esb" }, dependsOnMethods = { "testListPeopleWithMandatoryParams" }, description = "GooglePlus {listPeople} integration test with optional parameter pageToken.") public void testListPeopleOneOptionalParam2() throws Exception { String jsonRequestFilePath = pathToRequestsDirectory + "listPeopleOptionalParams.txt"; String methodName = "listPeople"; 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("listPeoplePageToken")); 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", "fields" }; String requiredJsonString = ConnectorIntegrationUtil.getRequiredJsonString(modifiedJsonString, unneededOptionalParameters); JSONObject responseJson = ConnectorIntegrationUtil.sendRequest(getProxyServiceURL(methodName), requiredJsonString); junit.framework.Assert.assertEquals("plus#peopleFeed", responseJson.getString("kind")); } finally { proxyAdmin.deleteProxy(methodName); } }
From source file:org.wso2.carbon.connector.integration.test.gplus.GooglePlusTestCase.java
/** * Optional parameter orderBy check//from www . j a va 2 s.c om * * @throws Exception */ @Test(groups = { "wso2.esb" }, dependsOnMethods = { "testListPeopleWithMandatoryParams" }, description = "GooglePlus {listPeople} integration test with optional parameter orderBy.") public void testListPeopleOneOptionalParam3() throws Exception { String jsonRequestFilePath = pathToRequestsDirectory + "listPeopleOptionalParams.txt"; String methodName = "listPeople"; 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("listPeoplePageToken")); 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", "fields" }; String requiredJsonString = ConnectorIntegrationUtil.getRequiredJsonString(modifiedJsonString, unneededOptionalParameters); JSONObject responseJson = ConnectorIntegrationUtil.sendRequest(getProxyServiceURL(methodName), requiredJsonString); junit.framework.Assert.assertEquals("plus#peopleFeed", responseJson.getString("kind")); } finally { proxyAdmin.deleteProxy(methodName); } }
From source file:org.wso2.carbon.connector.integration.test.gplus.GooglePlusTestCase.java
/** * Optional parameter fields check//from w w w. j a va 2 s .c o m * * @throws Exception */ @Test(groups = { "wso2.esb" }, dependsOnMethods = { "testListPeopleWithMandatoryParams" }, description = "GooglePlus {listPeople} integration test with optional parameter fields.") public void testListPeopleOneOptionalParam4() throws Exception { String jsonRequestFilePath = pathToRequestsDirectory + "listPeopleOptionalParams.txt"; String methodName = "listPeople"; 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("listPeoplePageToken")); 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", "orderBy" }; String requiredJsonString = ConnectorIntegrationUtil.getRequiredJsonString(modifiedJsonString, unneededOptionalParameters); JSONObject responseJson = ConnectorIntegrationUtil.sendRequest(getProxyServiceURL(methodName), requiredJsonString); junit.framework.Assert.assertEquals("plus#peopleFeed", responseJson.getString("kind")); } finally { proxyAdmin.deleteProxy(methodName); } }
From source file:org.wso2.carbon.connector.integration.test.gplus.GooglePlusTestCase.java
/** * Optional parameter test case for ListPeople method with maxResults,pageToken optional parameter. *///from w w w.j a v a2 s .co m @Test(groups = { "wso2.esb" }, dependsOnMethods = { "testListPeopleWithMandatoryParams" }, description = "GooglePlus {ListPeople} integration test with mandatory and maxResults,pageToken optional parameters.") public void testListPeopleWithTwoOptionalParams1() throws Exception { String jsonRequestFilePath = pathToRequestsDirectory + "listPeopleOptionalParams.txt"; String methodName = "listPeople"; 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("listPeoplePageToken")); 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", "fields" }; String requiredJsonString = ConnectorIntegrationUtil.getRequiredJsonString(modifiedJsonString, unneededOptionalParameters); JSONObject responseJson = ConnectorIntegrationUtil.sendRequest(getProxyServiceURL(methodName), requiredJsonString); junit.framework.Assert.assertEquals("plus#peopleFeed", responseJson.getString("kind")); } finally { proxyAdmin.deleteProxy(methodName); } }
From source file:org.wso2.carbon.connector.integration.test.gplus.GooglePlusTestCase.java
/** * Optional parameter test case for ListPeople method with maxResults,orderBy optional parameter. *//*from ww w . j a va2 s.c o m*/ @Test(groups = { "wso2.esb" }, dependsOnMethods = { "testListPeopleWithMandatoryParams" }, description = "GooglePlus {ListPeople} integration test with mandatory and maxResults,orderBy optional parameters.") public void testListPeopleWithTwoOptionalParams2() throws Exception { String jsonRequestFilePath = pathToRequestsDirectory + "listPeopleOptionalParams.txt"; String methodName = "listPeople"; 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("listPeoplePageToken")); 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", "pageToken" }; String requiredJsonString = ConnectorIntegrationUtil.getRequiredJsonString(modifiedJsonString, unneededOptionalParameters); JSONObject responseJson = ConnectorIntegrationUtil.sendRequest(getProxyServiceURL(methodName), requiredJsonString); junit.framework.Assert.assertEquals("plus#peopleFeed", responseJson.getString("kind")); } finally { proxyAdmin.deleteProxy(methodName); } }
From source file:org.wso2.carbon.connector.integration.test.gplus.GooglePlusTestCase.java
/** * Optional parameter test case for ListPeople method with maxResults,fields optional parameter. *//*from www. j a va 2 s . c om*/ @Test(groups = { "wso2.esb" }, dependsOnMethods = { "testListPeopleWithMandatoryParams" }, description = "GooglePlus {ListPeople} integration test with mandatory and maxResults,fields optional parameters.") public void testListPeopleWithTwoOptionalParams3() throws Exception { String jsonRequestFilePath = pathToRequestsDirectory + "listPeopleOptionalParams.txt"; String methodName = "listPeople"; 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("listPeoplePageToken")); 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); junit.framework.Assert.assertEquals("plus#peopleFeed", responseJson.getString("kind")); } finally { proxyAdmin.deleteProxy(methodName); } }
From source file:org.wso2.carbon.connector.integration.test.gplus.GooglePlusTestCase.java
/** * Optional parameter test case for ListPeople method with pageToken,orderBy. *//*from w w w . jav a 2 s . com*/ @Test(groups = { "wso2.esb" }, dependsOnMethods = { "testListPeopleWithMandatoryParams" }, description = "GooglePlus {ListPeople} integration test with mandatory and pageToken,orderBy optional parameters.") public void testListPeopleWithTwoOptionalParams4() throws Exception { String jsonRequestFilePath = pathToRequestsDirectory + "listPeopleOptionalParams.txt"; String methodName = "listPeople"; 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("listPeoplePageToken")); 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); junit.framework.Assert.assertEquals("plus#peopleFeed", responseJson.getString("kind")); } finally { proxyAdmin.deleteProxy(methodName); } }
From source file:org.wso2.carbon.connector.integration.test.gplus.GooglePlusTestCase.java
/** * Optional parameter test case for ListPeople method with pageToken,fields optional parameter *//*from w w w . j a v a2 s.c o m*/ @Test(groups = { "wso2.esb" }, dependsOnMethods = { "testListPeopleWithMandatoryParams" }, description = "GooglePlus {ListPeople} integration test with mandatory and language,fields optional parameters.") public void testListPeopleWithTwoOptionalParams5() throws Exception { String jsonRequestFilePath = pathToRequestsDirectory + "listPeopleOptionalParams.txt"; String methodName = "listPeople"; 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("listPeoplePageToken")); 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); junit.framework.Assert.assertEquals("plus#peopleFeed", responseJson.getString("kind")); } finally { proxyAdmin.deleteProxy(methodName); } }
From source file:org.wso2.carbon.connector.integration.test.gplus.GooglePlusTestCase.java
/** * Optional parameter test case for ListPeople method with orderBy,fields optional parameter. */// ww w .ja va 2 s. co m @Test(groups = { "wso2.esb" }, dependsOnMethods = { "testListPeopleWithMandatoryParams" }, description = "GooglePlus {ListPeople} integration test with mandatory and orderBy,fields optional parameters.") public void testListPeopleWithTwoOptionalParams6() throws Exception { String jsonRequestFilePath = pathToRequestsDirectory + "listPeopleOptionalParams.txt"; String methodName = "listPeople"; 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("listPeoplePageToken")); 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); junit.framework.Assert.assertEquals("plus#peopleFeed", responseJson.getString("kind")); } finally { proxyAdmin.deleteProxy(methodName); } }
From source file:org.wso2.carbon.connector.integration.test.gplus.GooglePlusTestCase.java
/** * Optional parameter "pageToken", "orderBy", "fields" check * * @throws Exception//w w w.j av a 2 s . co m */ @Test(groups = { "wso2.esb" }, dependsOnMethods = { "testListPeopleWithMandatoryParams" }, description = "GooglePlus {listPeople} integration test with optional parameter pageToken, orderBy, fields.") public void testListPeopleThreeOptionalParam1() throws Exception { String jsonRequestFilePath = pathToRequestsDirectory + "listPeopleOptionalParams.txt"; String methodName = "listPeople"; 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("listPeoplePageToken")); 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); junit.framework.Assert.assertEquals("plus#peopleFeed", responseJson.getString("kind")); } finally { proxyAdmin.deleteProxy(methodName); } }