-
Notifications
You must be signed in to change notification settings - Fork 787
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #210 from sanethd/master
Add unique API names fro each testcase and removed youtube API dependency
- Loading branch information
Showing
32 changed files
with
619 additions
and
335 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
143 changes: 143 additions & 0 deletions
143
...ommon/admin-clients/src/main/java/org/wso2/am/admin/clients/webapp/WebAppAdminClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<String> getWebAppList(String webAppNameSearchString) throws RemoteException { | ||
List<String> list = new ArrayList<String>(); | ||
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<String> getFaultyWebAppList(String webAppNameSearchString) throws RemoteException { | ||
List<String> list = new ArrayList<String>(); | ||
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; | ||
} | ||
|
||
} |
103 changes: 103 additions & 0 deletions
103
...t-utils/src/main/java/org/wso2/am/integration/test/utils/webapp/WebAppDeploymentUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<String> webAppList; | ||
List<String> 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; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.