List of usage examples for org.json JSONObject toString
public String toString()
From source file:org.wso2.carbon.connector.integration.test.flickr.FlickrConnectoreIntegrationTest.java
/** * Negative test case for addComment method with Negative parameters. *///from w ww .j av a 2 s. c om @Test(priority = 2, groups = { "wso2.esb" }, description = "flickr {addComment} integration test with Negative parameters") public void testFlickrAddCommentWithNegativeParameters() throws Exception { String jsonRequestFilePath = pathToRequestsDirectory + "flickr_addComment.txt"; String methodName = "flickr_addComment"; String rawString = ConnectorIntegrationUtil.getFileContent(jsonRequestFilePath); rawString = rawString.replace("dummyvalue", flickrConnectorProperties.getProperty("photoId")); final String jsonString = addCredentials(rawString); final String proxyFilePath = "file:///" + pathToProxiesDirectory + "/negetive/" + methodName + ".xml"; proxyAdmin.addProxyService(new DataHandler(new URL(proxyFilePath))); try { JSONObject responseConnector = ConnectorIntegrationUtil.sendRequest("POST", getProxyServiceURL(methodName), jsonString); String httpMethod = "GET"; String parameters = "format=json&nojsoncallback=1&method=flickr.photos.comments.getList&api_key=" + flickrConnectorProperties.getProperty("consumerKey") + "&photo_id=" + flickrConnectorProperties.getProperty("photoId"); JSONObject responseDirect = ConnectorIntegrationUtil.sendRestRequest(false, httpMethod, parameters, flickrConnectorProperties); Assert.assertTrue(responseConnector.getString("stat").equals("fail") && !responseDirect.toString() .contains(flickrConnectorProperties.getProperty("invalidComment"))); } finally { proxyAdmin.deleteProxy(methodName); } }
From source file:org.wso2.carbon.connector.integration.test.flickr.FlickrConnectoreIntegrationTest.java
/** * Negative test case for getCommentsList method with Negative parameters. *///w w w . j a v a2 s . co m @Test(priority = 2, groups = { "wso2.esb" }, description = "flickr {getCommentsList} integration test with Negative parameters") public void testFlickrGetCommentsListWithNegativeParameters() throws Exception { String jsonRequestFilePath = pathToRequestsDirectory + "flickr_getCommentList.txt"; String methodName = "flickr_getCommentList"; String rawString = ConnectorIntegrationUtil.getFileContent(jsonRequestFilePath); rawString = rawString.replace("dummyvalue", flickrConnectorProperties.getProperty("invalidPhotoId")); final String jsonString = addCredentials(rawString); final String proxyFilePath = "file:///" + pathToProxiesDirectory + "/negetive/" + methodName + ".xml"; proxyAdmin.addProxyService(new DataHandler(new URL(proxyFilePath))); try { JSONObject responseConnector = ConnectorIntegrationUtil.sendRequest("POST", getProxyServiceURL(methodName), jsonString); String httpMethod = "GET"; String parameters = "format=json&nojsoncallback=1&method=flickr.photos.comments.getList&api_key=" + flickrConnectorProperties.getProperty("consumerKey") + "&photo_id=" + flickrConnectorProperties.getProperty("invalidPhotoId"); JSONObject responseDirect = ConnectorIntegrationUtil.sendRestRequest(false, httpMethod, parameters, flickrConnectorProperties); Assert.assertTrue(responseConnector.getString("stat").equals("fail") && responseDirect.toString().equals(responseConnector.toString())); } finally { proxyAdmin.deleteProxy(methodName); } }
From source file:org.wso2.carbon.connector.integration.test.flickr.FlickrConnectoreIntegrationTest.java
/** * Negative test case for editComment method with Negative parameters. *//*from w w w. j a v a 2 s . c o m*/ @Test(priority = 2, groups = { "wso2.esb" }, description = "flickr {editComment} integration test with Negative parameters") public void testFlickrEditCommentWithNegativeParameters() throws Exception { String jsonRequestFilePath = pathToRequestsDirectory + "flickr_editComment.txt"; String methodName = "flickr_editComment"; String rawString = ConnectorIntegrationUtil.getFileContent(jsonRequestFilePath); String comment = flickrConnectorProperties.getProperty("comment") + System.currentTimeMillis(); rawString = rawString.replace("dummycomment", comment); final String jsonString = addCredentials(rawString); final String proxyFilePath = "file:///" + pathToProxiesDirectory + "/negetive/" + methodName + ".xml"; proxyAdmin.addProxyService(new DataHandler(new URL(proxyFilePath))); try { JSONObject responseConnector = ConnectorIntegrationUtil.sendRequest("POST", getProxyServiceURL(methodName), jsonString); String httpMethod = "GET"; String parameters = "format=json&nojsoncallback=1&method=flickr.photos.comments.getList&api_key=" + flickrConnectorProperties.getProperty("consumerKey") + "&photo_id=" + flickrConnectorProperties.getProperty("photoId"); JSONObject responseDirect = ConnectorIntegrationUtil.sendRestRequest(false, httpMethod, parameters, flickrConnectorProperties); Assert.assertTrue(responseConnector.getString("stat").equals("fail") && !responseDirect.toString().contains(comment)); } finally { proxyAdmin.deleteProxy(methodName); } }
From source file:org.wso2.carbon.connector.integration.test.flickr.FlickrConnectoreIntegrationTest.java
/** * Negative test case for getRecentCommentsForContacts method with Negative parameters. *///from w w w . j av a2 s. com @Test(priority = 2, groups = { "wso2.esb" }, description = "flickr {isLogged} integration test with Negative parameters.") public void testFlickrGetRecentCommentsForContactsWithNegativeParameters() throws Exception { String jsonRequestFilePath = pathToRequestsDirectory + "flickr_getRecentCommentsForContacts.txt"; String methodName = "flickr_getRecentCommentsForContacts"; final String rawString = ConnectorIntegrationUtil.getFileContent(jsonRequestFilePath); final String jsonString = addCredentials(rawString); final String proxyFilePath = "file:///" + pathToProxiesDirectory + "/negetive/" + methodName + ".xml"; proxyAdmin.addProxyService(new DataHandler(new URL(proxyFilePath))); try { JSONObject responseConnector = ConnectorIntegrationUtil.sendRequest("POST", getProxyServiceURL(methodName), jsonString); String httpMethod = "GET"; String parameters = "format=json" + "&method=flickr.photos.comments.getRecentForContacts" + "&nojsoncallback=1" + "&oauth_consumer_key=" + flickrConnectorProperties.getProperty("invalidConsumerKey") + "&oauth_nonce=dummynonce" + "&oauth_signature_method=HMAC-SHA1" + "&oauth_timestamp=dummytimestamp" + "&oauth_token=" + flickrConnectorProperties.getProperty("accessToken") + "&oauth_version=1.0"; JSONObject responseDirect = ConnectorIntegrationUtil.sendRestRequest(true, httpMethod, parameters, flickrConnectorProperties); Assert.assertTrue(responseConnector.getString("stat").equals("fail") && responseConnector.toString().equals(responseDirect.toString())); } finally { proxyAdmin.deleteProxy(methodName); } }
From source file:org.wso2.carbon.connector.integration.test.flickr.FlickrConnectoreIntegrationTest.java
/** * Negative test case for getInfo method with Negative parameters. *///from w w w. j av a2 s . co m @Test(priority = 2, groups = { "wso2.esb" }, description = "flickr {getInfo} integration test with Negative parameters") public void testFlickrGetInfoWithNegativeParameters() throws Exception { String jsonRequestFilePath = pathToRequestsDirectory + "flickr_getInfo.txt"; String methodName = "flickr_getInfo"; String rawString = ConnectorIntegrationUtil.getFileContent(jsonRequestFilePath); rawString = rawString.replace("dummyvalue", flickrConnectorProperties.getProperty("invalidUserId")); final String jsonString = addCredentials(rawString); final String proxyFilePath = "file:///" + pathToProxiesDirectory + "/negetive/" + methodName + ".xml"; proxyAdmin.addProxyService(new DataHandler(new URL(proxyFilePath))); try { JSONObject responseConnector = ConnectorIntegrationUtil.sendRequest("POST", getProxyServiceURL(methodName), jsonString); String httpMethod = "GET"; String parameters = "format=json&nojsoncallback=1&method=flickr.people.getInfo&api_key=" + flickrConnectorProperties.getProperty("consumerKey") + "&user_id=" + flickrConnectorProperties.getProperty("invalidUserId"); JSONObject responseDirect = ConnectorIntegrationUtil.sendRestRequest(false, httpMethod, parameters, flickrConnectorProperties); Assert.assertTrue(responseConnector.getString("stat").equals("fail") && responseConnector.toString().equals(responseDirect.toString())); } finally { proxyAdmin.deleteProxy(methodName); } }
From source file:org.wso2.carbon.connector.integration.test.flickr.FlickrConnectoreIntegrationTest.java
/** * Negative test case for getPhotos method with Negative parameters. *///from w ww. j a va2s . c om @Test(priority = 2, groups = { "wso2.esb" }, description = "flickr {getPhotos} integration test with Negative parameters") public void testFlickrGetPhotosWithNegativeParameters() throws Exception { String jsonRequestFilePath = pathToRequestsDirectory + "flickr_getPhotos.txt"; String methodName = "flickr_getPhotos"; String rawString = ConnectorIntegrationUtil.getFileContent(jsonRequestFilePath); rawString = rawString.replace("dummyvalue", flickrConnectorProperties.getProperty("invalidUserId")); final String jsonString = addCredentials(rawString); final String proxyFilePath = "file:///" + pathToProxiesDirectory + "/negetive/" + methodName + ".xml"; proxyAdmin.addProxyService(new DataHandler(new URL(proxyFilePath))); try { JSONObject responseConnector = ConnectorIntegrationUtil.sendRequest("POST", getProxyServiceURL(methodName), jsonString); String httpMethod = "GET"; String parameters = "format=json&nojsoncallback=1&method=flickr.people.getPhotos&api_key=" + flickrConnectorProperties.getProperty("consumerKey") + "&user_id=" + flickrConnectorProperties.getProperty("invalidUserId"); JSONObject responseDirect = ConnectorIntegrationUtil.sendRestRequest(false, httpMethod, parameters, flickrConnectorProperties); Assert.assertTrue(responseConnector.getString("stat").equals("fail") && responseConnector.toString().equals(responseDirect.toString())); } finally { proxyAdmin.deleteProxy(methodName); } }
From source file:org.wso2.carbon.connector.integration.test.flickr.FlickrConnectoreIntegrationTest.java
/** * Negative test case for getPhotoInfo method with Negative parameters. *///from ww w . j av a2 s . c om @Test(priority = 2, groups = { "wso2.esb" }, description = "flickr {getPhotoInfo} integration test with Negative parameters") public void testFlickrGetPhotoInfoWithNegativeParameters() throws Exception { String jsonRequestFilePath = pathToRequestsDirectory + "flickr_getPhotoInfo.txt"; String methodName = "flickr_getPhotoInfo"; String rawString = ConnectorIntegrationUtil.getFileContent(jsonRequestFilePath); rawString = rawString.replace("dummyvalue", flickrConnectorProperties.getProperty("invalidPhotoId")); final String jsonString = addCredentials(rawString); final String proxyFilePath = "file:///" + pathToProxiesDirectory + "/negetive/" + methodName + ".xml"; proxyAdmin.addProxyService(new DataHandler(new URL(proxyFilePath))); try { JSONObject responseConnector = ConnectorIntegrationUtil.sendRequest("POST", getProxyServiceURL(methodName), jsonString); String httpMethod = "GET"; String parameters = "format=json&nojsoncallback=1&method=flickr.photos.getInfo&api_key=" + flickrConnectorProperties.getProperty("consumerKey") + "&photo_id=" + flickrConnectorProperties.getProperty("invalidPhotoId"); JSONObject responseDirect = ConnectorIntegrationUtil.sendRestRequest(false, httpMethod, parameters, flickrConnectorProperties); Assert.assertTrue(responseConnector.getString("stat").equals("fail") && responseConnector.toString().equals(responseDirect.toString())); } finally { proxyAdmin.deleteProxy(methodName); } }
From source file:org.wso2.carbon.connector.integration.test.flickr.FlickrConnectoreIntegrationTest.java
/** * Negative test case for getExif method with Negative parameters. *///from ww w . j a v a2s. c o m @Test(priority = 2, groups = { "wso2.esb" }, description = "flickr {getExif} integration test with Negative parameters") public void testFlickrGetExifWithNegativeParameters() throws Exception { String jsonRequestFilePath = pathToRequestsDirectory + "flickr_getExif.txt"; String methodName = "flickr_getExif"; String rawString = ConnectorIntegrationUtil.getFileContent(jsonRequestFilePath); rawString = rawString.replace("dummyvalue", flickrConnectorProperties.getProperty("invalidPhotoId")); final String jsonString = addCredentials(rawString); final String proxyFilePath = "file:///" + pathToProxiesDirectory + "/negetive/" + methodName + ".xml"; proxyAdmin.addProxyService(new DataHandler(new URL(proxyFilePath))); try { JSONObject responseConnector = ConnectorIntegrationUtil.sendRequest("POST", getProxyServiceURL(methodName), jsonString); String httpMethod = "GET"; String parameters = "format=json&nojsoncallback=1&method=flickr.photos.getExif&api_key=" + flickrConnectorProperties.getProperty("consumerKey") + "&photo_id=" + flickrConnectorProperties.getProperty("invalidPhotoId"); JSONObject responseDirect = ConnectorIntegrationUtil.sendRestRequest(false, httpMethod, parameters, flickrConnectorProperties); Assert.assertTrue(responseConnector.getString("stat").equals("fail") && responseConnector.toString().equals(responseDirect.toString())); } finally { proxyAdmin.deleteProxy(methodName); } }
From source file:org.wso2.carbon.connector.integration.test.flickr.FlickrConnectoreIntegrationTest.java
/** * Negative test case for addTags method with Negative parameters. *///from w ww.j a v a 2s .c o m @Test(priority = 2, groups = { "wso2.esb" }, description = "flickr {addTags} integration test with Negative parameters") public void testFlickrAddTagsWithNegativeParameters() throws Exception { String jsonRequestFilePath = pathToRequestsDirectory + "flickr_addTags.txt"; String methodName = "flickr_addTags"; String rawString = ConnectorIntegrationUtil.getFileContent(jsonRequestFilePath); rawString = rawString.replace("dummyvalue", flickrConnectorProperties.getProperty("invalidPhotoId")); final String jsonString = addCredentials(rawString); final String proxyFilePath = "file:///" + pathToProxiesDirectory + "/negetive/" + methodName + ".xml"; proxyAdmin.addProxyService(new DataHandler(new URL(proxyFilePath))); try { JSONObject responseConnector = ConnectorIntegrationUtil.sendRequest("POST", getProxyServiceURL(methodName), jsonString); String httpMethod = "GET"; String parameters = "format=json&nojsoncallback=1&method=flickr.photos.getInfo&api_key=" + flickrConnectorProperties.getProperty("consumerKey") + "&photo_id=" + flickrConnectorProperties.getProperty("PhotoId"); JSONObject responseDirect = ConnectorIntegrationUtil.sendRestRequest(false, httpMethod, parameters, flickrConnectorProperties); Assert.assertTrue(responseConnector.getString("stat").equals("fail") && !responseDirect.toString().contains("negetiveTag")); } finally { proxyAdmin.deleteProxy(methodName); } }
From source file:org.wso2.carbon.connector.integration.test.flickr.FlickrConnectoreIntegrationTest.java
/** * Positive test case for getCommentsList method with Optional parameters. *///from w ww . ja v a 2 s . com @Test(priority = 3, groups = { "wso2.esb" }, description = "flickr {getCommentsList} integration test with Optional parameters") public void testFlickrGetCommentsListWithOptionalParameters() throws Exception { String jsonRequestFilePath = pathToRequestsDirectory + "optional/flickr_getCommentList.txt"; String methodName = "flickr_getCommentList"; String rawString = ConnectorIntegrationUtil.getFileContent(jsonRequestFilePath); rawString = rawString.replace("dummyvalue", flickrConnectorProperties.getProperty("photoId")); rawString = rawString.replace("dummymindate", flickrConnectorProperties.getProperty("minDate")); rawString = rawString.replace("dummymaxdate", flickrConnectorProperties.getProperty("maxDate")); final String jsonString = addCredentials(rawString); final String proxyFilePath = "file:///" + pathToProxiesDirectory + "optional/" + methodName + ".xml"; proxyAdmin.addProxyService(new DataHandler(new URL(proxyFilePath))); try { JSONObject responseConnector = ConnectorIntegrationUtil.sendRequest("POST", getProxyServiceURL(methodName), jsonString); String httpMethod = "GET"; String parameters = "format=json&nojsoncallback=1&method=flickr.photos.comments.getList&api_key=" + flickrConnectorProperties.getProperty("consumerKey") + "&photo_id=" + flickrConnectorProperties.getProperty("photoId") + "&min_comment_date=" + flickrConnectorProperties.getProperty("minDate") + "&max_comment_date=" + flickrConnectorProperties.getProperty("maxDate"); JSONObject responseDirect = ConnectorIntegrationUtil.sendRestRequest(false, httpMethod, parameters, flickrConnectorProperties); Assert.assertTrue(responseDirect.toString().equals(responseConnector.toString())); } finally { proxyAdmin.deleteProxy(methodName); } }