diff --git a/modules/integration/tests-common/admin-clients/pom.xml b/modules/integration/tests-common/admin-clients/pom.xml
index cbd7a8a660..e4ebe1b807 100644
--- a/modules/integration/tests-common/admin-clients/pom.xml
+++ b/modules/integration/tests-common/admin-clients/pom.xml
@@ -77,6 +77,10 @@ under the License.
org.wso2.carbon
org.wso2.carbon.priority.executors.stub
+
+ org.wso2.carbon.deployment
+ org.wso2.carbon.webapp.mgt.stub
+
org.wso2.carbon
org.wso2.carbon.rest.api
diff --git a/modules/integration/tests-common/admin-clients/src/main/java/org/wso2/am/admin/clients/webapp/WebAppAdminClient.java b/modules/integration/tests-common/admin-clients/src/main/java/org/wso2/am/admin/clients/webapp/WebAppAdminClient.java
new file mode 100644
index 0000000000..7faa33cfc6
--- /dev/null
+++ b/modules/integration/tests-common/admin-clients/src/main/java/org/wso2/am/admin/clients/webapp/WebAppAdminClient.java
@@ -0,0 +1,143 @@
+/*
+ * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.wso2.am.admin.clients.webapp;
+
+import org.apache.axis2.AxisFault;
+import org.wso2.carbon.integration.common.admin.client.utils.AuthenticateStubUtil;
+import org.wso2.carbon.webapp.mgt.stub.WebappAdminStub;
+import org.wso2.carbon.webapp.mgt.stub.types.carbon.VersionedWebappMetadata;
+import org.wso2.carbon.webapp.mgt.stub.types.carbon.WebappMetadata;
+import org.wso2.carbon.webapp.mgt.stub.types.carbon.WebappUploadData;
+import org.wso2.carbon.webapp.mgt.stub.types.carbon.WebappsWrapper;
+
+import javax.activation.DataHandler;
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.rmi.RemoteException;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Client that enable the functions of WebappAdmin service.
+ */
+public class WebAppAdminClient {
+ private WebappAdminStub webappAdminStub;
+
+ public WebAppAdminClient(String backendUrl, String sessionCookie) throws AxisFault {
+ String serviceName = "WebappAdmin";
+ String endPoint = backendUrl + serviceName;
+ webappAdminStub = new WebappAdminStub(endPoint);
+ AuthenticateStubUtil.authenticateStub(sessionCookie, webappAdminStub);
+ }
+
+ /**
+ * Upload war files to the "repository/deployment/server/webapps/" location.
+ * Those war files will get automatically deployed.
+ *
+ * @param filePath - path to the location where the war files if locally located.
+ * @return boolean - Return true if WebApp upload success else false.
+ * @throws RemoteException - Exception occurs when uploading an war file using WebappAdminStub.
+ * @throws MalformedURLException - Exception occurs when creating the URL Object.
+ */
+
+ public boolean uploadWarFile(String filePath) throws RemoteException, MalformedURLException {
+ File file = new File(filePath);
+ String fileName = file.getName();
+ URL url = new URL("file://" + filePath);
+ DataHandler dh = new DataHandler(url);
+ WebappUploadData webApp;
+ webApp = new WebappUploadData();
+ webApp.setFileName(fileName);
+ webApp.setDataHandler(dh);
+ return webappAdminStub.uploadWebapp(new WebappUploadData[]{webApp});
+
+ }
+
+ /**
+ * Get WebApp summary in Paged manner.
+ *
+ * @param searchString - Search string for get the WebAPP summary.
+ * @param webAppType - Type of the WebApp.
+ * @param webAppState - State of the WebApp.
+ * @param pageNo - Page no of the results.
+ * @throws RemoteException - Exception occurs when retrieving the WebAppSummary from the WebappAdminStub
+ */
+ public WebappsWrapper getPagedWebAppsSummary(String searchString, String webAppType, String webAppState, int pageNo)
+ throws RemoteException {
+ return webappAdminStub.getPagedWebappsSummary(searchString, webAppType, webAppState, pageNo);
+ }
+
+
+ /**
+ * Get WebApp list for the given search String.
+ *
+ * @param webAppNameSearchString - String that contains the data to filter the WebApp.
+ * @return List - List of WebApps that matches to the given search String.
+ * @throws RemoteException - Exception occurs when call the method getPagedWebAppsSummary().
+ */
+ public List getWebAppList(String webAppNameSearchString) throws RemoteException {
+ List list = new ArrayList();
+ WebappsWrapper wrapper = getPagedWebAppsSummary(webAppNameSearchString, "ALL", "ALL", 0);
+ VersionedWebappMetadata[] webAppGroups = wrapper.getWebapps();
+
+ if (webAppGroups != null) {
+ for (VersionedWebappMetadata webAppGroup : webAppGroups) {
+ for (WebappMetadata metaData : webAppGroup.getVersionGroups()) {
+ list.add(metaData.getWebappFile());
+ }
+ }
+ }
+ return list;
+ }
+
+ /**
+ * Get faulty WebApp summary in Paged manner.
+ *
+ * @param searchString - Search string for get the WebAPP summary.
+ * @param webAppType - Type of the WebApp.
+ * @param pageNo - State of the WebApp.
+ * @throws RemoteException - Exception occurs when retrieving the WebAppSummary from the WebappAdminStub
+ */
+ public WebappsWrapper getPagedFaultyWebAppsSummary(String searchString, String webAppType, int pageNo)
+ throws RemoteException {
+ return webappAdminStub.getPagedFaultyWebappsSummary(searchString, webAppType, pageNo);
+ }
+
+ /**
+ * Get faulty WebApp list for the given search String.
+ *
+ * @param webAppNameSearchString - String that contains the data to filter the WebApp.
+ * @return - List of WebApps that matches to the given search String.
+ * @throws RemoteException - Exception occurs when call the method getPagedFaultyWebAppsSummary().
+ */
+ public List getFaultyWebAppList(String webAppNameSearchString) throws RemoteException {
+ List list = new ArrayList();
+ WebappsWrapper wrapper = getPagedFaultyWebAppsSummary(webAppNameSearchString, "ALL", 0);
+ VersionedWebappMetadata[] webAppGroups = wrapper.getWebapps();
+
+ if (webAppGroups != null && webAppGroups[0].getVersionGroups() != null) {
+ for (WebappMetadata metaData : webAppGroups[0].getVersionGroups()) {
+ list.add(metaData.getWebappFile());
+ }
+ }
+ return list;
+ }
+
+}
diff --git a/modules/integration/tests-common/integration-test-utils/src/main/java/org/wso2/am/integration/test/utils/webapp/WebAppDeploymentUtil.java b/modules/integration/tests-common/integration-test-utils/src/main/java/org/wso2/am/integration/test/utils/webapp/WebAppDeploymentUtil.java
new file mode 100644
index 0000000000..c9dc9e5acb
--- /dev/null
+++ b/modules/integration/tests-common/integration-test-utils/src/main/java/org/wso2/am/integration/test/utils/webapp/WebAppDeploymentUtil.java
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.wso2.am.integration.test.utils.webapp;
+
+import org.apache.axis2.AxisFault;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.wso2.am.admin.clients.webapp.WebAppAdminClient;
+import org.wso2.am.integration.test.utils.APIManagerIntegrationTestException;
+
+import java.rmi.RemoteException;
+import java.util.Calendar;
+import java.util.List;
+
+/**
+ * Util that is enabled the more utility methods for handling the WebApps
+ */
+public class WebAppDeploymentUtil {
+ private static Log log = LogFactory.getLog(WebAppDeploymentUtil.class);
+ private static int WEB_APP_DEPLOYMENT_DELAY = 90 * 1000;
+
+ /**
+ * Check whether the given web app is deployed correctly. This method will wait maximum 90 seconds
+ * until it get deployed. check for the web app d
+ *
+ * @param backEndUrl - Backend URL of the server where the web app is host.
+ * @param sessionCookie - valid session cookie of the server where the web app is host.
+ * @param webAppFileName - File name of the web app that want to check for the deployment.
+ * @return boolean - if WebAPp is get deployed withing 90 seconds or else return false.
+ * @throws APIManagerIntegrationTestException - Exception throws when creating WebAppAdminClient object and calling
+ * methods of WebAppAdminClient class.
+ */
+ public static boolean isWebApplicationDeployed(String backEndUrl, String sessionCookie, String webAppFileName)
+ throws APIManagerIntegrationTestException {
+ log.info("waiting " + WEB_APP_DEPLOYMENT_DELAY + " millis for Service deployment " + webAppFileName);
+
+ WebAppAdminClient webAppAdminClient;
+ try {
+ webAppAdminClient = new WebAppAdminClient(backEndUrl, sessionCookie);
+ } catch (AxisFault axisFault) {
+ throw new APIManagerIntegrationTestException("AxisFault Exception occurs when creating the WebAppAdminClient" +
+ " object ", axisFault);
+ }
+
+ List webAppList;
+ List faultyWebAppList;
+ String webAppName = webAppFileName + ".war";
+ boolean isWebAppDeployed = false;
+ Calendar startTime = Calendar.getInstance();
+ long time;
+ while ((time = (Calendar.getInstance().getTimeInMillis() - startTime.getTimeInMillis())) <
+ WEB_APP_DEPLOYMENT_DELAY) {
+ try {
+ webAppList = webAppAdminClient.getWebAppList(webAppFileName);
+ faultyWebAppList = webAppAdminClient.getFaultyWebAppList(webAppFileName);
+ } catch (RemoteException e) {
+ throw new APIManagerIntegrationTestException("RemoteException occurs while retrieving the web app list" +
+ " from WebAppAdminClient.", e);
+ }
+ //check in the faulty WebApp list
+ for (String faultWebAppName : faultyWebAppList) {
+ if (webAppName.equalsIgnoreCase(faultWebAppName)) {
+ isWebAppDeployed = false;
+ log.info(webAppFileName + "- Web Application is faulty");
+ return isWebAppDeployed;
+ }
+ }
+ //check in the successfully deployed WebApp list
+ for (String name : webAppList) {
+ if (webAppName.equalsIgnoreCase(name)) {
+ isWebAppDeployed = true;
+ log.info(webAppFileName + " Web Application deployed in " + time + " millis");
+ return isWebAppDeployed;
+ }
+ }
+
+ try {
+ //Sleeping 500 milliseconds before the next check of the deployment.
+ Thread.sleep(500);
+ } catch (InterruptedException ignored) {
+ log.warn("InterruptedException occurs while waiting sleep for 500 milliseconds");
+ }
+ }
+ return isWebAppDeployed;
+ }
+
+}
diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/APIAccessibilityOfPublishedOldAPIAndPublishedCopyAPITestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/APIAccessibilityOfPublishedOldAPIAndPublishedCopyAPITestCase.java
index 58e2879355..0aa218ad7a 100644
--- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/APIAccessibilityOfPublishedOldAPIAndPublishedCopyAPITestCase.java
+++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/APIAccessibilityOfPublishedOldAPIAndPublishedCopyAPITestCase.java
@@ -51,16 +51,17 @@
*/
public class APIAccessibilityOfPublishedOldAPIAndPublishedCopyAPITestCase extends APIManagerLifecycleBaseTest {
- private static final String API_NAME = "APILifeCycleTestAPI";
- private static final String API_CONTEXT = "testAPI";
- private static final String API_TAGS = "youtube, video, media";
- private static final String API_END_POINT_URL = "http://gdata.youtube.com/feeds/api/standardfeeds";
+ private static final String API_NAME = "APIAccessibilityOfOldAndCopyAPITest";
+ private static final String API_CONTEXT = "APIAccessibilityOfOldAndCopyAPI";
+ private static final String API_TAGS = "testTag1, testTag2, testTag3";
private static final String API_DESCRIPTION = "This is test API create by API manager integration test";
- private static final String API_END_POINT_METHOD = "/most_popular";
- private static final String API_RESPONSE_DATA = " requestHeaders = new HashMap();
+ requestHeaders.put("accept", "text/xml");
requestHeaders.put("Authorization", "Bearer " + accessToken);
//Invoke old version
HttpResponse oldVersionInvokeResponse =
- HttpRequestUtil.doGet(GATEWAY_WEB_APP_URL + API_CONTEXT + "/" + API_VERSION_1_0_0 +
+ HttpRequestUtil.doGet(gatewayWebAppUrl + API_CONTEXT + "/" + API_VERSION_1_0_0 +
API_END_POINT_METHOD, requestHeaders);
assertEquals(oldVersionInvokeResponse.getResponseCode(), HTTP_RESPONSE_CODE_OK, "Response code mismatched");
assertTrue(oldVersionInvokeResponse.getData().contains(API_RESPONSE_DATA), "Response data mismatched");
//Invoke new version
HttpResponse newVersionInvokeResponse =
- HttpRequestUtil.doGet(GATEWAY_WEB_APP_URL + API_CONTEXT + "/" + API_VERSION_2_0_0 +
+ HttpRequestUtil.doGet(gatewayWebAppUrl + API_CONTEXT + "/" + API_VERSION_2_0_0 +
API_END_POINT_METHOD, requestHeaders);
assertEquals(newVersionInvokeResponse.getResponseCode(), HTTP_RESPONSE_CODE_OK, "Response code mismatched");
assertTrue(newVersionInvokeResponse.getData().contains(API_RESPONSE_DATA), "Response data mismatched");
diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/APIManagerConfigurationChangeTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/APIManagerConfigurationChangeTest.java
index 786c10849a..3211f8d9a0 100644
--- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/APIManagerConfigurationChangeTest.java
+++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/APIManagerConfigurationChangeTest.java
@@ -22,8 +22,11 @@
import org.apache.commons.logging.LogFactory;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
+import org.wso2.am.admin.clients.webapp.WebAppAdminClient;
+import org.wso2.am.integration.test.utils.webapp.WebAppDeploymentUtil;
import org.wso2.carbon.automation.engine.annotations.ExecutionEnvironment;
import org.wso2.carbon.automation.engine.annotations.SetEnvironment;
+import org.wso2.carbon.automation.test.utils.common.FileManager;
import org.wso2.carbon.automation.test.utils.common.TestConfigurationProvider;
import org.wso2.carbon.integration.common.utils.mgt.ServerConfigurationManager;
@@ -37,6 +40,10 @@ public class APIManagerConfigurationChangeTest extends APIManagerLifecycleBaseTe
private static final Log log = LogFactory.getLog(APIManagerConfigurationChangeTest.class);
private ServerConfigurationManager serverManager;
private static final String APIM_CONFIG_XML = "api-manager.xml";
+ private static final String WEB_APP_NAME = "jaxrs_basic";
+ private static final String WEB_APP_FILE_NAME = "jaxrs_basic.war";
+ private String targetPathInServer;
+ private String sessionId;
@SetEnvironment(executionEnvironments = {ExecutionEnvironment.STANDALONE})
@BeforeTest(alwaysRun = true)
@@ -55,14 +62,30 @@ public void startChangeAPIMConfigureXml() throws Exception {
serverManager.applyConfigurationWithoutRestart(sourceFile, targetFile, true);
log.info("api-manager.xml configuration file copy from :" + apimConfigArtifactLocation +
" to :" + apimRepositoryConfigLocation);
+
+ String sourcePath =
+ TestConfigurationProvider.getResourceLocation() + File.separator + "artifacts" + File.separator + "AM" +
+ File.separator + "lifecycletest" + File.separator + WEB_APP_FILE_NAME;
+ targetPathInServer =
+ CARBON_HOME + File.separator + "repository" + File.separator + "deployment" + File.separator +
+ "server" + File.separator + "webapps" + File.separator + WEB_APP_FILE_NAME;
+
+ sessionId = createSession(gatewayContext);
+ WebAppAdminClient webAppAdminClient =
+ new WebAppAdminClient(gatewayContext.getContextUrls().getBackEndUrl(), sessionId);
+ webAppAdminClient.uploadWarFile(sourcePath);
+ WebAppDeploymentUtil.isWebApplicationDeployed(gatewayContext.getContextUrls().getBackEndUrl(),
+ sessionId, WEB_APP_NAME);
serverManager.restartGracefully();
+
}
@AfterTest(alwaysRun = true)
public void startRestoreAPIMConfigureXml() throws Exception {
serverManager.restoreToLastConfiguration();
log.info("Restore the api-manager.xml configuration file");
+ FileManager.deleteFile(targetPathInServer);
serverManager.restartGracefully();
}
}
diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/APIManagerLifecycleBaseTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/APIManagerLifecycleBaseTest.java
index a36b2eba01..3a898ff95c 100644
--- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/APIManagerLifecycleBaseTest.java
+++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/APIManagerLifecycleBaseTest.java
@@ -54,8 +54,8 @@ public class APIManagerLifecycleBaseTest extends APIMIntegrationBaseTest {
protected static final int HTTP_RESPONSE_CODE_FORBIDDEN = Response.Status.FORBIDDEN.getStatusCode();
protected static final String HTTP_RESPONSE_DATA_API_BLOCK =
"700700API blocked";
- protected static final String HTTP_RESPONSE_DATA_INVALID_CREDENTIALS =
- "Invalid Credentials";
+ protected static final String UNCLASSIFIED_AUTHENTICATION_FAILURE =
+ "Unclassified Authentication Failure";
protected static final String HTTP_RESPONSE_DATA_NOT_FOUND =
"404Status reportNot Found";
protected static final int GOLD_INVOCATION_LIMIT_PER_MIN = 20;
@@ -68,12 +68,12 @@ public class APIManagerLifecycleBaseTest extends APIMIntegrationBaseTest {
"You have exceeded your quota";
protected static final int THROTTLING_UNIT_TIME = 60000;
protected static final int THROTTLING_ADDITIONAL_WAIT_TIME = 5000;
- protected static String GATEWAY_WEB_APP_URL;
+ protected static String gatewayWebAppUrl;
@BeforeClass(alwaysRun = true)
public void init() throws APIManagerIntegrationTestException {
super.init();
- GATEWAY_WEB_APP_URL = gatewayUrls.getWebAppURLNhttp();
+ gatewayWebAppUrl = gatewayUrls.getWebAppURLNhttp();
}
/**
diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/APIPublishingAndVisibilityInStoreTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/APIPublishingAndVisibilityInStoreTestCase.java
index 782c6bb7ca..b80687b0ae 100644
--- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/APIPublishingAndVisibilityInStoreTestCase.java
+++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/APIPublishingAndVisibilityInStoreTestCase.java
@@ -43,13 +43,14 @@
*/
public class APIPublishingAndVisibilityInStoreTestCase extends APIManagerLifecycleBaseTest {
- private static final String API_NAME = "APILifeCycleTestAPI";
- private static final String API_CONTEXT = "testAPI";
- private static final String API_TAGS = "youtube, video, media";
- private static final String API_END_POINT_URL = "http://gdata.youtube.com/feeds/api/standardfeeds";
+ private static final String API_NAME = "APIPublishingAndVisibilityInStoreTest";
+ private static final String API_CONTEXT = "APIPublishingAndVisibilityInStore";
+ private static final String API_TAGS = "testTag1, testTag2, testTag3";
private static final String API_DESCRIPTION = "This is test API create by API manager integration test";
private static final String API_VERSION_1_0_0 = "1.0.0";
private static final String APPLICATION_NAME = "APIPublishingAndVisibilityInStoreTestCase";
+ private static final String API_END_POINT_POSTFIX_URL = "jaxrs_basic/services/customers/customerservice/";
+ private String apiEndPointUrl;
private APIIdentifier apiIdentifier;
private String providerName;
private APICreationRequestBean apiCreationRequestBean;
@@ -59,10 +60,11 @@ public class APIPublishingAndVisibilityInStoreTestCase extends APIManagerLifecyc
@BeforeClass(alwaysRun = true)
public void initialize() throws APIManagerIntegrationTestException, XPathExpressionException, MalformedURLException {
super.init();
+ apiEndPointUrl = gatewayUrls.getWebAppURLHttp() + API_END_POINT_POSTFIX_URL;
providerName = publisherContext.getContextTenant().getContextUser().getUserName();
apiCreationRequestBean =
new APICreationRequestBean(API_NAME, API_CONTEXT, API_VERSION_1_0_0, providerName,
- new URL(API_END_POINT_URL));
+ new URL(apiEndPointUrl));
apiCreationRequestBean.setTags(API_TAGS);
apiCreationRequestBean.setDescription(API_DESCRIPTION);
String publisherURLHttp = publisherUrls.getWebAppURLHttp();
diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/APIVisibilityByDomainTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/APIVisibilityByDomainTestCase.java
index bd19ff23f0..dc4d603c32 100644
--- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/APIVisibilityByDomainTestCase.java
+++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/APIVisibilityByDomainTestCase.java
@@ -41,10 +41,9 @@
*/
public class APIVisibilityByDomainTestCase extends APIManagerLifecycleBaseTest {
- private static final String API_NAME = "APILifeCycleTestAPI";
- private static final String API_CONTEXT = "testAPI";
- private static final String API_TAGS = "youtube, video, media";
- private static final String API_END_POINT_URL = "http://gdata.youtube.com/feeds/api/standardfeeds";
+ private static final String API_NAME = "APIVisibilityByDomainTest";
+ private static final String API_CONTEXT = "APIVisibilityByDomain";
+ private static final String API_TAGS = "testTag1, testTag2, testTag3";
private static final String API_DESCRIPTION = "This is test API create by API manager integration test";
private static final String API_VERSION_1_0_0 = "1.0.0";
private static final String CARBON_SUPER_TENANT2_KEY = "userKey2";
@@ -52,6 +51,8 @@ public class APIVisibilityByDomainTestCase extends APIManagerLifecycleBaseTest {
private static final String TENANT_DOMAIN_ADMIN_KEY = "admin";
private static final String USER_KEY_USER2 = "userKey1";
private static final String OTHER_DOMAIN_TENANT_USER_KEY = "user1";
+ private static final String API_END_POINT_POSTFIX_URL = "jaxrs_basic/services/customers/customerservice/";
+ private String apiEndPointUrl;
private APIIdentifier apiIdentifier;
private APIStoreRestClient apiStoreClientCarbonSuperUser2;
private APIPublisherRestClient apiPublisherClientCarbonSuperUser2;
@@ -72,9 +73,9 @@ public class APIVisibilityByDomainTestCase extends APIManagerLifecycleBaseTest {
public void initialize() throws APIManagerIntegrationTestException, XPathExpressionException {
//Creating CarbonSuper context
super.init();
+ apiEndPointUrl = gatewayUrls.getWebAppURLHttp() + API_END_POINT_POSTFIX_URL;
String publisherURLHttp = publisherUrls.getWebAppURLHttp();
storeURLHttp = storeUrls.getWebAppURLHttp();
-
//Login to API Publisher and Store with CarbonSuper admin
apiPublisherClientCarbonSuperAdmin = new APIPublisherRestClient(publisherURLHttp);
apiStoreClientCarbonSuperAdmin = new APIStoreRestClient(storeURLHttp);
@@ -140,7 +141,7 @@ public void testVisibilityForCreatorInPublisher() throws APIManagerIntegrationTe
apiIdentifier = new APIIdentifier(providerName, API_NAME, API_VERSION_1_0_0);
APICreationRequestBean apiCreationRequestBean =
new APICreationRequestBean(API_NAME, API_CONTEXT, API_VERSION_1_0_0, providerName,
- new URL(API_END_POINT_URL));
+ new URL(apiEndPointUrl));
apiCreationRequestBean.setTags(API_TAGS);
apiCreationRequestBean.setDescription(API_DESCRIPTION);
apiPublisherClientCarbonSuperUser1.addAPI(apiCreationRequestBean);
diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/APIVisibilityByPublicTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/APIVisibilityByPublicTestCase.java
index 6e4caa4ccb..b0ad1001b1 100644
--- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/APIVisibilityByPublicTestCase.java
+++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/APIVisibilityByPublicTestCase.java
@@ -43,10 +43,9 @@
*/
public class APIVisibilityByPublicTestCase extends APIManagerLifecycleBaseTest {
private static final Log log = LogFactory.getLog(APIVisibilityByPublicTestCase.class);
- private static final String API_NAME = "APILifeCycleTestAPI";
- private static final String API_CONTEXT = "testAPI";
- private static final String API_TAGS = "youtube, video, media";
- private static final String API_END_POINT_URL = "http://gdata.youtube.com/feeds/api/standardfeeds";
+ private static final String API_NAME = "APIVisibilityByPublicTest";
+ private static final String API_CONTEXT = "APIVisibilityByPublic";
+ private static final String API_TAGS = "testTag1, testTag2, testTag3";
private static final String API_DESCRIPTION = "This is test API create by API manager integration test";
private static final String API_VERSION_1_0_0 = "1.0.0";
private static final String CARBON_SUPER_TENANT2_KEY = "userKey2";
@@ -54,6 +53,8 @@ public class APIVisibilityByPublicTestCase extends APIManagerLifecycleBaseTest {
private static final String TENANT_DOMAIN_ADMIN_KEY = "admin";
private static final String USER_KEY_USER2 = "userKey1";
private static final String OTHER_DOMAIN_TENANT_USER_KEY = "user1";
+ private static final String API_END_POINT_POSTFIX_URL = "jaxrs_basic/services/customers/customerservice/";
+ private String apiEndPointUrl;
private APIIdentifier apiIdentifier;
private APIStoreRestClient apiStoreClientAnotherUserSameDomain;
private APIPublisherRestClient apiPublisherClientUserAnotherUserSameDomain;
@@ -74,6 +75,7 @@ public class APIVisibilityByPublicTestCase extends APIManagerLifecycleBaseTest {
public void initialize() throws APIManagerIntegrationTestException, XPathExpressionException {
//Creating CarbonSuper context
super.init();
+ apiEndPointUrl = gatewayUrls.getWebAppURLHttp() + API_END_POINT_POSTFIX_URL;
String publisherURLHttp = publisherUrls.getWebAppURLHttp();
storeURLHttp = storeUrls.getWebAppURLHttp();
@@ -145,7 +147,7 @@ public void testVisibilityForCreatorInPublisher() throws Exception {
apiIdentifier = new APIIdentifier(providerName, API_NAME, API_VERSION_1_0_0);
APICreationRequestBean apiCreationRequestBean =
new APICreationRequestBean(API_NAME, API_CONTEXT, API_VERSION_1_0_0, providerName,
- new URL(API_END_POINT_URL));
+ new URL(apiEndPointUrl));
apiCreationRequestBean.setTags(API_TAGS);
apiCreationRequestBean.setDescription(API_DESCRIPTION);
//Create API with public visibility and publish.
diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/APIVisibilityByRoleTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/APIVisibilityByRoleTestCase.java
index 0bde27ed19..261002a815 100644
--- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/APIVisibilityByRoleTestCase.java
+++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/APIVisibilityByRoleTestCase.java
@@ -45,12 +45,11 @@
*/
public class APIVisibilityByRoleTestCase extends APIManagerLifecycleBaseTest {
- private static final String API_NAME_ADMIN_VISIBILITY = "APIAdminVisibility";
- private static final String API_NAME_SUBSCRIBER_VISIBILITY = "APISubscriberVisibility";
+ private static final String API_NAME_ADMIN_VISIBILITY = "APIVisibilityByRoleTest";
+ private static final String API_NAME_SUBSCRIBER_VISIBILITY = "APIVisibilityByRole";
private static final String API_CONTEXT1 = "testAPI1";
private static final String API_CONTEXT2 = "testAPI2";
- private static final String API_TAGS = "youtube, video, media";
- private static final String API_END_POINT_URL = "http://gdata.youtube.com/feeds/api/standardfeeds";
+ private static final String API_TAGS = "testTag1, testTag2, testTag3";
private static final String API_DESCRIPTION = "This is test API create by API manager integration test";
private static final String API_VERSION_1_0_0 = "1.0.0";
private static final String CARBON_SUPER_TENANT2_KEY = "userKey2";
@@ -63,6 +62,8 @@ public class APIVisibilityByRoleTestCase extends APIManagerLifecycleBaseTest {
private static final String TENANT_SUBSCRIBER_USERNAME = "subscriberUser2";
private static final char[] TENANT_SUBSCRIBER_PASSWORD = "password@123".toCharArray();
private static final String INTERNAL_ROLE_SUBSCRIBER = "Internal/subscriber";
+ private static final String API_END_POINT_POSTFIX_URL = "jaxrs_basic/services/customers/customerservice/";
+ private String apiEndPointUrl;
private String providerName;
private APIPublisherRestClient apiPublisherClientCarbonSuperUser1;
private APIStoreRestClient apiStoreClientCarbonSuperUser1;
@@ -89,6 +90,7 @@ public void initialize() throws APIManagerIntegrationTestException, XPathExpress
UserAdminUserAdminException {
//Creating CarbonSuper context
super.init();
+ apiEndPointUrl = gatewayUrls.getWebAppURLHttp() + API_END_POINT_POSTFIX_URL;
String publisherURLHttp = publisherUrls.getWebAppURLHttp();
storeURLHttp = storeUrls.getWebAppURLHttp();
//Login to API Publisher and Store with CarbonSuper admin
@@ -190,7 +192,7 @@ public void testVisibilityForCreatorInPublisher() throws APIManagerIntegrationTe
//Create API with public visibility and publish.
APICreationRequestBean apiCreationReqBeanVisibilityAdmin =
new APICreationRequestBean(API_NAME_ADMIN_VISIBILITY, API_CONTEXT1, API_VERSION_1_0_0,
- providerName, new URL(API_END_POINT_URL));
+ providerName, new URL(apiEndPointUrl));
apiCreationReqBeanVisibilityAdmin.setTags(API_TAGS);
apiCreationReqBeanVisibilityAdmin.setDescription(API_DESCRIPTION);
apiCreationReqBeanVisibilityAdmin.setVisibility("restricted");
@@ -199,7 +201,7 @@ public void testVisibilityForCreatorInPublisher() throws APIManagerIntegrationTe
publishAPI(apiIdentifierAdminVisibility, apiPublisherClientCarbonSuperUser1, false);
APICreationRequestBean apiCreationReqBeanVisibilityInternalSubscriber =
new APICreationRequestBean(API_NAME_SUBSCRIBER_VISIBILITY, API_CONTEXT2, API_VERSION_1_0_0,
- providerName, new URL(API_END_POINT_URL));
+ providerName, new URL(apiEndPointUrl));
apiCreationReqBeanVisibilityInternalSubscriber.setTags(API_TAGS);
apiCreationReqBeanVisibilityInternalSubscriber.setDescription(API_DESCRIPTION);
apiCreationReqBeanVisibilityInternalSubscriber.setVisibility("restricted");
diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/AccessibilityOfBlockAPITestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/AccessibilityOfBlockAPITestCase.java
index 3aba8195e2..035f209159 100644
--- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/AccessibilityOfBlockAPITestCase.java
+++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/AccessibilityOfBlockAPITestCase.java
@@ -47,15 +47,16 @@
public class AccessibilityOfBlockAPITestCase extends APIManagerLifecycleBaseTest {
- private static final String API_NAME = "APILifeCycleTestAPI";
- private static final String API_CONTEXT = "testAPI";
- private static final String API_TAGS = "youtube, video, media";
- private static final String API_END_POINT_URL = "http://gdata.youtube.com/feeds/api/standardfeeds";
+ private static final String API_NAME = "BlockAPITest";
+ private static final String API_CONTEXT = "BlockAPI";
+ private static final String API_TAGS = "testTag1, testTag2, testTag3";
private static final String API_DESCRIPTION = "This is test API create by API manager integration test";
- private static final String API_END_POINT_METHOD = "/most_popular";
- private static final String API_RESPONSE_DATA = "();
+ requestHeaders.put("accept", "text/xml");
requestHeaders.put("Authorization", "Bearer " + accessToken);
//Invoke old version
HttpResponse oldVersionInvokeResponse =
- HttpRequestUtil.doGet(GATEWAY_WEB_APP_URL + API_CONTEXT + "/" +
+ HttpRequestUtil.doGet(gatewayWebAppUrl + API_CONTEXT + "/" +
API_VERSION_1_0_0 + API_END_POINT_METHOD, requestHeaders);
assertEquals(oldVersionInvokeResponse.getResponseCode(), HTTP_RESPONSE_CODE_OK,
"Response code mismatched when invoke api before block");
@@ -132,7 +135,7 @@ public void testChangeAPILifecycleToBlock() throws APIManagerIntegrationTestExce
public void testInvokeAPIAfterChangeAPILifecycleToBlock() throws APIManagerIntegrationTestException, IOException {
//Invoke old version
HttpResponse oldVersionInvokeResponse =
- HttpRequestUtil.doGet(GATEWAY_WEB_APP_URL + API_CONTEXT + "/" + API_VERSION_1_0_0 + API_END_POINT_METHOD,
+ HttpRequestUtil.doGet(gatewayWebAppUrl + API_CONTEXT + "/" + API_VERSION_1_0_0 + API_END_POINT_METHOD,
requestHeaders);
assertEquals(oldVersionInvokeResponse.getResponseCode(), HTTP_RESPONSE_CODE_SERVICE_UNAVAILABLE,
"Response code mismatched when invoke api after block");
diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/AccessibilityOfDeprecatedOldAPIAndPublishedCopyAPITestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/AccessibilityOfDeprecatedOldAPIAndPublishedCopyAPITestCase.java
index 0e6fe486c0..c2a8666006 100644
--- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/AccessibilityOfDeprecatedOldAPIAndPublishedCopyAPITestCase.java
+++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/AccessibilityOfDeprecatedOldAPIAndPublishedCopyAPITestCase.java
@@ -49,16 +49,17 @@
* test invocation of both old and new API versions."
*/
public class AccessibilityOfDeprecatedOldAPIAndPublishedCopyAPITestCase extends APIManagerLifecycleBaseTest {
- private static final String API_NAME = "APILifeCycleTestAPI";
- private static final String API_CONTEXT = "testAPI";
- private static final String API_TAGS = "youtube, video, media";
- private static final String API_END_POINT_URL = "http://gdata.youtube.com/feeds/api/standardfeeds";
+ private static final String API_NAME = "DeprecatedAPITest";
+ private static final String API_CONTEXT = "DeprecatedAPI";
+ private static final String API_TAGS = "testTag1, testTag2, testTag3";
+ private static final String API_END_POINT_POSTFIX_URL = "jaxrs_basic/services/customers/customerservice/";
private static final String API_DESCRIPTION = "This is test API create by API manager integration test";
- private static final String API_END_POINT_METHOD = "/most_popular";
- private static final String API_RESPONSE_DATA = " requestHeaders = new HashMap();
+ requestHeaders.put("accept", "text/xml");
requestHeaders.put("Authorization", "Bearer " + accessToken);
//Invoke old version
HttpResponse oldVersionInvokeResponse =
- HttpRequestUtil.doGet(GATEWAY_WEB_APP_URL + API_CONTEXT + "/" + API_VERSION_1_0_0 +
+ HttpRequestUtil.doGet(gatewayWebAppUrl + API_CONTEXT + "/" + API_VERSION_1_0_0 +
API_END_POINT_METHOD, requestHeaders);
assertEquals(oldVersionInvokeResponse.getResponseCode(),
HTTP_RESPONSE_CODE_OK, "Response code mismatched");
assertTrue(oldVersionInvokeResponse.getData().contains(API_RESPONSE_DATA), "Response data mismatched");
//Invoke new version
- HttpResponse newVersionInvokeResponse = HttpRequestUtil.doGet(GATEWAY_WEB_APP_URL + API_CONTEXT +
+ HttpResponse newVersionInvokeResponse = HttpRequestUtil.doGet(gatewayWebAppUrl + API_CONTEXT +
"/" + API_VERSION_2_0_0 + API_END_POINT_METHOD, requestHeaders);
assertEquals(newVersionInvokeResponse.getResponseCode(), HTTP_RESPONSE_CODE_OK,
"Response code mismatched");
diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/AccessibilityOfOldAPIAndCopyAPIWithOutReSubscriptionTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/AccessibilityOfOldAPIAndCopyAPIWithOutReSubscriptionTestCase.java
index 84da9b10ef..55ab894e41 100644
--- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/AccessibilityOfOldAPIAndCopyAPIWithOutReSubscriptionTestCase.java
+++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/AccessibilityOfOldAPIAndCopyAPIWithOutReSubscriptionTestCase.java
@@ -47,16 +47,17 @@
*/
public class AccessibilityOfOldAPIAndCopyAPIWithOutReSubscriptionTestCase extends APIManagerLifecycleBaseTest {
- private static final String API_NAME = "APILifeCycleTestAPI";
- private static final String API_CONTEXT = "testAPI";
- private static final String API_TAGS = "youtube, video, media";
- private static final String API_END_POINT_URL = "http://gdata.youtube.com/feeds/api/standardfeeds";
+ private static final String API_NAME = "CopyAPIWithOutReSubscriptionTest";
+ private static final String API_CONTEXT = "CopyAPIWithOutReSubscription";
+ private static final String API_TAGS = "testTag1, testTag2, testTag3";
private static final String API_DESCRIPTION = "This is test API create by API manager integration test";
- private static final String API_END_POINT_METHOD = "/most_popular";
- private static final String API_RESPONSE_DATA = "();
+ requestHeaders.put("accept", "text/xml");
requestHeaders.put("Authorization", "Bearer " + accessToken);
//Invoke old version
HttpResponse oldVersionInvokeResponse =
- HttpRequestUtil.doGet(GATEWAY_WEB_APP_URL + API_CONTEXT + "/" + API_VERSION_1_0_0 +
+ HttpRequestUtil.doGet(gatewayWebAppUrl + API_CONTEXT + "/" + API_VERSION_1_0_0 +
API_END_POINT_METHOD, requestHeaders);
assertEquals(oldVersionInvokeResponse.getResponseCode(), HTTP_RESPONSE_CODE_OK,
"Response code mismatched when invoke old api before subscribe the new version");
@@ -154,7 +157,7 @@ public void testInvokeOldAPIBeforeSubscribeTheNewVersion() throws APIManagerInte
public void testInvokeNewAPIWithoutSubscribeTheNewVersion() throws APIManagerIntegrationTestException, IOException {
//Invoke old version
HttpResponse oldVersionInvokeResponse =
- HttpRequestUtil.doGet(GATEWAY_WEB_APP_URL + API_CONTEXT + "/" + API_VERSION_2_0_0 +
+ HttpRequestUtil.doGet(gatewayWebAppUrl + API_CONTEXT + "/" + API_VERSION_2_0_0 +
API_END_POINT_METHOD, requestHeaders);
assertEquals(oldVersionInvokeResponse.getResponseCode(), HTTP_RESPONSE_CODE_OK,
"Response code mismatched when invoke new api before subscribe the new version when re-subscription" +
diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/AccessibilityOfOldAPIAndCopyAPIWithReSubscriptionTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/AccessibilityOfOldAPIAndCopyAPIWithReSubscriptionTestCase.java
index 369ffae2d9..23b976b389 100644
--- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/AccessibilityOfOldAPIAndCopyAPIWithReSubscriptionTestCase.java
+++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/AccessibilityOfOldAPIAndCopyAPIWithReSubscriptionTestCase.java
@@ -47,16 +47,17 @@
* test invocation of New API before and after the re-subscription."
*/
public class AccessibilityOfOldAPIAndCopyAPIWithReSubscriptionTestCase extends APIManagerLifecycleBaseTest {
- private static final String API_NAME = "APILifeCycleTestAPI";
- private static final String API_CONTEXT = "testAPI";
- private static final String API_TAGS = "youtube, video, media";
- private static final String API_END_POINT_URL = "http://gdata.youtube.com/feeds/api/standardfeeds";
+ private static final String API_NAME = "CopyAPIWithReSubscriptionTest";
+ private static final String API_CONTEXT = "CopyAPIWithReSubscription";
+ private static final String API_TAGS = "testTag1, testTag2, testTag3";
private static final String API_DESCRIPTION = "This is test API create by API manager integration test";
- private static final String API_END_POINT_METHOD = "/most_popular";
- private static final String API_RESPONSE_DATA = "();
+ requestHeaders.put("accept", "text/xml");
requestHeaders.put("Authorization", "Bearer " + accessToken);
//Invoke old version
HttpResponse oldVersionInvokeResponse =
- HttpRequestUtil.doGet(GATEWAY_WEB_APP_URL + API_CONTEXT + "/" + API_VERSION_1_0_0 +
+ HttpRequestUtil.doGet(gatewayWebAppUrl + API_CONTEXT + "/" + API_VERSION_1_0_0 +
API_END_POINT_METHOD, requestHeaders);
assertEquals(oldVersionInvokeResponse.getResponseCode(), HTTP_RESPONSE_CODE_OK,
"Response code mismatched when invoke old api before subscribe the new version");
@@ -153,11 +156,11 @@ public void testInvokeOldAPIBeforeSubscribeTheNewVersion() throws APIManagerInte
public void testInvokeNewAPIBeforeSubscribeTheNewVersion() throws APIManagerIntegrationTestException, IOException {
//Invoke old version
HttpResponse oldVersionInvokeResponse =
- HttpRequestUtil.doGet(GATEWAY_WEB_APP_URL + API_CONTEXT + "/" + API_VERSION_2_0_0 +
+ HttpRequestUtil.doGet(gatewayWebAppUrl + API_CONTEXT + "/" + API_VERSION_2_0_0 +
API_END_POINT_METHOD, requestHeaders);
assertEquals(oldVersionInvokeResponse.getResponseCode(), HTTP_RESPONSE_CODE_UNAUTHORIZED,
"Response code mismatched when invoke new api before subscribe the new version");
- assertTrue(oldVersionInvokeResponse.getData().contains(HTTP_RESPONSE_DATA_INVALID_CREDENTIALS),
+ assertTrue(oldVersionInvokeResponse.getData().contains(UNCLASSIFIED_AUTHENTICATION_FAILURE),
"Response data mismatched when invoke new API version before subscribe the new version." +
" Response Data:" + oldVersionInvokeResponse.getData());
}
@@ -181,7 +184,7 @@ public void testSubscribeTheNewVersion() throws APIManagerIntegrationTestExcepti
dependsOnMethods = "testSubscribeTheNewVersion")
public void testInvokeNewAPIAfterSubscribeTheNewVersion() throws APIManagerIntegrationTestException, IOException {
//Invoke new version after subscription
- HttpResponse oldVersionInvokeResponse = HttpRequestUtil.doGet(GATEWAY_WEB_APP_URL + API_CONTEXT +
+ HttpResponse oldVersionInvokeResponse = HttpRequestUtil.doGet(gatewayWebAppUrl + API_CONTEXT +
"/" + API_VERSION_2_0_0 + API_END_POINT_METHOD, requestHeaders);
assertEquals(oldVersionInvokeResponse.getResponseCode(), HTTP_RESPONSE_CODE_OK, "Response code mismatched when" +
" invoke new api after subscribe the new version");
diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/AccessibilityOfRetireAPITestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/AccessibilityOfRetireAPITestCase.java
index 643fc432dd..ef9730dc16 100644
--- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/AccessibilityOfRetireAPITestCase.java
+++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/AccessibilityOfRetireAPITestCase.java
@@ -46,15 +46,16 @@
* "Retire an API and check its accessibility and visibility in the API Store."
*/
public class AccessibilityOfRetireAPITestCase extends APIManagerLifecycleBaseTest {
- private static final String API_NAME = "APILifeCycleTestAPI";
- private static final String API_CONTEXT = "testAPI";
- private static final String API_TAGS = "youtube, video, media";
- private static final String API_END_POINT_URL = "http://gdata.youtube.com/feeds/api/standardfeeds";
+ private static final String API_NAME = "RetireAPITest";
+ private static final String API_CONTEXT = "RetireAPI";
+ private static final String API_TAGS = "testTag1, testTag2, testTag3";
private static final String API_DESCRIPTION = "This is test API create by API manager integration test";
- private static final String API_END_POINT_METHOD = "/most_popular";
- private static final String API_RESPONSE_DATA = "();
+ requestHeaders.put("accept", "text/xml");
requestHeaders.put("Authorization", "Bearer " + accessToken);
//Invoke old version
HttpResponse oldVersionInvokeResponse =
- HttpRequestUtil.doGet(GATEWAY_WEB_APP_URL + API_CONTEXT + "/" + API_VERSION_1_0_0 +
+ HttpRequestUtil.doGet(gatewayWebAppUrl + API_CONTEXT + "/" + API_VERSION_1_0_0 +
API_END_POINT_METHOD, requestHeaders);
assertEquals(oldVersionInvokeResponse.getResponseCode(), HTTP_RESPONSE_CODE_OK,
"Response code mismatched when invoke api before Retire");
@@ -143,7 +146,7 @@ public void testInvokeAPIAfterChangeAPILifecycleToRetired() throws APIManagerInt
//Invoke old version
HttpResponse oldVersionInvokeResponse =
- HttpRequestUtil.doGet(GATEWAY_WEB_APP_URL + API_CONTEXT + "/" + API_VERSION_1_0_0 +
+ HttpRequestUtil.doGet(gatewayWebAppUrl + API_CONTEXT + "/" + API_VERSION_1_0_0 +
API_END_POINT_METHOD, requestHeaders);
assertEquals(oldVersionInvokeResponse.getResponseCode(), HTTP_RESPONSE_CODE_NOT_FOUND,
"Response code mismatched when invoke api after retire");
diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/AddEditRemoveRESTResourceTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/AddEditRemoveRESTResourceTestCase.java
index 6dc752169d..c268459ce7 100644
--- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/AddEditRemoveRESTResourceTestCase.java
+++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/AddEditRemoveRESTResourceTestCase.java
@@ -27,15 +27,14 @@
import org.wso2.am.integration.test.utils.clients.APIPublisherRestClient;
import org.wso2.am.integration.test.utils.clients.APIStoreRestClient;
import org.wso2.carbon.apimgt.api.model.APIIdentifier;
-import org.wso2.carbon.automation.test.utils.common.FileManager;
-import org.wso2.carbon.automation.test.utils.common.TestConfigurationProvider;
import org.wso2.carbon.automation.test.utils.http.client.HttpRequestUtil;
import org.wso2.carbon.automation.test.utils.http.client.HttpResponse;
-import org.wso2.carbon.integration.common.utils.mgt.ServerConfigurationManager;
-import java.io.File;
+import javax.xml.xpath.XPathExpressionException;
import java.io.IOException;
+import java.net.MalformedURLException;
import java.net.URL;
+import java.rmi.RemoteException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -47,9 +46,9 @@
* Add , edit and remove rest resource and test the invocation of API
*/
public class AddEditRemoveRESTResourceTestCase extends APIManagerLifecycleBaseTest {
- private static final String API_NAME = "APILifeCycleTestAPI";
- private static final String API_CONTEXT = "testAPI";
- private static final String API_TAGS = "youtube, video, media";
+ private static final String API_NAME = "EditRemoveRESTResourceTest";
+ private static final String API_CONTEXT = "EditRemoveRESTResource";
+ private static final String API_TAGS = "testTag1, testTag2, testTag3";
private static final String API_END_POINT_POSTFIX_URL = "jaxrs_basic/services/customers/customerservice/";
private static final String API_DESCRIPTION = "This is test API create by API manager integration test";
private static final String API_VERSION_1_0_0 = "1.0.0";
@@ -71,19 +70,11 @@ public class AddEditRemoveRESTResourceTestCase extends APIManagerLifecycleBaseTe
private HashMap requestHeadersPost;
@BeforeClass(alwaysRun = true)
- public void initialize() throws Exception {
+ public void initialize() throws APIManagerIntegrationTestException, XPathExpressionException,
+ RemoteException, MalformedURLException {
super.init();
- postEndPointURL = GATEWAY_WEB_APP_URL + API_CONTEXT + "/" + API_VERSION_1_0_0 + API_POST_ENDPOINT_METHOD;
+ postEndPointURL = gatewayWebAppUrl + API_CONTEXT + "/" + API_VERSION_1_0_0 + API_POST_ENDPOINT_METHOD;
apiEndPointUrl = gatewayUrls.getWebAppURLHttp() + API_END_POINT_POSTFIX_URL;
- String sourcePath =
- TestConfigurationProvider.getResourceLocation() + File.separator + "artifacts" + File.separator + "AM" +
- File.separator + "lifecycletest" + File.separator + "jaxrs_basic.war";
- String targetPath = CARBON_HOME + File.separator + "repository" + File.separator + "deployment" +
- File.separator + "server" + File.separator + "webapps";
- ServerConfigurationManager serverConfigurationManager = new ServerConfigurationManager(gatewayContext);
- FileManager.copyResourceToFileSystem(sourcePath, targetPath, "jaxrs_basic.war");
- serverConfigurationManager.restartGracefully();
- super.init();
APICreationRequestBean apiCreationRequestBean =
new APICreationRequestBean(API_NAME, API_CONTEXT, API_VERSION_1_0_0, providerName, new URL(apiEndPointUrl));
apiCreationRequestBean.setTags(API_TAGS);
@@ -126,7 +117,7 @@ public void testInvokeGETResource() throws APIManagerIntegrationTestException, I
requestHeadersPost.put("Authorization", "Bearer " + accessToken);
//Send GET Request
HttpResponse httpResponse =
- HttpRequestUtil.doGet(GATEWAY_WEB_APP_URL + API_CONTEXT + "/" + API_VERSION_1_0_0 + API_GET_ENDPOINT_METHOD,
+ HttpRequestUtil.doGet(gatewayWebAppUrl + API_CONTEXT + "/" + API_VERSION_1_0_0 + API_GET_ENDPOINT_METHOD,
requestHeadersGet);
assertEquals(httpResponse.getResponseCode(), HTTP_RESPONSE_CODE_OK, "Invocation fails for GET request");
assertTrue(httpResponse.getData().contains(RESPONSE_GET), "Response Data not match for GET request." +
@@ -177,7 +168,7 @@ public void testInvokePOSTAndGETResourceAfterAddingPOSTResource() throws Excepti
"Update APi with new Resource information fail");
//Send GET Request
HttpResponse httpResponseGet =
- HttpRequestUtil.doGet(GATEWAY_WEB_APP_URL + API_CONTEXT + "/" + API_VERSION_1_0_0 + API_GET_ENDPOINT_METHOD,
+ HttpRequestUtil.doGet(gatewayWebAppUrl + API_CONTEXT + "/" + API_VERSION_1_0_0 + API_GET_ENDPOINT_METHOD,
requestHeadersGet);
assertEquals(httpResponseGet.getResponseCode(), HTTP_RESPONSE_CODE_OK, "Invocation fails for GET request after " +
"update the api with both GET and POST resource");
@@ -185,7 +176,7 @@ public void testInvokePOSTAndGETResourceAfterAddingPOSTResource() throws Excepti
" update the api with both GET and POST resource. Expected value :\"" + RESPONSE_GET + "\" not contains" +
" in response data:\"" + httpResponseGet.getData() + "\"");
//Send POST Request
- HttpResponse httpResponsePOST = HttpRequestUtil.doPost(new URL(GATEWAY_WEB_APP_URL + API_CONTEXT + "/" +
+ HttpResponse httpResponsePOST = HttpRequestUtil.doPost(new URL(gatewayWebAppUrl + API_CONTEXT + "/" +
API_VERSION_1_0_0 + API_POST_ENDPOINT_METHOD), "id=25", requestHeadersPost);
assertEquals(httpResponsePOST.getResponseCode(), HTTP_RESPONSE_CODE_OK,
@@ -221,7 +212,7 @@ public void testInvokePOSTAndGetResourceAfterAddingURLPattern() throws Exception
"Update APi with new Resource information fail");
//Send GET Request
HttpResponse httpResponseGet =
- HttpRequestUtil.doGet(GATEWAY_WEB_APP_URL + API_CONTEXT + "/" + API_VERSION_1_0_0 +
+ HttpRequestUtil.doGet(gatewayWebAppUrl + API_CONTEXT + "/" + API_VERSION_1_0_0 +
API_GET_ENDPOINT_METHOD, requestHeadersGet);
assertEquals(httpResponseGet.getResponseCode(), HTTP_RESPONSE_CODE_OK, "Invocation fails for GET request after " +
"update the api with URLPattern");
@@ -230,7 +221,7 @@ public void testInvokePOSTAndGetResourceAfterAddingURLPattern() throws Exception
" in response data:\"" + httpResponseGet.getData() + "\"");
//Send GET Request with invalid url
HttpResponse httpResponseGetInvalidUrl =
- HttpRequestUtil.doGet(GATEWAY_WEB_APP_URL + API_CONTEXT + "/" + API_VERSION_1_0_0 + API_GET_ENDPOINT_METHOD +
+ HttpRequestUtil.doGet(gatewayWebAppUrl + API_CONTEXT + "/" + API_VERSION_1_0_0 + API_GET_ENDPOINT_METHOD +
INVALID_URL, requestHeadersGet);
assertEquals(httpResponseGetInvalidUrl.getResponseCode(), HTTP_RESPONSE_CODE_FORBIDDEN, "Invocation is not " +
"forbidden when try to invoke GET resource via invalid url pattern");
@@ -239,7 +230,7 @@ public void testInvokePOSTAndGetResourceAfterAddingURLPattern() throws Exception
RESPONSE_GET + "\" not contains in response data:\"" + httpResponseGetInvalidUrl.getData() + "\"");
//Send POST Request
HttpResponse httpResponsePOST =
- HttpRequestUtil.doPost(new URL(GATEWAY_WEB_APP_URL + API_CONTEXT + "/" + API_VERSION_1_0_0 +
+ HttpRequestUtil.doPost(new URL(gatewayWebAppUrl + API_CONTEXT + "/" + API_VERSION_1_0_0 +
API_POST_ENDPOINT_METHOD), "id=25", requestHeadersPost);
assertEquals(httpResponsePOST.getResponseCode(), HTTP_RESPONSE_CODE_OK, "Invocation of POST resource fail after" +
" update the api with URLPattern");
@@ -270,7 +261,7 @@ public void testInvokeGETAndPOSTResourceAfterRemovePOSTResource() throws APIMana
"Update APi with new Resource information fail");
//Send GET request
HttpResponse httpResponseGet =
- HttpRequestUtil.doGet(GATEWAY_WEB_APP_URL + API_CONTEXT + "/" + API_VERSION_1_0_0 + API_GET_ENDPOINT_METHOD,
+ HttpRequestUtil.doGet(gatewayWebAppUrl + API_CONTEXT + "/" + API_VERSION_1_0_0 + API_GET_ENDPOINT_METHOD,
requestHeadersGet);
assertEquals(httpResponseGet.getResponseCode(), HTTP_RESPONSE_CODE_OK, "Invocation fails for GET request after " +
"remove the POST resource from api");
@@ -293,7 +284,7 @@ public void testInvokeGETAndPOSTResourceAfterRemovePOSTResource() throws APIMana
@AfterClass(alwaysRun = true)
- public void cleanUpArtifacts() throws APIManagerIntegrationTestException {
+ public void cleanUpArtifacts() throws APIManagerIntegrationTestException, XPathExpressionException {
apiStoreClientUser1.removeApplication(APPLICATION_NAME);
deleteAPI(apiIdentifier, apiPublisherClientUser1);
diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/AddNewHandlerAndInvokeAPITestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/AddNewHandlerAndInvokeAPITestCase.java
index f898e2140b..c476c836c1 100644
--- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/AddNewHandlerAndInvokeAPITestCase.java
+++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/AddNewHandlerAndInvokeAPITestCase.java
@@ -18,6 +18,8 @@
package org.wso2.am.integration.tests.api.lifecycle;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@@ -51,9 +53,10 @@
* Configure a new handler and Invoke the API and verify the request is going through newly added handler.
*/
public class AddNewHandlerAndInvokeAPITestCase extends APIManagerLifecycleBaseTest {
- private static final String API_NAME = "APILifeCycleTestAPIHandler";
- private static final String API_CONTEXT = "testAPIHandler";
- private static final String API_TAGS = "youtube, video, media";
+ private static final Log log = LogFactory.getLog(AddNewHandlerAndInvokeAPITestCase.class);
+ private static final String API_NAME = "AddNewHandlerAndInvokeAPITest";
+ private static final String API_CONTEXT = "AddNewHandlerAndInvokeAPI";
+ private static final String API_TAGS = "testTag1, testTag2, testTag3";
private static final String API_DESCRIPTION = "This is test API create by API manager integration test";
private static final String API_VERSION_1_0_0 = "1.0.0";
private static final String APPLICATION_NAME = "AddNewHandlerAndInvokeAPI";
@@ -63,38 +66,34 @@ public class AddNewHandlerAndInvokeAPITestCase extends APIManagerLifecycleBaseTe
private static final String API_GET_ENDPOINT_METHOD = "/handler";
private static final String CUSTOM_AUTHORIZATION = "CustomAuthKey 123456789";
private static final String API_END_POINT_POSTFIX_URL = "jaxrs_basic/services/customers/customerservice/";
+ private static final String CUSTOM_AUTH_HANDLER_JAR = "CustomAPIAuthenticationHandler-1.0.0.jar";
private APIPublisherRestClient apiPublisherClientUser1;
private APIStoreRestClient apiStoreClientUser1;
private String providerName;
- private String originalSynapseConfig;
private String newSynapseConfig;
private APIIdentifier apiIdentifier;
private SynapseConfigAdminClient synapseConfigAdminClient;
private String gatewaySession;
private String apiEndPointUrl;
+ private ServerConfigurationManager serverConfigurationManager;
+ private String customHandlerTargetPath;
@BeforeClass(alwaysRun = true)
public void initialize() throws Exception {
super.init();
+
String synapseConfigArtifactsPath =
TestConfigurationProvider.getResourceLocation() + File.separator + "artifacts" + File.separator +
"AM" + File.separator + "lifecycletest" + File.separator + "synapseconfig.xml";
newSynapseConfig = readFile(synapseConfigArtifactsPath);
- String webAppSourcePath =
- TestConfigurationProvider.getResourceLocation() + File.separator + "artifacts" + File.separator +
- "AM" + File.separator + "lifecycletest" + File.separator + "jaxrs_basic.war";
- String webAppTargetPath =
- CARBON_HOME + File.separator + "repository" + File.separator + "deployment" + File.separator +
- "server" + File.separator + "webapps";
- ServerConfigurationManager serverConfigurationManager = new ServerConfigurationManager(gatewayContext);
- FileManager.copyResourceToFileSystem(webAppSourcePath, webAppTargetPath, "jaxrs_basic.war");
String customHandlerSourcePath =
TestConfigurationProvider.getResourceLocation() + File.separator + "artifacts" + File.separator + "AM" +
File.separator + "lifecycletest" + File.separator + "CustomAPIAuthenticationHandler-1.0.0.jar";
- String customHandlerTargetPath =
+ customHandlerTargetPath =
CARBON_HOME + File.separator + "repository" + File.separator + "components" + File.separator + "lib";
- FileManager.copyResourceToFileSystem(customHandlerSourcePath, customHandlerTargetPath,
- "CustomAPIAuthenticationHandler-1.0.0.jar");
+ FileManager.copyResourceToFileSystem(customHandlerSourcePath, customHandlerTargetPath, CUSTOM_AUTH_HANDLER_JAR);
+
+ serverConfigurationManager = new ServerConfigurationManager(gatewayContext);
String log4jPropertiesFile =
TestConfigurationProvider.getResourceLocation() + File.separator + "artifacts" + File.separator +
"AM" + File.separator + "lifecycletest" + File.separator + "log4j.properties";
@@ -119,8 +118,7 @@ public void initialize() throws Exception {
storeContext.getContextTenant().getContextUser().getPassword());
gatewaySession = createSession(gatewayContext);
synapseConfigAdminClient =
- new SynapseConfigAdminClient(gatewayUrls.getWebAppURLHttps() + "services/", gatewaySession);
- originalSynapseConfig = synapseConfigAdminClient.getConfiguration();
+ new SynapseConfigAdminClient(gatewayContext.getContextUrls().getBackEndUrl(), gatewaySession);
apiEndPointUrl = gatewayUrls.getWebAppURLHttp() + API_END_POINT_POSTFIX_URL;
}
@@ -142,6 +140,17 @@ public void testAPIInvocationHitsTheNewHandler() throws APIManagerIntegrationTes
apiPublisherClientUser1, apiStoreClientUser1, APPLICATION_NAME);
synapseConfigAdminClient.updateConfiguration(newSynapseConfig);
+ long startTime = System.currentTimeMillis();
+ long maxWaitTimeForConfigPersist = 60 * 1000;
+ while ((!synapseConfigAdminClient.getConfiguration().
+ contains("")) &&
+ (System.currentTimeMillis() - startTime) < maxWaitTimeForConfigPersist) {
+ try {
+ Thread.sleep(500);
+ } catch (InterruptedException e) {
+ log.warn("InterruptedException occurs while sleeping 500 milliseconds");
+ }
+ }
Map requestHeadersGet = new HashMap();
requestHeadersGet.put("Content-Type", "text/plain");
//get the access token
@@ -155,7 +164,7 @@ public void testAPIInvocationHitsTheNewHandler() throws APIManagerIntegrationTes
//Send GET Request
HttpResponse httpResponse =
- HttpRequestUtil.doGet(GATEWAY_WEB_APP_URL + API_CONTEXT + "/" + API_VERSION_1_0_0 +
+ HttpRequestUtil.doGet(gatewayWebAppUrl + API_CONTEXT + "/" + API_VERSION_1_0_0 +
API_GET_ENDPOINT_METHOD, requestHeadersGet);
assertEquals(httpResponse.getResponseCode(), HTTP_RESPONSE_CODE_OK, "Invocation fails for GET request");
@@ -177,10 +186,9 @@ public void testAPIInvocationHitsTheNewHandler() throws APIManagerIntegrationTes
@AfterClass(alwaysRun = true)
public void cleanUpArtifacts() throws APIManagerIntegrationTestException, XMLStreamException,
RemoteException {
- //Restore original synapse configuration
- synapseConfigAdminClient.updateConfiguration(originalSynapseConfig);
apiStoreClientUser1.removeApplication(APPLICATION_NAME);
deleteAPI(apiIdentifier, apiPublisherClientUser1);
+ FileManager.deleteFile(customHandlerTargetPath + File.separator + CUSTOM_AUTH_HANDLER_JAR);
}
diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/AddNewMediationAndInvokeAPITestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/AddNewMediationAndInvokeAPITestCase.java
index 16e6cf731d..3703b851ae 100644
--- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/AddNewMediationAndInvokeAPITestCase.java
+++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/AddNewMediationAndInvokeAPITestCase.java
@@ -26,16 +26,12 @@
import org.wso2.am.integration.test.utils.clients.APIPublisherRestClient;
import org.wso2.am.integration.test.utils.clients.APIStoreRestClient;
import org.wso2.carbon.apimgt.api.model.APIIdentifier;
-import org.wso2.carbon.automation.test.utils.common.FileManager;
-import org.wso2.carbon.automation.test.utils.common.TestConfigurationProvider;
import org.wso2.carbon.automation.test.utils.http.client.HttpRequestUtil;
import org.wso2.carbon.automation.test.utils.http.client.HttpResponse;
import org.wso2.carbon.integration.common.admin.client.LogViewerClient;
-import org.wso2.carbon.integration.common.utils.mgt.ServerConfigurationManager;
import org.wso2.carbon.logging.view.stub.LogViewerLogViewerException;
import org.wso2.carbon.logging.view.stub.types.carbon.LogEvent;
-import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.HashMap;
@@ -46,16 +42,16 @@
* Add new Log mediation to the in-flow and check the logs to verify the added mediation is working.
*/
public class AddNewMediationAndInvokeAPITestCase extends APIManagerLifecycleBaseTest {
- private static final String API_NAME = "APILifeCycleTestAPI";
- private static final String API_CONTEXT = "testAPI";
- private static final String API_TAGS = "youtube, video, media";
+ private static final String API_NAME = "AddNewMediationAndInvokeAPITest";
+ private static final String API_CONTEXT = "AddNewMediationAndInvokeAPI";
+ private static final String API_TAGS = "testTag1, testTag2, testTag3";
private static final String API_END_POINT_POSTFIX_URL = "jaxrs_basic/services/customers/customerservice/";
private static final String API_DESCRIPTION = "This is test API create by API manager integration test";
private static final String API_VERSION_1_0_0 = "1.0.0";
private static final String APPLICATION_NAME = "AddNewMediationAndInvokeAPI";
private final static String RESPONSE_GET = "123John";
private final static String API_GET_ENDPOINT_METHOD = "/customers/123";
- private final static String MEDIATION_LOG_OUTPUT1 = "To: /testAPI/1.0.0/customers/123";
+ private final static String MEDIATION_LOG_OUTPUT1 = "To: /" + API_CONTEXT + "/" + API_VERSION_1_0_0 + API_GET_ENDPOINT_METHOD;
private final static String MEDIATION_LOG_OUTPUT2 = "Direction: request, IN_MESSAGE = IN_MESSAGE";
private final static String MEDIATION_LOGGER = "org.apache.synapse.mediators.builtin.LogMediator";
private APIPublisherRestClient apiPublisherClientUser1;
@@ -69,17 +65,6 @@ public class AddNewMediationAndInvokeAPITestCase extends APIManagerLifecycleBase
public void initialize() throws Exception {
super.init();
String apiEndPointUrl = gatewayUrls.getWebAppURLHttp() + API_END_POINT_POSTFIX_URL;
- String webAppSourcePath =
- TestConfigurationProvider.getResourceLocation() + File.separator + "artifacts" + File.separator +
- "AM" + File.separator + "lifecycletest" + File.separator +
- "jaxrs_basic.war";
- String webAppTargetPath =
- CARBON_HOME + File.separator + "repository" + File.separator + "deployment" + File.separator +
- "server" + File.separator + "webapps";
- ServerConfigurationManager serverConfigurationManager = new ServerConfigurationManager(gatewayContext);
- FileManager.copyResourceToFileSystem(webAppSourcePath, webAppTargetPath, "jaxrs_basic.war");
- serverConfigurationManager.restartGracefully();
- super.init();
String providerName = publisherContext.getContextTenant().getContextUser().getUserName();
apiCreationRequestBean =
new APICreationRequestBean(API_NAME, API_CONTEXT, API_VERSION_1_0_0, providerName,
@@ -126,7 +111,7 @@ public void testAPIInvocationBeforeAddingNewMediation() throws APIManagerIntegra
logViewerClient.clearLogs();
//Send GET Request
HttpResponse httpResponse =
- HttpRequestUtil.doGet(GATEWAY_WEB_APP_URL + API_CONTEXT + "/" + API_VERSION_1_0_0 + API_GET_ENDPOINT_METHOD,
+ HttpRequestUtil.doGet(gatewayWebAppUrl + API_CONTEXT + "/" + API_VERSION_1_0_0 + API_GET_ENDPOINT_METHOD,
requestHeadersGet);
assertEquals(httpResponse.getResponseCode(), HTTP_RESPONSE_CODE_OK, "Invocation fails for GET request");
assertTrue(httpResponse.getData().contains(RESPONSE_GET), "Response Data not match for GET request." +
@@ -152,7 +137,7 @@ public void testAPIInvocationAfterAddingNewMediation() throws APIManagerIntegrat
logViewerClient.clearLogs();
//Send GET Request
HttpResponse httpResponse =
- HttpRequestUtil.doGet(GATEWAY_WEB_APP_URL + API_CONTEXT + "/" + API_VERSION_1_0_0 + API_GET_ENDPOINT_METHOD,
+ HttpRequestUtil.doGet(gatewayWebAppUrl + API_CONTEXT + "/" + API_VERSION_1_0_0 + API_GET_ENDPOINT_METHOD,
requestHeadersGet);
assertEquals(httpResponse.getResponseCode(), HTTP_RESPONSE_CODE_OK, "Invocation fails for GET request");
assertTrue(httpResponse.getData().contains(RESPONSE_GET), "Response Data not match for GET request." +
@@ -176,7 +161,7 @@ public void testAPIInvocationBeforeRemovingNewMediation() throws APIManagerInteg
apiPublisherClientUser1.updateAPI(apiCreationRequestBean);
//Send GET Request
HttpResponse httpResponse =
- HttpRequestUtil.doGet(GATEWAY_WEB_APP_URL + API_CONTEXT + "/" + API_VERSION_1_0_0 +
+ HttpRequestUtil.doGet(gatewayWebAppUrl + API_CONTEXT + "/" + API_VERSION_1_0_0 +
API_GET_ENDPOINT_METHOD, requestHeadersGet);
assertEquals(httpResponse.getResponseCode(), HTTP_RESPONSE_CODE_OK, "Invocation fails for GET request");
assertTrue(httpResponse.getData().contains(RESPONSE_GET), "Response Data not match for GET request." +
@@ -208,9 +193,10 @@ public void cleanUpArtifacts() throws APIManagerIntegrationTestException {
private boolean isLogAvailable(LogEvent[] logEventsArray, String expectedLogger, String expectedLog) {
boolean isNewMediationCalled = false;
for (LogEvent logEvent : logEventsArray) {
- if (logEvent.getLogger().equals(expectedLogger) && logEvent.getMessage().contains(expectedLog)) {
+
+ if (logEvent != null && logEvent.getLogger().equals(expectedLogger) &&
+ logEvent.getMessage().contains(expectedLog)) {
isNewMediationCalled = true;
- System.out.print(logEvent);
break;
}
}
diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/ChangeAPIEndPointURLTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/ChangeAPIEndPointURLTestCase.java
index 545bf04f5b..32f0369142 100644
--- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/ChangeAPIEndPointURLTestCase.java
+++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/ChangeAPIEndPointURLTestCase.java
@@ -42,17 +42,20 @@
* Change the API end point URL and test the invocation.
*/
public class ChangeAPIEndPointURLTestCase extends APIManagerLifecycleBaseTest {
- private static final String API_NAME = "APILifeCycleTestAPI";
- private static final String API_CONTEXT = "testAPI";
- private static final String API_TAGS = "youtube, video, media";
- private static final String API1_END_POINT_URL = "http://gdata.youtube.com/feeds/api/standardfeeds";
+ private static final String API_NAME = "ChangeAPIEndPointURLTest";
+ private static final String API_CONTEXT = "ChangeAPIEndPointURLTest";
+ private static final String API_TAGS = "testTag1, testTag2, testTag3";
+
private static final String API_DESCRIPTION = "This is test API create by API manager integration test";
- private static final String API1_END_POINT_METHOD = "/most_popular";
- private static final String API1_RESPONSE_DATA = "();
+ requestHeaders.put("accept", "text/xml");
requestHeaders.put("Authorization", "Bearer " + accessToken);
//Invoke old version
HttpResponse oldVersionInvokeResponse =
- HttpRequestUtil.doGet(GATEWAY_WEB_APP_URL + API_CONTEXT + "/" + API_VERSION_1_0_0 + API1_END_POINT_METHOD,
+ HttpRequestUtil.doGet(gatewayWebAppUrl + API_CONTEXT + "/" + API_VERSION_1_0_0 + API1_END_POINT_METHOD,
requestHeaders);
assertEquals(oldVersionInvokeResponse.getResponseCode(), HTTP_RESPONSE_CODE_OK,
"Response code mismatched when invoke api before change the end point URL");
@@ -131,7 +136,7 @@ public void testEditEndPointURL() throws APIManagerIntegrationTestException, Mal
public void testInvokeAPIAfterChangeAPIEndPointURLWithNewEndPointURL() throws APIManagerIntegrationTestException, IOException {
//Invoke new context
HttpResponse oldVersionInvokeResponse =
- HttpRequestUtil.doGet(GATEWAY_WEB_APP_URL + API_CONTEXT + "/" + API_VERSION_1_0_0,
+ HttpRequestUtil.doGet(gatewayWebAppUrl + API_CONTEXT + "/" + API_VERSION_1_0_0,
requestHeaders);
assertEquals(oldVersionInvokeResponse.getResponseCode(), HTTP_RESPONSE_CODE_OK,
"Response code mismatched when invoke API after change the end point URL");
diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/ChangeAPITagsTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/ChangeAPITagsTestCase.java
index 0ebed607a1..724101ff9b 100644
--- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/ChangeAPITagsTestCase.java
+++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/ChangeAPITagsTestCase.java
@@ -41,10 +41,12 @@
* Change the API Tags and check how the API are listed under tags.
*/
public class ChangeAPITagsTestCase extends APIManagerLifecycleBaseTest {
- private static final String API_END_POINT_URL = "http://gdata.youtube.com/feeds/api/standardfeeds";
+
private static final String API_DESCRIPTION = "This is test API create by API manager integration test";
private static final String API_VERSION_1_0_0 = "1.0.0";
private static final String TEST_TAG = "Tag3";
+ private static final String API_END_POINT_POSTFIX_URL = "jaxrs_basic/services/customers/customerservice/";
+ private String apiEndPointUrl;
private String providerName;
private APIPublisherRestClient apiPublisherClientUser1;
private APIStoreRestClient apiStoreClientUser1;
@@ -55,6 +57,7 @@ public class ChangeAPITagsTestCase extends APIManagerLifecycleBaseTest {
@BeforeClass(alwaysRun = true)
public void initialize() throws APIManagerIntegrationTestException, XPathExpressionException {
super.init();
+ apiEndPointUrl = gatewayUrls.getWebAppURLHttp() + API_END_POINT_POSTFIX_URL;
providerName = publisherContext.getContextTenant().getContextUser().getUserName();
String publisherURLHttp = publisherUrls.getWebAppURLHttp();
String storeURLHttp = storeUrls.getWebAppURLHttp();
@@ -94,7 +97,7 @@ public void testFilterByTagsBeforeTagChange() throws APIManagerIntegrationTestEx
= new APIIdentifier(providerName, apiName, API_VERSION_1_0_0);
APICreationRequestBean apiCreationRequestBean =
new APICreationRequestBean(apiName, apiContext, API_VERSION_1_0_0, providerName,
- new URL(API_END_POINT_URL));
+ new URL(apiEndPointUrl));
apiCreationRequestBean.setTags(apiTags);
apiCreationRequestBean.setDescription(API_DESCRIPTION);
createAndPublishAPIWithoutRequireReSubscription(apiIdentifier, apiCreationRequestBean,
@@ -131,7 +134,7 @@ public void testUpdateTagsAndFilterByTags() throws APIManagerIntegrationTestExce
String apiContext = apiName.toLowerCase();
APICreationRequestBean apiCreationRequestBean =
new APICreationRequestBean(apiName, apiContext, API_VERSION_1_0_0, providerName,
- new URL(API_END_POINT_URL));
+ new URL(apiEndPointUrl));
apiCreationRequestBean.setTags(apiTags);
apiCreationRequestBean.setDescription(API_DESCRIPTION);
//Update API with Edited Tags
diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/ChangeAPITierAndTestInvokingTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/ChangeAPITierAndTestInvokingTestCase.java
index 97a55bd24a..44dbe45630 100644
--- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/ChangeAPITierAndTestInvokingTestCase.java
+++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/ChangeAPITierAndTestInvokingTestCase.java
@@ -44,15 +44,17 @@
* and do a new silver subscription and test invocation under Silver tier.
*/
public class ChangeAPITierAndTestInvokingTestCase extends APIManagerLifecycleBaseTest {
- private static final String API_NAME = "APILifeCycleTestAPI";
- private static final String API_CONTEXT = "testAPI";
- private static final String API_TAGS = "youtube, video, media";
- private static final String API_END_POINT_URL = "http://gdata.youtube.com/feeds/api/standardfeeds";
+ private static final String API_NAME = "ChangeAPITierAndTestInvokingTest";
+ private static final String API_CONTEXT = "ChangeAPITierAndTestInvoking";
+ private static final String API_TAGS = "testTag1, testTag2, testTag3";
+
private static final String API_DESCRIPTION = "This is test API create by API manager integration test";
- private static final String API_END_POINT_METHOD = "/most_popular";
- private static final String API_RESPONSE_DATA = " requestHeadersGoldTier;
@@ -65,6 +67,7 @@ public class ChangeAPITierAndTestInvokingTestCase extends APIManagerLifecycleBas
@BeforeClass(alwaysRun = true)
public void initialize() throws APIManagerIntegrationTestException, XPathExpressionException {
super.init();
+ apiEndPointUrl = gatewayUrls.getWebAppURLHttp() + API_END_POINT_POSTFIX_URL;
providerName = publisherContext.getContextTenant().getContextUser().getUserName();
String publisherURLHttp = publisherUrls.getWebAppURLHttp();
String storeURLHttp = storeUrls.getWebAppURLHttp();
@@ -87,7 +90,7 @@ public void testInvokingWithGoldTier() throws APIManagerIntegrationTestException
apiStoreClientUser1.addApplication(applicationNameGold, TIER_GOLD, "", "");
apiCreationRequestBean =
new APICreationRequestBean(API_NAME, API_CONTEXT, API_VERSION_1_0_0, providerName,
- new URL(API_END_POINT_URL));
+ new URL(apiEndPointUrl));
apiCreationRequestBean.setTags(API_TAGS);
apiCreationRequestBean.setDescription(API_DESCRIPTION);
apiCreationRequestBean.setTier(TIER_GOLD);
@@ -100,13 +103,14 @@ public void testInvokingWithGoldTier() throws APIManagerIntegrationTestException
// Create requestHeaders
requestHeadersGoldTier = new HashMap();
requestHeadersGoldTier.put("Authorization", "Bearer " + accessToken);
+ requestHeadersGoldTier.put("accept", "text/xml");
long startTime = System.currentTimeMillis();
long currentTime;
for (int invocationCount = 1; invocationCount <= GOLD_INVOCATION_LIMIT_PER_MIN; invocationCount++) {
currentTime = System.currentTimeMillis();
//Invoke API
HttpResponse invokeResponse =
- HttpRequestUtil.doGet(GATEWAY_WEB_APP_URL + API_CONTEXT + "/" + API_VERSION_1_0_0 +
+ HttpRequestUtil.doGet(gatewayWebAppUrl + API_CONTEXT + "/" + API_VERSION_1_0_0 +
API_END_POINT_METHOD, requestHeadersGoldTier);
assertEquals(invokeResponse.getResponseCode(), HTTP_RESPONSE_CODE_OK,
"Response code mismatched. Invocation attempt:" + invocationCount + " failed during :" +
@@ -116,7 +120,7 @@ public void testInvokingWithGoldTier() throws APIManagerIntegrationTestException
(currentTime - startTime) + " milliseconds under Gold API level tier");
}
currentTime = System.currentTimeMillis();
- HttpResponse invokeResponse = HttpRequestUtil.doGet(GATEWAY_WEB_APP_URL + API_CONTEXT + "/" +
+ HttpResponse invokeResponse = HttpRequestUtil.doGet(gatewayWebAppUrl + API_CONTEXT + "/" +
API_VERSION_1_0_0 + API_END_POINT_METHOD, requestHeadersGoldTier);
assertEquals(invokeResponse.getResponseCode(), HTTP_RESPONSE_CODE_SERVICE_UNAVAILABLE,
"Response code mismatched. Invocation attempt:" + (GOLD_INVOCATION_LIMIT_PER_MIN + 1) +
@@ -133,7 +137,7 @@ public void testInvokingAfterExpireThrottleExpireTime() throws InterruptedExcept
//wait millisecond to expire the throttling block
Thread.sleep(THROTTLING_UNIT_TIME + THROTTLING_ADDITIONAL_WAIT_TIME);
HttpResponse invokeResponse =
- HttpRequestUtil.doGet(GATEWAY_WEB_APP_URL + API_CONTEXT + "/" + API_VERSION_1_0_0 +
+ HttpRequestUtil.doGet(gatewayWebAppUrl + API_CONTEXT + "/" + API_VERSION_1_0_0 +
API_END_POINT_METHOD, requestHeadersGoldTier);
assertEquals(invokeResponse.getResponseCode(), HTTP_RESPONSE_CODE_OK, "Response code mismatched, " +
"Invocation fails after wait " + (THROTTLING_UNIT_TIME + THROTTLING_ADDITIONAL_WAIT_TIME) +
@@ -147,7 +151,7 @@ public void testInvokingAfterExpireThrottleExpireTime() throws InterruptedExcept
dependsOnMethods = "testInvokingAfterExpireThrottleExpireTime")
public void testEditAPITierToSilver() throws APIManagerIntegrationTestException, MalformedURLException {
apiCreationRequestBean = new APICreationRequestBean(API_NAME, API_CONTEXT, API_VERSION_1_0_0, providerName,
- new URL(API_END_POINT_URL));
+ new URL(apiEndPointUrl));
apiCreationRequestBean.setTags(API_TAGS);
apiCreationRequestBean.setDescription(API_DESCRIPTION);
apiCreationRequestBean.setTier(TIER_SILVER);
@@ -175,6 +179,7 @@ public void testInvokingWithSilverTier() throws APIManagerIntegrationTestExcepti
String accessToken = generateApplicationKeys(apiStoreClientUser1, applicationNameSilver).getAccessToken();
// Create requestHeaders
Map requestHeadersSilverTier = new HashMap();
+ requestHeadersSilverTier.put("accept", "text/xml");
requestHeadersSilverTier.put("Authorization", "Bearer " + accessToken);
//millisecond to expire the throttling block
Thread.sleep(THROTTLING_UNIT_TIME + THROTTLING_ADDITIONAL_WAIT_TIME);
@@ -184,7 +189,7 @@ public void testInvokingWithSilverTier() throws APIManagerIntegrationTestExcepti
currentTime = System.currentTimeMillis();
//Invoke API
HttpResponse invokeResponse =
- HttpRequestUtil.doGet(GATEWAY_WEB_APP_URL + API_CONTEXT + "/" + API_VERSION_1_0_0 +
+ HttpRequestUtil.doGet(gatewayWebAppUrl + API_CONTEXT + "/" + API_VERSION_1_0_0 +
API_END_POINT_METHOD, requestHeadersSilverTier);
assertEquals(invokeResponse.getResponseCode(), HTTP_RESPONSE_CODE_OK, "Response code mismatched. " +
"Invocation attempt:" + invocationCount + " failed during :" + (currentTime - startTime) +
@@ -194,7 +199,7 @@ public void testInvokingWithSilverTier() throws APIManagerIntegrationTestExcepti
" milliseconds under Silver API level tier");
}
currentTime = System.currentTimeMillis();
- HttpResponse invokeResponse = HttpRequestUtil.doGet(GATEWAY_WEB_APP_URL + API_CONTEXT + "/" + API_VERSION_1_0_0 +
+ HttpResponse invokeResponse = HttpRequestUtil.doGet(gatewayWebAppUrl + API_CONTEXT + "/" + API_VERSION_1_0_0 +
API_END_POINT_METHOD, requestHeadersSilverTier);
assertEquals(invokeResponse.getResponseCode(), HTTP_RESPONSE_CODE_SERVICE_UNAVAILABLE,
"Response code mismatched. Invocation attempt:" + (SILVER_INVOCATION_LIMIT_PER_MIN + 1) +
diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/ChangeApplicationTierAndTestInvokingTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/ChangeApplicationTierAndTestInvokingTestCase.java
index 7725224cfd..1bd6a413a8 100644
--- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/ChangeApplicationTierAndTestInvokingTestCase.java
+++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/ChangeApplicationTierAndTestInvokingTestCase.java
@@ -44,15 +44,16 @@
*/
public class ChangeApplicationTierAndTestInvokingTestCase extends APIManagerLifecycleBaseTest {
- private static final String API_NAME = "APILifeCycleTestAPI";
- private static final String API_CONTEXT = "testAPI";
- private static final String API_TAGS = "youtube, video, media";
- private static final String API_END_POINT_URL = "http://gdata.youtube.com/feeds/api/standardfeeds";
+ private static final String API_NAME = "ChangeApplicationTierAndTestInvokingTest";
+ private static final String API_CONTEXT = "ChangeApplicationTierAndTestInvoking";
+ private static final String API_TAGS = "testTag1, testTag2, testTag3";
private static final String API_DESCRIPTION = "This is test API create by API manager integration test";
- private static final String API_END_POINT_METHOD = "/most_popular";
- private static final String API_RESPONSE_DATA = "();
+ requestHeaders.put("accept", "text/xml");
requestHeaders.put("Authorization", "Bearer " + accessToken);
long startTime = System.currentTimeMillis();
long currentTime;
@@ -112,7 +115,7 @@ public void testInvokingWithAPIGoldTierApplicationSilver() throws APIManagerInte
currentTime = System.currentTimeMillis();
//Invoke API
HttpResponse invokeResponse =
- HttpRequestUtil.doGet(GATEWAY_WEB_APP_URL + API_CONTEXT + "/" + API_VERSION_1_0_0 +
+ HttpRequestUtil.doGet(gatewayWebAppUrl + API_CONTEXT + "/" + API_VERSION_1_0_0 +
API_END_POINT_METHOD, requestHeaders);
assertEquals(invokeResponse.getResponseCode(), HTTP_RESPONSE_CODE_OK,
"Response code mismatched. Invocation attempt:" + invocationCount + " failed during :" +
@@ -122,7 +125,7 @@ public void testInvokingWithAPIGoldTierApplicationSilver() throws APIManagerInte
(currentTime - startTime) + " milliseconds under Gold API and Silver Application level tier");
}
currentTime = System.currentTimeMillis();
- HttpResponse invokeResponse = HttpRequestUtil.doGet(GATEWAY_WEB_APP_URL + API_CONTEXT + "/" + API_VERSION_1_0_0 +
+ HttpResponse invokeResponse = HttpRequestUtil.doGet(gatewayWebAppUrl + API_CONTEXT + "/" + API_VERSION_1_0_0 +
API_END_POINT_METHOD, requestHeaders);
assertEquals(invokeResponse.getResponseCode(), HTTP_RESPONSE_CODE_SERVICE_UNAVAILABLE,
"Response code mismatched. Invocation attempt:" + (SILVER_INVOCATION_LIMIT_PER_MIN + 1) +
@@ -147,7 +150,7 @@ public void testInvokingWithAPIGoldTierApplicationGold() throws APIManagerIntegr
currentTime = System.currentTimeMillis();
//Invoke API
HttpResponse invokeResponse =
- HttpRequestUtil.doGet(GATEWAY_WEB_APP_URL + API_CONTEXT + "/" + API_VERSION_1_0_0 +
+ HttpRequestUtil.doGet(gatewayWebAppUrl + API_CONTEXT + "/" + API_VERSION_1_0_0 +
API_END_POINT_METHOD, requestHeaders);
assertEquals(invokeResponse.getResponseCode(), HTTP_RESPONSE_CODE_OK,
"Response code mismatched. Invocation attempt:" + invocationCount + " failed during :" +
@@ -157,7 +160,9 @@ public void testInvokingWithAPIGoldTierApplicationGold() throws APIManagerIntegr
(currentTime - startTime) + " milliseconds under Gold API and Gold Application level tier");
}
currentTime = System.currentTimeMillis();
- HttpResponse invokeResponse = HttpRequestUtil.doGet(GATEWAY_WEB_APP_URL + API_CONTEXT + "/" + API_VERSION_1_0_0 +
+ HttpRequestUtil.doGet(gatewayWebAppUrl + API_CONTEXT + "/" + API_VERSION_1_0_0 +
+ API_END_POINT_METHOD, requestHeaders);
+ HttpResponse invokeResponse = HttpRequestUtil.doGet(gatewayWebAppUrl + API_CONTEXT + "/" + API_VERSION_1_0_0 +
API_END_POINT_METHOD, requestHeaders);
assertEquals(invokeResponse.getResponseCode(), HTTP_RESPONSE_CODE_SERVICE_UNAVAILABLE, "Response code mismatched." +
" Invocation attempt:" + (GOLD_INVOCATION_LIMIT_PER_MIN + 1) + " passed during :" +
@@ -182,7 +187,7 @@ public void testInvokingWithAPIGoldTierApplicationSilverFor2ndTime() throws APIM
currentTime = System.currentTimeMillis();
//Invoke API
HttpResponse invokeResponse =
- HttpRequestUtil.doGet(GATEWAY_WEB_APP_URL + API_CONTEXT + "/" + API_VERSION_1_0_0 +
+ HttpRequestUtil.doGet(gatewayWebAppUrl + API_CONTEXT + "/" + API_VERSION_1_0_0 +
API_END_POINT_METHOD, requestHeaders);
assertEquals(invokeResponse.getResponseCode(), HTTP_RESPONSE_CODE_OK,
"Response code mismatched. Invocation attempt:" + invocationCount + " failed during :" +
@@ -192,7 +197,9 @@ public void testInvokingWithAPIGoldTierApplicationSilverFor2ndTime() throws APIM
(currentTime - startTime) + " milliseconds under Gold API and Gold Application level tier");
}
currentTime = System.currentTimeMillis();
- HttpResponse invokeResponse = HttpRequestUtil.doGet(GATEWAY_WEB_APP_URL + API_CONTEXT + "/" + API_VERSION_1_0_0 +
+ HttpRequestUtil.doGet(gatewayWebAppUrl + API_CONTEXT + "/" + API_VERSION_1_0_0 +
+ API_END_POINT_METHOD, requestHeaders);
+ HttpResponse invokeResponse = HttpRequestUtil.doGet(gatewayWebAppUrl + API_CONTEXT + "/" + API_VERSION_1_0_0 +
API_END_POINT_METHOD, requestHeaders);
assertEquals(invokeResponse.getResponseCode(), HTTP_RESPONSE_CODE_SERVICE_UNAVAILABLE, "Response code mismatched." +
" Invocation attempt:" + (SILVER_INVOCATION_LIMIT_PER_MIN + 1) + " passed during :" +
diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/ChangeAuthTypeOfResourceTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/ChangeAuthTypeOfResourceTestCase.java
index 35d47bb23d..b2345a609f 100644
--- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/ChangeAuthTypeOfResourceTestCase.java
+++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/ChangeAuthTypeOfResourceTestCase.java
@@ -29,13 +29,9 @@
import org.wso2.am.integration.test.utils.clients.APIPublisherRestClient;
import org.wso2.am.integration.test.utils.clients.APIStoreRestClient;
import org.wso2.carbon.apimgt.api.model.APIIdentifier;
-import org.wso2.carbon.automation.test.utils.common.FileManager;
-import org.wso2.carbon.automation.test.utils.common.TestConfigurationProvider;
import org.wso2.carbon.automation.test.utils.http.client.HttpRequestUtil;
import org.wso2.carbon.automation.test.utils.http.client.HttpResponse;
-import org.wso2.carbon.integration.common.utils.mgt.ServerConfigurationManager;
-import java.io.File;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
@@ -49,9 +45,9 @@
*/
public class ChangeAuthTypeOfResourceTestCase extends APIManagerLifecycleBaseTest {
- private static final String API_NAME = "ChangeAuthTypeAPI1";
- private static final String API_CONTEXT = "ChangeAuthTypeAPI1";
- private static final String API_TAGS = "youtube, video, media";
+ private static final String API_NAME = "ChangeAuthTypeOfResourceTest";
+ private static final String API_CONTEXT = "ChangeAuthTypeOfResource";
+ private static final String API_TAGS = "testTag1, testTag2, testTag3";
private static final String API_END_POINT_POSTFIX_URL = "jaxrs_basic/services/customers/customerservice/";
private static final String API_DESCRIPTION = "This is test API create by API manager integration test";
private static final String API_VERSION_1_0_0 = "1.0.0";
@@ -71,16 +67,6 @@ public class ChangeAuthTypeOfResourceTestCase extends APIManagerLifecycleBaseTes
public void initialize() throws Exception {
super.init();
apiEndPointUrl = gatewayUrls.getWebAppURLHttp() + API_END_POINT_POSTFIX_URL;
- String sourcePath =
- TestConfigurationProvider.getResourceLocation() + File.separator + "artifacts" + File.separator + "AM" +
- File.separator + "lifecycletest" + File.separator + "jaxrs_basic.war";
- String targetPath =
- CARBON_HOME + File.separator + "repository" + File.separator +
- "deployment" + File.separator + "server" + File.separator + "webapps";
- ServerConfigurationManager serverConfigurationManager = new ServerConfigurationManager(gatewayContext);
- FileManager.copyResourceToFileSystem(sourcePath, targetPath, "jaxrs_basic.war");
- serverConfigurationManager.restartGracefully();
- super.init();
providerName = publisherContext.getContextTenant().getContextUser().getUserName();
String publisherURLHttp = publisherUrls.getWebAppURLHttp();
String storeURLHttp = storeUrls.getWebAppURLHttp();
@@ -120,7 +106,7 @@ public void testInvokeResourceWithAuthTypeApplicationAndApplicationUser() throws
requestHeadersGet.put("Authorization", "Bearer " + accessToken);
//Send GET request
HttpResponse httpResponseGet =
- HttpRequestUtil.doGet(GATEWAY_WEB_APP_URL + API_CONTEXT + "/" + API_VERSION_1_0_0 + API_GET_ENDPOINT_METHOD,
+ HttpRequestUtil.doGet(gatewayWebAppUrl + API_CONTEXT + "/" + API_VERSION_1_0_0 + API_GET_ENDPOINT_METHOD,
requestHeadersGet);
assertEquals(httpResponseGet.getResponseCode(), HTTP_RESPONSE_CODE_OK, "Invocation fails for GET request for " +
"auth type Application & Application User");
@@ -151,7 +137,7 @@ public void testInvokeResourceWithAuthTypeApplication() throws Exception {
assertEquals(getValueFromJSON(updateAPIHTTPResponse, "error"), "false", "Update APi with new Resource information fail");
//Send GET request
HttpResponse httpResponseGet =
- HttpRequestUtil.doGet(GATEWAY_WEB_APP_URL + API_CONTEXT + "/" + API_VERSION_1_0_0 + API_GET_ENDPOINT_METHOD,
+ HttpRequestUtil.doGet(gatewayWebAppUrl + API_CONTEXT + "/" + API_VERSION_1_0_0 + API_GET_ENDPOINT_METHOD,
requestHeadersGet);
assertEquals(httpResponseGet.getResponseCode(), HTTP_RESPONSE_CODE_OK, "Invocation fails for GET request for " +
"auth type Application");
@@ -189,7 +175,7 @@ public void testInvokeGETResourceWithAuthTypeApplicationUser() throws Exception
requestHeadersGet.put("Authorization", "Bearer " + accessTokenGenerationResponse.getString("access_token"));
//Send GET request
HttpResponse httpResponseGet =
- HttpRequestUtil.doGet(GATEWAY_WEB_APP_URL + API_CONTEXT + "/" + API_VERSION_1_0_0 + API_GET_ENDPOINT_METHOD,
+ HttpRequestUtil.doGet(gatewayWebAppUrl + API_CONTEXT + "/" + API_VERSION_1_0_0 + API_GET_ENDPOINT_METHOD,
requestHeadersGet);
assertEquals(httpResponseGet.getResponseCode(), HTTP_RESPONSE_CODE_OK, "Invocation fails for GET request for " +
"auth type Application User");
@@ -218,7 +204,7 @@ public void testInvokeGETResourceWithAuthTypeNone() throws Exception {
assertEquals(getValueFromJSON(updateAPIHTTPResponse, "error"), "false", "Update APi with new Resource information fail");
//Send GET request
HttpResponse httpResponseGet =
- HttpRequestUtil.doGet(GATEWAY_WEB_APP_URL + API_CONTEXT + "/" + API_VERSION_1_0_0 + API_GET_ENDPOINT_METHOD,
+ HttpRequestUtil.doGet(gatewayWebAppUrl + API_CONTEXT + "/" + API_VERSION_1_0_0 + API_GET_ENDPOINT_METHOD,
requestHeadersGet);
assertEquals(httpResponseGet.getResponseCode(), HTTP_RESPONSE_CODE_OK, "Invocation fails for GET request for " +
"auth type None");
diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/ChangeEndPointSecurityOfAPITestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/ChangeEndPointSecurityOfAPITestCase.java
index 24ad870353..ae0a0a5aab 100644
--- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/ChangeEndPointSecurityOfAPITestCase.java
+++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/ChangeEndPointSecurityOfAPITestCase.java
@@ -18,6 +18,7 @@
package org.wso2.am.integration.tests.api.lifecycle;
+import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
@@ -26,16 +27,15 @@
import org.wso2.am.integration.test.utils.clients.APIPublisherRestClient;
import org.wso2.am.integration.test.utils.clients.APIStoreRestClient;
import org.wso2.carbon.apimgt.api.model.APIIdentifier;
-import org.wso2.carbon.automation.test.utils.common.FileManager;
-import org.wso2.carbon.automation.test.utils.common.TestConfigurationProvider;
import org.wso2.carbon.automation.test.utils.http.client.HttpRequestUtil;
import org.wso2.carbon.automation.test.utils.http.client.HttpResponse;
-import org.wso2.carbon.integration.common.utils.mgt.ServerConfigurationManager;
import javax.xml.bind.DatatypeConverter;
-import java.io.File;
+import javax.xml.xpath.XPathExpressionException;
import java.io.IOException;
import java.net.URL;
+import java.net.URLEncoder;
+import java.rmi.RemoteException;
import java.util.HashMap;
import static org.testng.Assert.assertEquals;
@@ -46,8 +46,8 @@
* the response body.
*/
public class ChangeEndPointSecurityOfAPITestCase extends APIManagerLifecycleBaseTest {
- private static final String API_NAME = "ChangeEndpointAPI1";
- private static final String API_CONTEXT = "ChangeEndpointAPI1";
+ private static final String API_NAME = "ChangeEndPointSecurityOfAPITest";
+ private static final String API_CONTEXT = "ChangeEndPointSecurityOfAPI";
private static final String API_TAGS = "security, username, password";
private static final String API_END_POINT_POSTFIX_URL = "jaxrs_basic/services/customers/customerservice/";
private static final String API_DESCRIPTION = "This is test API create by API manager integration test";
@@ -58,21 +58,12 @@ public class ChangeEndPointSecurityOfAPITestCase extends APIManagerLifecycleBase
private APIStoreRestClient apiStoreClientUser1;
private String providerName;
private String apiEndPointUrl;
+ private APIIdentifier apiIdentifier;
@BeforeClass(alwaysRun = true)
- public void initialize() throws Exception {
+ public void initialize() throws APIManagerIntegrationTestException, XPathExpressionException, RemoteException {
super.init();
apiEndPointUrl = gatewayUrls.getWebAppURLHttp() + API_END_POINT_POSTFIX_URL;
- String sourcePath =
- TestConfigurationProvider.getResourceLocation() + File.separator + "artifacts" + File.separator +
- "AM" + File.separator + "lifecycletest" + File.separator + "jaxrs_basic.war";
- String targetPath =
- CARBON_HOME + File.separator + "repository" + File.separator + "deployment" + File.separator +
- "server" + File.separator + "webapps";
- ServerConfigurationManager serverConfigurationManager = new ServerConfigurationManager(gatewayContext);
- FileManager.copyResourceToFileSystem(sourcePath, targetPath, "jaxrs_basic.war");
- serverConfigurationManager.restartGracefully();
- super.init();
providerName = publisherContext.getContextTenant().getContextUser().getUserName();
String publisherURLHttp = publisherUrls.getWebAppURLHttp();
String storeURLHttp = storeUrls.getWebAppURLHttp();
@@ -91,6 +82,7 @@ public void initialize() throws Exception {
requestHeadersGet = new HashMap();
requestHeadersGet.put("accept", "text/plain");
requestHeadersGet.put("Content-Type", "text/plain");
+ apiIdentifier = new APIIdentifier(providerName, API_NAME, API_VERSION_1_0_0);
}
@@ -100,7 +92,7 @@ public void testInvokeGETResourceWithSecuredEndPointPasswordOnlyNumbersAndLetter
APIManagerIntegrationTestException, IOException {
String endpointUsername = "admin1";
char[] endpointPassword = {'a', 'd', 'm', 'i', 'n', '1', '2', '3'};
- byte[] userNamePasswordByteArray = (endpointUsername + ":" + endpointPassword).getBytes();
+ byte[] userNamePasswordByteArray = (endpointUsername + ":" + String.valueOf(endpointPassword)).getBytes();
String encodedUserNamePassword = DatatypeConverter.printBase64Binary(userNamePasswordByteArray);
//Create application
apiStoreClientUser1.addApplication(APPLICATION_NAME, TIER_UNLIMITED, "", "");
@@ -120,7 +112,7 @@ public void testInvokeGETResourceWithSecuredEndPointPasswordOnlyNumbersAndLetter
String accessToken = generateApplicationKeys(apiStoreClientUser1, APPLICATION_NAME).getAccessToken();
requestHeadersGet.put("Authorization", "Bearer " + accessToken);
HttpResponse httpResponseGet =
- HttpRequestUtil.doGet(GATEWAY_WEB_APP_URL + API_CONTEXT + "/" + API_VERSION_1_0_0 + "/sec",
+ HttpRequestUtil.doGet(gatewayWebAppUrl + API_CONTEXT + "/" + API_VERSION_1_0_0 + "/sec",
requestHeadersGet);
assertEquals(httpResponseGet.getResponseCode(), HTTP_RESPONSE_CODE_OK, "Invocation fails for GET request for " +
"endpoint type secured. username:" + endpointUsername + " password:" + String.valueOf(endpointPassword));
@@ -132,12 +124,14 @@ public void testInvokeGETResourceWithSecuredEndPointPasswordOnlyNumbersAndLetter
}
- @Test(groups = {"wso2.am"}, dataProvider = "SymbolCharacters", description = "Test the API with endpoint security enabled with" +
- " complex password", dependsOnMethods = "testInvokeGETResourceWithSecuredEndPointPasswordOnlyNumbersAndLetters")
- public void testInvokeGETResourceWithSecuredEndPointComplexPassword(String st) throws Exception {
+ @Test(groups = {"wso2.am"}, dataProvider = "SymbolCharacters", description = "Test the API with endpoint security" +
+ " enabled with complex password",
+ dependsOnMethods = "testInvokeGETResourceWithSecuredEndPointPasswordOnlyNumbersAndLetters")
+ public void testInvokeGETResourceWithSecuredEndPointComplexPassword(String st) throws IOException,
+ APIManagerIntegrationTestException {
String endpointUsername = "user";
char[] endpointPassword = {'a', 'b', 'c', 'd', st.charAt(0), 'e', 'f', 'g', 'h', 'i', 'j', 'k'};
- byte[] userNamePasswordByteArray = (endpointUsername + ":" + endpointPassword).getBytes();
+ byte[] userNamePasswordByteArray = (endpointUsername + ":" + String.valueOf(endpointPassword)).getBytes();
String encodedUserNamePassword = DatatypeConverter.printBase64Binary(userNamePasswordByteArray);
APICreationRequestBean apiCreationRequestBean =
new APICreationRequestBean(API_NAME, API_CONTEXT, API_VERSION_1_0_0, providerName, new URL(apiEndPointUrl));
@@ -146,7 +140,7 @@ public void testInvokeGETResourceWithSecuredEndPointComplexPassword(String st) t
apiCreationRequestBean.setVisibility("public");
apiCreationRequestBean.setEndpointType("secured");
apiCreationRequestBean.setEpUsername(endpointUsername);
- apiCreationRequestBean.setEpPassword(String.valueOf(endpointPassword));
+ apiCreationRequestBean.setEpPassword(URLEncoder.encode(String.valueOf(endpointPassword), "UTF-8"));
//Update API with Edited information
HttpResponse updateAPIHTTPResponse = apiPublisherClientUser1.updateAPI(apiCreationRequestBean);
assertEquals(updateAPIHTTPResponse.getResponseCode(), HTTP_RESPONSE_CODE_OK, "Update APi with new Resource " +
@@ -154,7 +148,7 @@ public void testInvokeGETResourceWithSecuredEndPointComplexPassword(String st) t
assertEquals(updateAPIHTTPResponse.getData(), "{\"error\" : false}", "Update APi with new Resource information fail");
//Send GET request
HttpResponse httpResponseGet =
- HttpRequestUtil.doGet(GATEWAY_WEB_APP_URL + API_CONTEXT + "/" + API_VERSION_1_0_0 + "/sec",
+ HttpRequestUtil.doGet(gatewayWebAppUrl + API_CONTEXT + "/" + API_VERSION_1_0_0 + "/sec",
requestHeadersGet);
assertEquals(httpResponseGet.getResponseCode(), HTTP_RESPONSE_CODE_OK, "Invocation fails for GET request for " +
"endpoint type secured. username:" + endpointUsername + " password:" + String.valueOf(endpointPassword));
@@ -164,6 +158,13 @@ public void testInvokeGETResourceWithSecuredEndPointComplexPassword(String st) t
String.valueOf(endpointPassword));
}
+ @AfterClass(alwaysRun = true)
+ public void cleanUpArtifacts() throws APIManagerIntegrationTestException, XPathExpressionException {
+ apiStoreClientUser1.removeApplication(APPLICATION_NAME);
+ deleteAPI(apiIdentifier, apiPublisherClientUser1);
+
+ }
+
@DataProvider(name = "SymbolCharacters")
public static Object[][] getSymbolCharacters() {
diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/ChangeResourceTierAndTestInvokingTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/ChangeResourceTierAndTestInvokingTestCase.java
index 0dac98ca48..139181a4bf 100644
--- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/ChangeResourceTierAndTestInvokingTestCase.java
+++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/ChangeResourceTierAndTestInvokingTestCase.java
@@ -41,15 +41,16 @@
*/
public class ChangeResourceTierAndTestInvokingTestCase extends APIManagerLifecycleBaseTest {
- private static final String API_NAME = "APILifeCycleTestAPI";
- private static final String API_CONTEXT = "testAPI";
- private static final String API_TAGS = "youtube, video, media";
- private static final String API_END_POINT_URL = "http://gdata.youtube.com/feeds/api/standardfeeds";
+ private static final String API_NAME = "ChangeResourceTierAndTestInvokingTest";
+ private static final String API_CONTEXT = "ChangeResourceTierAndTestInvoking";
+ private static final String API_TAGS = "testTag1, testTag2, testTag3";
private static final String API_DESCRIPTION = "This is test API create by API manager integration test";
- private static final String API_END_POINT_METHOD = "/most_popular";
- private static final String API_RESPONSE_DATA = " requestHeaders;
@@ -60,11 +61,11 @@ public class ChangeResourceTierAndTestInvokingTestCase extends APIManagerLifecyc
@BeforeClass(alwaysRun = true)
public void initialize() throws Exception {
super.init();
+ apiEndPointUrl = gatewayUrls.getWebAppURLHttp() + API_END_POINT_POSTFIX_URL;
providerName = publisherContext.getContextTenant().getContextUser().getUserName();
apiCreationRequestBean =
new APICreationRequestBean(API_NAME, API_CONTEXT, API_VERSION_1_0_0, providerName,
- new URL(API_END_POINT_URL));
-
+ new URL(apiEndPointUrl));
apiCreationRequestBean.setTags(API_TAGS);
apiCreationRequestBean.setDescription(API_DESCRIPTION);
String publisherURLHttp = publisherUrls.getWebAppURLHttp();
@@ -93,15 +94,13 @@ public void testInvokingWithAPIGoldTierApplicationGoldResourceUnlimited() throws
//Create publish and subscribe a API
APIIdentifier apiIdentifier = new APIIdentifier(providerName, API_NAME, API_VERSION_1_0_0);
apiIdentifier.setTier(TIER_GOLD);
-
createPublishAndSubscribeToAPI(
apiIdentifier, apiCreationRequestBean, apiPublisherClientUser1, apiStoreClientUser1, APPLICATION_NAME);
-
//get access token
String accessToken = generateApplicationKeys(apiStoreClientUser1, APPLICATION_NAME).getAccessToken();
-
// Create requestHeaders
requestHeaders = new HashMap();
+ requestHeaders.put("accept", "text/xml");
requestHeaders.put("Authorization", "Bearer " + accessToken);
long startTime = System.currentTimeMillis();
long currentTime;
@@ -109,7 +108,7 @@ public void testInvokingWithAPIGoldTierApplicationGoldResourceUnlimited() throws
currentTime = System.currentTimeMillis();
//Invoke API
HttpResponse invokeResponse =
- HttpRequestUtil.doGet(GATEWAY_WEB_APP_URL + API_CONTEXT + "/" + API_VERSION_1_0_0 +
+ HttpRequestUtil.doGet(gatewayWebAppUrl + API_CONTEXT + "/" + API_VERSION_1_0_0 +
API_END_POINT_METHOD, requestHeaders);
assertEquals(invokeResponse.getResponseCode(), HTTP_RESPONSE_CODE_OK,
"Response code mismatched. Invocation attempt:" + invocationCount + " failed during :" +
@@ -119,13 +118,10 @@ public void testInvokingWithAPIGoldTierApplicationGoldResourceUnlimited() throws
"Response data mismatched. Invocation attempt:" + invocationCount + " failed during :" +
(currentTime - startTime) + " milliseconds under Gold API , Gold Application level tier" +
" and Unlimited Resource tier");
-
}
currentTime = System.currentTimeMillis();
-
-
- HttpResponse invokeResponse = HttpRequestUtil.doGet(GATEWAY_WEB_APP_URL + API_CONTEXT + "/" + API_VERSION_1_0_0 +
+ HttpResponse invokeResponse = HttpRequestUtil.doGet(gatewayWebAppUrl + API_CONTEXT + "/" + API_VERSION_1_0_0 +
API_END_POINT_METHOD, requestHeaders);
assertEquals(invokeResponse.getResponseCode(), HTTP_RESPONSE_CODE_SERVICE_UNAVAILABLE,
"Response code mismatched. Invocation attempt:" + (GOLD_INVOCATION_LIMIT_PER_MIN + 1) +
@@ -136,7 +132,6 @@ public void testInvokingWithAPIGoldTierApplicationGoldResourceUnlimited() throws
" passed during :" + (currentTime - startTime) + " milliseconds under Gold API , " +
"Gold Application level tier and Unlimited Resource tier.");
-
}
@@ -145,17 +140,12 @@ public void testInvokingWithAPIGoldTierApplicationGoldResourceUnlimited() throws
public void testInvokingWithAPIGoldTierApplicationGoldResourceSilver() throws Exception {
Thread.sleep(THROTTLING_UNIT_TIME + THROTTLING_ADDITIONAL_WAIT_TIME);
+ String swagger = " {\"paths\":{\"/*\":{\"get\":{\"x-auth-type\":\"Application \",\"x-throttling-tier\":" +
+ "\"Silver\",\"responses\":{\"200\":\"{}\"}}}},\"swagger\":\"2.0\",\"securityDefinitions\":{\"apim\"" +
+ ":{\"x-wso2-scopes\":[]}},\"info\":{\"licence\":{},\"title\":\"" + API_NAME + "\",\"description\":" +
+ "\"This is test API create by API manager integration test\",\"contact\":{\"email\":null,\"name\":null}," +
+ "\"version\":\"" + API_VERSION_1_0_0 + "\"}}";
- String swagger = "{\"apiVersion\":\"" + API_VERSION_1_0_0 + "\",\"swaggerVersion\":\"2.0\",\"authorizations\":" +
- "{\"oauth2\":{\"scopes\":[],\"type\":\"oauth2\"}},\"apis\":[{\"file\":{\"apiVersion\":\"1.0.0\",\"basePath\":" +
- "\"" + gatewayUrls.getWebAppURLHttp() + "/" + API_CONTEXT + "/" + API_VERSION_1_0_0 + "\",\"resourcePath\":" +
- "\"/default\",\"swaggerVersion\":\"1.2\",\"authorizations\":{\"oauth2\":{\"scopes\":[],\"type\":\"" +
- "oauth2\"}},\"apis\":[{\"path\":\"/*\",\"operations\":[{\"auth_type\":\"Application \",\"throttling_tier\":" +
- "\"Silver\",\"method\":\"GET\",\"parameters\":[]}]}],\"info\":{\"termsOfServiceUrl\":\"\"," +
- "\"title\":\"\",\"description\":\"\",\"license\":\"\",\"contact\":\"\",\"licenseUrl\":\"\"}}," +
- "\"description\":\"\",\"path\":\"/default\"}],\"info\":{\"termsOfServiceUrl\":\"\",\"title\":\"\"," +
- "\"description\":\"This is test API create by API manager integration test\",\"license\":\"\",\"contact\":" +
- "\"\",\"licenseUrl\":\"\"}}";
apiPublisherClientUser1.updateResourceOfAPI(providerName, API_NAME, API_VERSION_1_0_0, swagger);
long startTime = System.currentTimeMillis();
long currentTime;
@@ -163,7 +153,7 @@ public void testInvokingWithAPIGoldTierApplicationGoldResourceSilver() throws Ex
currentTime = System.currentTimeMillis();
//Invoke API
HttpResponse invokeResponse =
- HttpRequestUtil.doGet(GATEWAY_WEB_APP_URL + API_CONTEXT + "/" + API_VERSION_1_0_0 +
+ HttpRequestUtil.doGet(gatewayWebAppUrl + API_CONTEXT + "/" + API_VERSION_1_0_0 +
API_END_POINT_METHOD, requestHeaders);
assertEquals(invokeResponse.getResponseCode(), HTTP_RESPONSE_CODE_OK,
"Response code mismatched. Invocation attempt:" + invocationCount + " failed during :" +
@@ -176,9 +166,8 @@ public void testInvokingWithAPIGoldTierApplicationGoldResourceSilver() throws Ex
}
currentTime = System.currentTimeMillis();
- HttpRequestUtil.doGet(GATEWAY_WEB_APP_URL + API_CONTEXT + "/" + API_VERSION_1_0_0 +
- API_END_POINT_METHOD, requestHeaders);
- HttpResponse invokeResponse = HttpRequestUtil.doGet(GATEWAY_WEB_APP_URL + API_CONTEXT + "/" + API_VERSION_1_0_0 +
+
+ HttpResponse invokeResponse = HttpRequestUtil.doGet(gatewayWebAppUrl + API_CONTEXT + "/" + API_VERSION_1_0_0 +
API_END_POINT_METHOD, requestHeaders);
assertEquals(invokeResponse.getResponseCode(), HTTP_RESPONSE_CODE_SERVICE_UNAVAILABLE,
"Response code mismatched. Invocation attempt:" + (SILVER_INVOCATION_LIMIT_PER_MIN + 1) +
@@ -195,16 +184,13 @@ public void testInvokingWithAPIGoldTierApplicationGoldResourceSilver() throws Ex
"Resource Tier: Gold.", dependsOnMethods = "testInvokingWithAPIGoldTierApplicationGoldResourceSilver")
public void testInvokingWithAPIGoldTierApplicationGoldResourceGold() throws Exception {
Thread.sleep(THROTTLING_UNIT_TIME + THROTTLING_ADDITIONAL_WAIT_TIME);
- String swagger = "{\"apiVersion\":\"" + API_VERSION_1_0_0 + "\",\"swaggerVersion\":\"1.2\",\"authorizations\":" +
- "{\"oauth2\":{\"scopes\":[],\"type\":\"oauth2\"}},\"apis\":[{\"file\":{\"apiVersion\":\"1.0.0\",\"basePath\":" +
- "\"" + gatewayUrls.getWebAppURLHttp() + "/" + API_CONTEXT + "/" + API_VERSION_1_0_0 + "\",\"resourcePath\":" +
- "\"/default\",\"swaggerVersion\":\"1.2\",\"authorizations\":{\"oauth2\":{\"scopes\":[],\"type\":\"" +
- "oauth2\"}},\"apis\":[{\"path\":\"/*\",\"operations\":[{\"auth_type\":\"Application \",\"throttling_tier\":" +
- "\"Gold\",\"method\":\"GET\",\"parameters\":[]}]}],\"info\":{\"termsOfServiceUrl\":\"\"," +
- "\"title\":\"\",\"description\":\"\",\"license\":\"\",\"contact\":\"\",\"licenseUrl\":\"\"}}," +
- "\"description\":\"\",\"path\":\"/default\"}],\"info\":{\"termsOfServiceUrl\":\"\",\"title\":\"\"," +
- "\"description\":\"This is test API create by API manager integration test\",\"license\":\"\",\"contact\":" +
- "\"\",\"licenseUrl\":\"\"}}";
+
+ String swagger = " {\"paths\":{\"/*\":{\"get\":{\"x-auth-type\":\"Application \",\"x-throttling-tier\":" +
+ "\"Gold\",\"responses\":{\"200\":\"{}\"}}}},\"swagger\":\"2.0\",\"securityDefinitions\":{\"apim\"" +
+ ":{\"x-wso2-scopes\":[]}},\"info\":{\"licence\":{},\"title\":\"" + API_NAME + "\",\"description\":" +
+ "\"This is test API create by API manager integration test\",\"contact\":{\"email\":null,\"name\":null}," +
+ "\"version\":\"" + API_VERSION_1_0_0 + "\"}}";
+
apiPublisherClientUser1.updateResourceOfAPI(providerName, API_NAME, API_VERSION_1_0_0, swagger);
long startTime = System.currentTimeMillis();
long currentTime;
@@ -212,7 +198,7 @@ public void testInvokingWithAPIGoldTierApplicationGoldResourceGold() throws Exce
currentTime = System.currentTimeMillis();
//Invoke API
HttpResponse invokeResponse =
- HttpRequestUtil.doGet(GATEWAY_WEB_APP_URL + API_CONTEXT + "/" + API_VERSION_1_0_0 +
+ HttpRequestUtil.doGet(gatewayWebAppUrl + API_CONTEXT + "/" + API_VERSION_1_0_0 +
API_END_POINT_METHOD, requestHeaders);
assertEquals(invokeResponse.getResponseCode(), HTTP_RESPONSE_CODE_OK,
"Response code mismatched. Invocation attempt:" + invocationCount + " failed during :" +
@@ -224,7 +210,7 @@ public void testInvokingWithAPIGoldTierApplicationGoldResourceGold() throws Exce
" and Gold Resource tier");
}
currentTime = System.currentTimeMillis();
- HttpResponse invokeResponse = HttpRequestUtil.doGet(GATEWAY_WEB_APP_URL + API_CONTEXT + "/" + API_VERSION_1_0_0 +
+ HttpResponse invokeResponse = HttpRequestUtil.doGet(gatewayWebAppUrl + API_CONTEXT + "/" + API_VERSION_1_0_0 +
API_END_POINT_METHOD, requestHeaders);
assertEquals(invokeResponse.getResponseCode(), HTTP_RESPONSE_CODE_SERVICE_UNAVAILABLE,
"Response code mismatched. Invocation attempt:" + (GOLD_INVOCATION_LIMIT_PER_MIN + 1) +
diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/EditAPIAndCheckUpdatedInformationTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/EditAPIAndCheckUpdatedInformationTestCase.java
index f2a8a6b2ee..dc1777e530 100644
--- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/EditAPIAndCheckUpdatedInformationTestCase.java
+++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/EditAPIAndCheckUpdatedInformationTestCase.java
@@ -42,14 +42,15 @@
*/
public class EditAPIAndCheckUpdatedInformationTestCase extends APIManagerLifecycleBaseTest {
- private static final String API_NAME = "APILifeCycleTestAPI";
- private static final String API_CONTEXT = "testAPI";
- private static final String API_TAGS = "youtube, video, media";
- private static final String API_END_POINT_URL = "http://gdata.youtube.com/feeds/api/standardfeeds";
+ private static final String API_NAME = "EditAPIAndCheckUpdatedInformationTest";
+ private static final String API_CONTEXT = "EditAPIAndCheckUpdatedInformation";
+ private static final String API_TAGS = "testTag1, testTag2, testTag3";
private static final String API_DESCRIPTION = "This is test API create by API manager integration test";
private static final String API_VERSION_1_0_0 = "1.0.0";
private static final String NEW_API_TAG = "newTag";
private static final String NEW_API_DESCRIPTION = API_DESCRIPTION + " New Description";
+ private static final String API_END_POINT_POSTFIX_URL = "jaxrs_basic/services/customers/customerservice/";
+ private String apiEndPointUrl;
private String providerName;
private APIIdentifier apiIdentifier;
private APIPublisherRestClient apiPublisherClientUser1;
@@ -59,9 +60,10 @@ public class EditAPIAndCheckUpdatedInformationTestCase extends APIManagerLifecyc
@BeforeClass(alwaysRun = true)
public void initialize() throws APIManagerIntegrationTestException, XPathExpressionException, MalformedURLException {
super.init();
+ apiEndPointUrl = gatewayUrls.getWebAppURLHttp() + API_END_POINT_POSTFIX_URL;
providerName = publisherContext.getContextTenant().getContextUser().getUserName();
apiCreationRequestBean =
- new APICreationRequestBean(API_NAME, API_CONTEXT, API_VERSION_1_0_0, providerName, new URL(API_END_POINT_URL));
+ new APICreationRequestBean(API_NAME, API_CONTEXT, API_VERSION_1_0_0, providerName, new URL(apiEndPointUrl));
apiCreationRequestBean.setTags(API_TAGS);
apiCreationRequestBean.setDescription(API_DESCRIPTION);
String publisherURLHttp = publisherUrls.getWebAppURLHttp();
diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/EditAPIContextAndCheckAccessibilityTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/EditAPIContextAndCheckAccessibilityTestCase.java
index 5b50355063..e8cb7fa3ce 100644
--- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/EditAPIContextAndCheckAccessibilityTestCase.java
+++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/EditAPIContextAndCheckAccessibilityTestCase.java
@@ -43,15 +43,17 @@
* Edit the API context and check its accessibility.
*/
public class EditAPIContextAndCheckAccessibilityTestCase extends APIManagerLifecycleBaseTest {
- private static final String API_NAME = "APILifeCycleTestAPI";
- private static final String API_CONTEXT = "testAPI";
- private static final String API_TAGS = "youtube, video, media";
- private static final String API_END_POINT_URL = "http://gdata.youtube.com/feeds/api/standardfeeds";
+ private static final String API_NAME = "EditAPIContextAndCheckAccessibilityTest";
+ private static final String API_CONTEXT = "EditAPIContextAndCheckAccessibility";
+ private static final String API_TAGS = "testTag1, testTag2, testTag3";
+
private static final String API_DESCRIPTION = "This is test API create by API manager integration test";
- private static final String API_END_POINT_METHOD = "/most_popular";
- private static final String API_RESPONSE_DATA = " requestHeaders;
@@ -63,9 +65,10 @@ public class EditAPIContextAndCheckAccessibilityTestCase extends APIManagerLifec
@BeforeClass(alwaysRun = true)
public void initialize() throws APIManagerIntegrationTestException, XPathExpressionException, MalformedURLException {
super.init();
+ apiEndPointUrl = gatewayUrls.getWebAppURLHttp() + API_END_POINT_POSTFIX_URL;
providerName = publisherContext.getContextTenant().getContextUser().getUserName();
apiCreationRequestBean = new APICreationRequestBean(API_NAME, API_CONTEXT, API_VERSION_1_0_0, providerName,
- new URL(API_END_POINT_URL));
+ new URL(apiEndPointUrl));
apiCreationRequestBean.setTags(API_TAGS);
apiCreationRequestBean.setDescription(API_DESCRIPTION);
@@ -95,10 +98,11 @@ public void testInvokeAPIBeforeChangeAPIContext() throws APIManagerIntegrationTe
String accessToken = generateApplicationKeys(apiStoreClientUser1, APPLICATION_NAME).getAccessToken();
// Create requestHeaders
requestHeaders = new HashMap();
+ requestHeaders.put("accept", "text/xml");
requestHeaders.put("Authorization", "Bearer " + accessToken);
//Invoke old version
HttpResponse oldVersionInvokeResponse =
- HttpRequestUtil.doGet(GATEWAY_WEB_APP_URL + API_CONTEXT + "/" + API_VERSION_1_0_0 +
+ HttpRequestUtil.doGet(gatewayWebAppUrl + API_CONTEXT + "/" + API_VERSION_1_0_0 +
API_END_POINT_METHOD, requestHeaders);
assertEquals(oldVersionInvokeResponse.getResponseCode(), HTTP_RESPONSE_CODE_OK,
"Response code mismatched when invoke api before change the context");
@@ -114,7 +118,7 @@ public void testEditAPIContext() throws APIManagerIntegrationTestException, Malf
//Create the API Request with new context
newContext = "new" + API_CONTEXT;
apiCreationRequestBean = new APICreationRequestBean(API_NAME, newContext, API_VERSION_1_0_0,
- providerName, new URL(API_END_POINT_URL));
+ providerName, new URL(apiEndPointUrl));
apiCreationRequestBean.setTags(API_TAGS);
apiCreationRequestBean.setDescription(API_DESCRIPTION);
//Update API with Edited information
@@ -132,7 +136,7 @@ public void testEditAPIContext() throws APIManagerIntegrationTestException, Malf
public void testInvokeAPIAfterChangeAPIContextWithOldContext() throws APIManagerIntegrationTestException, IOException {
//Invoke old context
HttpResponse oldVersionInvokeResponse =
- HttpRequestUtil.doGet(GATEWAY_WEB_APP_URL + API_CONTEXT + "/" + API_VERSION_1_0_0 +
+ HttpRequestUtil.doGet(gatewayWebAppUrl + API_CONTEXT + "/" + API_VERSION_1_0_0 +
API_END_POINT_METHOD, requestHeaders);
assertEquals(oldVersionInvokeResponse.getResponseCode(), HTTP_RESPONSE_CODE_NOT_FOUND,
"Response code mismatched when invoke api before changing the context");
@@ -147,7 +151,7 @@ public void testInvokeAPIAfterChangeAPIContextWithOldContext() throws APIManager
public void testInvokeAPIAfterChangeAPIContextWithNewContext() throws APIManagerIntegrationTestException, IOException {
//Invoke new context
HttpResponse oldVersionInvokeResponse =
- HttpRequestUtil.doGet(GATEWAY_WEB_APP_URL + newContext + "/" + API_VERSION_1_0_0 +
+ HttpRequestUtil.doGet(gatewayWebAppUrl + newContext + "/" + API_VERSION_1_0_0 +
API_END_POINT_METHOD, requestHeaders);
assertEquals(oldVersionInvokeResponse.getResponseCode(), HTTP_RESPONSE_CODE_OK,
"Response code mismatched when invoke api after changing the context");
diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/EditTiersXMLAndVerifyInPublisherTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/EditTiersXMLAndVerifyInPublisherTestCase.java
index 79e0258618..9a3029dfa5 100644
--- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/EditTiersXMLAndVerifyInPublisherTestCase.java
+++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/EditTiersXMLAndVerifyInPublisherTestCase.java
@@ -43,10 +43,9 @@
* Change the tiers.xml file with new tier added and check the new tier availability in publisher.
*/
public class EditTiersXMLAndVerifyInPublisherTestCase extends APIManagerLifecycleBaseTest {
- private static final String API_NAME = "EditTiersAPI1";
- private static final String API_CONTEXT = "EditTiersAPI1";
- private static final String API_TAGS = "youtube, video, media";
- private static final String API_END_POINT_URL = "http://gdata.youtube.com/feeds/api/standardfeeds";
+ private static final String API_NAME = "EditTiersXMLAndVerifyInPublisherTest";
+ private static final String API_CONTEXT = "EditTiersXMLAndVerifyInPublisher";
+ private static final String API_TAGS = "testTag1, testTag2, testTag3";
private static final String API_DESCRIPTION = "This is test API create by API manager integration test";
private static final String API_VERSION_1_0_0 = "1.0.0";
private static final String TIER_XML_REG_CONFIG_LOCATION = "/_system/governance/apimgt/applicationdata/tiers.xml";
@@ -54,6 +53,8 @@ public class EditTiersXMLAndVerifyInPublisherTestCase extends APIManagerLifecycl
private static final String TIER_PERMISSION_PAGE_TIER_PLATINUM = "Platinum | ";
private static final String TIER_MANAGE_PAGE_TIER_GOLD = "{ \"value\": \"Gold\", \"text\": \"Gold\" }";
private static final String TIER_MANAGE_PAGE_TIER_PLATINUM = "{ \"value\": \"Platinum\", \"text\": \"Platinum\" }";
+ private static final String API_END_POINT_POSTFIX_URL = "jaxrs_basic/services/customers/customerservice/";
+ private String apiEndPointUrl;
private String providerName;
private APICreationRequestBean apiCreationRequestBean;
private APIIdentifier apiIdentifier;
@@ -67,10 +68,11 @@ public class EditTiersXMLAndVerifyInPublisherTestCase extends APIManagerLifecycl
public void initialize() throws APIManagerIntegrationTestException, XPathExpressionException,
RemoteException, ResourceAdminServiceExceptionException, MalformedURLException {
super.init();
+ apiEndPointUrl = gatewayUrls.getWebAppURLHttp() + API_END_POINT_POSTFIX_URL;
providerName = publisherContext.getContextTenant().getContextUser().getUserName();
apiCreationRequestBean =
new APICreationRequestBean(API_NAME, API_CONTEXT, API_VERSION_1_0_0, providerName,
- new URL(API_END_POINT_URL));
+ new URL(apiEndPointUrl));
apiCreationRequestBean.setTags(API_TAGS);
apiCreationRequestBean.setDescription(API_DESCRIPTION);
String publisherURLHttp = publisherUrls.getWebAppURLHttp();
diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/UsersAndDocsInAPIOverviewTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/UsersAndDocsInAPIOverviewTestCase.java
index 82a7c514de..affb73bfa3 100644
--- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/UsersAndDocsInAPIOverviewTestCase.java
+++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/UsersAndDocsInAPIOverviewTestCase.java
@@ -40,14 +40,15 @@
* tab should show the correct information about subscribed uses.
*/
public class UsersAndDocsInAPIOverviewTestCase extends APIManagerLifecycleBaseTest {
- private static final String API_NAME = "UsersAndDocsAPI1";
- private static final String API_CONTEXT = "UsersAndDocsAPI1";
- private static final String API_TAGS = "youtube, video, media";
- private static final String API_END_POINT_URL = "http://gdata.youtube.com/feeds/api/standardfeeds";
+ private static final String API_NAME = "UsersAndDocsInAPIOverviewTest";
+ private static final String API_CONTEXT = "UsersAndDocsInAPIOverview";
+ private static final String API_TAGS = "testTag1, testTag2, testTag3";
private static final String API_DESCRIPTION = "This is test API create by API manager integration test";
private static final String API_VERSION_1_0_0 = "1.0.0";
private static final String USER_KEY_USER2 = "userKey1";
private static final String APPLICATION_NAME = "UsersAndDocsInAPIOverviewTestCase";
+ private static final String API_END_POINT_POSTFIX_URL = "jaxrs_basic/services/customers/customerservice/";
+ private String apiEndPointUrl;
private String providerName;
private APIIdentifier apiIdentifier;
private APIPublisherRestClient apiPublisherClientUser1;
@@ -58,9 +59,10 @@ public class UsersAndDocsInAPIOverviewTestCase extends APIManagerLifecycleBaseTe
@BeforeClass(alwaysRun = true)
public void initialize() throws Exception {
super.init();
+ apiEndPointUrl = gatewayUrls.getWebAppURLHttp() + API_END_POINT_POSTFIX_URL;
providerName = publisherContext.getContextTenant().getContextUser().getUserName();
apiCreationRequestBean = new APICreationRequestBean(API_NAME, API_CONTEXT, API_VERSION_1_0_0, providerName,
- new URL(API_END_POINT_URL));
+ new URL(apiEndPointUrl));
apiCreationRequestBean.setTags(API_TAGS);
apiCreationRequestBean.setDescription(API_DESCRIPTION);
String publisherURLHttp = publisherUrls.getWebAppURLHttp();
diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/AM/lifecycletest/synapseconfig.xml b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/AM/lifecycletest/synapseconfig.xml
index 5ab14f809b..9f254cedd8 100644
--- a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/AM/lifecycletest/synapseconfig.xml
+++ b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/AM/lifecycletest/synapseconfig.xml
@@ -386,8 +386,8 @@
The default main sequence for API manager - Returns 404 Not Found
-
@@ -395,7 +395,7 @@
-
+
diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/testng.xml b/modules/integration/tests-integration/tests-backend/src/test/resources/testng.xml
index d6d1dab43c..39a6df9542 100755
--- a/modules/integration/tests-integration/tests-backend/src/test/resources/testng.xml
+++ b/modules/integration/tests-integration/tests-backend/src/test/resources/testng.xml
@@ -30,41 +30,35 @@
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
-
-
-
-
-
-
-
+
+
-
-
-
-
-
+
+
-
-
-
+
+
+
+
+
+
+
+
+
diff --git a/pom.xml b/pom.xml
index 62025ed1b9..9893f38247 100644
--- a/pom.xml
+++ b/pom.xml
@@ -512,7 +512,11 @@
org.wso2.am.integration.ui.pages
${apimserver.version}
-
+
+ org.wso2.carbon.deployment
+ org.wso2.carbon.webapp.mgt.stub
+ ${carbon.deployment.version}
+
org.wso2.carbon