Hi,

I have attached a diff file herewith which has test cases and some
improvements to TestUtil class.

This diff contain testcases for following jiras
https://wso2.org/jira/browse/APIMANAGER-3017
https://wso2.org/jira/browse/APIMANAGER-3149
https://wso2.org/jira/browse/APIMANAGER-2957

Modifications done to TestUtil class
Used api name as contextpath (removed hard coded path. otherwise we cannot
create multiple APIs) and JSONParser to check the response status when
creating an API

Thanks

*Dinesh J. Weerakkody*
Software Engineer
WSO2 Inc.
lean | enterprise | middleware
M : +94 727 361788 | E : dine...@wso2.com | W : www.wso2.com
Index: 
1.8.0/modules/integration/tests-ui/src/test/java/org/wso2/carbon/am/integration/ui/APIMANAGER2957EpochTimeTestCase.java
===================================================================
--- 
1.8.0/modules/integration/tests-ui/src/test/java/org/wso2/carbon/am/integration/ui/APIMANAGER2957EpochTimeTestCase.java
     (revision 0)
+++ 
1.8.0/modules/integration/tests-ui/src/test/java/org/wso2/carbon/am/integration/ui/APIMANAGER2957EpochTimeTestCase.java
     (working copy)
@@ -0,0 +1,118 @@
+/*
+*Copyright (c) 2005-2014, 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.carbon.am.integration.ui;
+
+import org.apache.http.protocol.HttpContext;
+import org.openqa.selenium.Alert;
+import org.openqa.selenium.By;
+import org.openqa.selenium.NoAlertPresentException;
+import org.openqa.selenium.NoSuchElementException;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.support.ui.ExpectedConditions;
+import org.openqa.selenium.support.ui.WebDriverWait;
+import org.testng.Assert;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+import org.wso2.carbon.am.integration.ui.util.TestUtil;
+import org.wso2.carbon.automation.core.BrowserManager;
+import org.wso2.carbon.automation.core.ProductConstant;
+
+import java.util.concurrent.TimeUnit;
+import java.util.regex.Pattern;
+
+import static org.testng.Assert.assertTrue;
+
+public class APIMANAGER2957EpochTimeTestCase extends AMIntegrationUiTestBase {
+    private WebDriver driver;
+    private boolean acceptNextAlert = true;
+    private StringBuffer verificationErrors = new StringBuffer();
+
+    private static final String TEST_DATA_API_NAME = "EpochAPI";
+    private static final String TEST_DATA_API_VERSION = "1.0.0";
+    private static final String TEST_DATA_API_TIER = "Unlimited";
+    private static final String TEST_DATA_APP_NAME = "DefaultApplication";
+
+    @BeforeClass(alwaysRun = true)
+    public void init() throws Exception {
+        super.init(0);
+        driver = BrowserManager.getWebDriver();
+        driver.get(getLoginURL(ProductConstant.AM_SERVER_NAME));
+
+        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
+    }
+
+    @Test(groups = "wso2.am", description = "This method adds and publishes 
the Test API in carbon.super store")
+    public void testCreatePublishAndSubscribeAPI() throws Exception {
+
+        // login to publisher and create new API
+        String publisherURL = getPublisherURL(ProductConstant.AM_SERVER_NAME);
+        HttpContext httpContext = TestUtil.login(userInfo.getUserName(), 
userInfo.getPassword(), publisherURL);
+        assertTrue(TestUtil.addAPI(userInfo.getUserName(), TEST_DATA_API_NAME, 
TEST_DATA_API_VERSION, httpContext, publisherURL));
+        assertTrue(TestUtil.publishAPI(userInfo.getUserName(), 
TEST_DATA_API_NAME, TEST_DATA_API_VERSION, httpContext, publisherURL));
+
+        // login to store and subscribe to API
+        String storeURL = getStoreURL(ProductConstant.AM_SERVER_NAME);
+        httpContext = TestUtil.login(userInfo.getUserName(), 
userInfo.getPassword(), storeURL);
+        assertTrue(TestUtil.addSubscription(userInfo.getUserName(), 
TEST_DATA_API_NAME, TEST_DATA_API_VERSION, TEST_DATA_API_TIER, 
TEST_DATA_APP_NAME, httpContext, storeURL));
+
+        System.out.println("API Create and Publish test case is completed ");
+    }
+
+    @Test(groups = "wso2.am", description = "Check time conversion from epoch 
to human readable version", dependsOnMethods = 
"testCreatePublishAndSubscribeAPI")
+    public void testFIDELITYDEV86EpochTimeTestCase() throws Exception {
+        // login to publisher
+        driver.get(getPublisherURL(ProductConstant.AM_SERVER_NAME) + 
"/site/pages/login.jag");
+        WebDriverWait wait = new WebDriverWait(driver, 30);
+        wait.until(ExpectedConditions.visibilityOfElementLocated(
+                By.id("username")));
+        driver.findElement(By.id("username")).clear();
+        driver.findElement(By.id("username")).sendKeys(userInfo.getUserName());
+        driver.findElement(By.id("pass")).clear();
+        driver.findElement(By.id("pass")).sendKeys(userInfo.getPassword());
+        driver.findElement(By.id("loginButton")).click();
+        driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
+        // wait until load the page
+        wait.until(ExpectedConditions.visibilityOfElementLocated(
+                By.linkText("Browse")));
+        // Click browse API and wait
+        driver.findElement(By.linkText("Browse")).click();
+        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
+        // clieck user link and wait
+        driver.findElement(By.id("noOfUsers")).click();
+        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
+
+        // validate date format
+        try {
+            // Regex : check is there at least 2 characters such as Mon, AM.
+            
Assert.assertTrue(Pattern.compile(".*[a-zA-Z]{2}.*").matcher(driver.findElement(By.xpath("//tbody[@id='userList']/tr[1]/td[2]")).getText()).find());
+        } catch (Error e) {
+            verificationErrors.append(e.toString());
+        }
+    }
+
+    @AfterClass(alwaysRun = true)
+    public void tearDown() throws Exception {
+        driver.quit();
+        String verificationErrorString = verificationErrors.toString();
+        if (!"".equals(verificationErrorString)) {
+            Assert.fail(verificationErrorString);
+        }
+    }
+}
Index: 
1.8.0/modules/integration/tests-ui/src/test/java/org/wso2/carbon/am/integration/ui/APIMANAGER3017ExternalStoreLifeCycleTestCase.java
===================================================================
--- 
1.8.0/modules/integration/tests-ui/src/test/java/org/wso2/carbon/am/integration/ui/APIMANAGER3017ExternalStoreLifeCycleTestCase.java
        (revision 0)
+++ 
1.8.0/modules/integration/tests-ui/src/test/java/org/wso2/carbon/am/integration/ui/APIMANAGER3017ExternalStoreLifeCycleTestCase.java
        (working copy)
@@ -0,0 +1,196 @@
+/*
+*Copyright (c) 2005-2014, 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.carbon.am.integration.ui;
+
+import org.apache.http.protocol.HttpContext;
+import org.openqa.selenium.By;
+import org.openqa.selenium.NoSuchElementException;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.support.ui.ExpectedConditions;
+import org.openqa.selenium.support.ui.Select;
+import org.openqa.selenium.support.ui.WebDriverWait;
+import org.testng.Assert;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+import org.wso2.carbon.am.integration.ui.util.TestUtil;
+import 
org.wso2.carbon.automation.api.clients.registry.ResourceAdminServiceClient;
+import org.wso2.carbon.automation.core.BrowserManager;
+import org.wso2.carbon.automation.core.ProductConstant;
+
+import java.util.concurrent.TimeUnit;
+
+import static org.testng.Assert.assertTrue;
+
+public class APIMANAGER3017ExternalStoreLifeCycleTestCase extends 
AMIntegrationUiTestBase {
+    public static final String BLOCKED = "BLOCKED", PUBLISHED = "PUBLISHED";
+    private WebDriver driver;
+    private String TEST_DATA_TENANT_DOMAIN = "apim3017.com",
+            TEST_DATA_TENANT_FIRST_NAME = "admin",
+            TEST_DATA_TENANT_LAST_NAME = "admin",
+            TEST_DATA_ADMIN_USER_NAME = "admin",
+            TEST_DATA_PASSWORD = "123456",
+            TEST_DATA_EMAIL = "ad...@apim3017.com",
+            TEST_DATA_API_NAME = "APIM3017API",
+            TEST_DATA_API_VERSION = "1.0.0";
+    private String STORE_URL;
+
+    @BeforeClass(alwaysRun = true)
+    protected void init() throws Exception {
+        super.init(0);
+        STORE_URL = getStoreURL(ProductConstant.AM_SERVER_NAME);
+
+        ResourceAdminServiceClient resourceAdminServiceStub = new 
ResourceAdminServiceClient(amServer.getBackEndUrl()
+                , amServer.getSessionCookie());
+
+        String configuration = "<ExternalAPIStores>\n" +
+                               "    <StoreURL>" + STORE_URL + "</StoreURL>\n" +
+                               "    <ExternalAPIStore id=\"Store1\" 
type=\"wso2\">\n" +
+                               "        <DisplayName>Store1</DisplayName>\n" +
+                               "        <Endpoint>" + STORE_URL + 
"</Endpoint>\n" +
+                               "        <Username>" + TEST_DATA_EMAIL + 
"</Username>\n" +
+                               "        <Password>" + TEST_DATA_PASSWORD + 
"</Password>\n" +
+                               "    </ExternalAPIStore>\n" +
+                               "</ExternalAPIStores>";
+
+        resourceAdminServiceStub.updateTextContent
+                
("/_system/governance/apimgt/externalstores/external-api-stores.xml", 
configuration);
+
+        driver = BrowserManager.getWebDriver();
+    }
+
+    public void generateTenant() throws Exception {
+        WebDriverWait wait = new WebDriverWait(driver, 10);
+
+        driver.get(getLoginURL(ProductConstant.AM_SERVER_NAME));
+
+        // wait until load the page
+        
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("txtUserName")));
+
+        driver.findElement(By.id("txtUserName")).clear();
+        driver.findElement(By.id("txtUserName")).sendKeys("admin");
+        driver.findElement(By.id("txtPassword")).clear();
+        driver.findElement(By.id("txtPassword")).sendKeys("admin");
+        driver.findElement(By.cssSelector("input.button")).click();
+
+        // wait until load the page
+        
wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("#menu-panel-button3
 > span")));
+
+        driver.findElement(By.cssSelector("#menu-panel-button3 > 
span")).click();
+        driver.findElement(By.linkText("Add New Tenant")).click();
+        // wait until load the page
+        
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("domain")));
+
+        driver.findElement(By.id("domain")).clear();
+        driver.findElement(By.id("domain")).sendKeys(TEST_DATA_TENANT_DOMAIN);
+        driver.findElement(By.id("admin-firstname")).clear();
+        
driver.findElement(By.id("admin-firstname")).sendKeys(TEST_DATA_TENANT_FIRST_NAME);
+        driver.findElement(By.id("admin-lastname")).clear();
+        
driver.findElement(By.id("admin-lastname")).sendKeys(TEST_DATA_TENANT_LAST_NAME);
+        driver.findElement(By.id("admin")).clear();
+        driver.findElement(By.id("admin")).sendKeys(TEST_DATA_ADMIN_USER_NAME);
+        driver.findElement(By.id("admin-password")).clear();
+        
driver.findElement(By.id("admin-password")).sendKeys(TEST_DATA_PASSWORD);
+        driver.findElement(By.id("admin-password-repeat")).clear();
+        
driver.findElement(By.id("admin-password-repeat")).sendKeys(TEST_DATA_PASSWORD);
+        driver.findElement(By.id("admin-email")).clear();
+        driver.findElement(By.id("admin-email")).sendKeys(TEST_DATA_EMAIL);
+        driver.findElement(By.cssSelector("input.button")).click();
+        driver.findElement(By.cssSelector("button[type=\"button\"]")).click();
+    }
+
+    public void testCreateAndPublishAPI() throws Exception {
+        String loginURL = getPublisherURL(ProductConstant.AM_SERVER_NAME);
+        HttpContext httpContext = TestUtil.login(userInfo.getUserName(), 
userInfo.getPassword(), loginURL);
+
+        assertTrue(TestUtil.addAPI(userInfo.getUserName(), TEST_DATA_API_NAME, 
TEST_DATA_API_VERSION, httpContext, loginURL));
+        Thread.sleep(3000);
+        assertTrue(TestUtil.publishAPI(userInfo.getUserName(), 
TEST_DATA_API_NAME, TEST_DATA_API_VERSION, httpContext, loginURL));
+
+        System.out.println("API Create and Publish test case is completed ");
+    }
+
+    @Test(groups = "wso2.am")
+    public void testNotificationWhenExternalStoresAvailable() throws Exception 
{
+        WebDriverWait wait = new WebDriverWait(driver, 10);
+        // create new tenant
+        generateTenant();
+
+        testCreateAndPublishAPI();
+
+        //login to publisher
+        driver.get(getPublisherURL(ProductConstant.AM_SERVER_NAME) + 
"/site/pages/login.jag");
+        // wait until load the page
+        
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("username")));
+        driver.findElement(By.id("username")).clear();
+        driver.findElement(By.id("username")).sendKeys("admin");
+        driver.findElement(By.id("pass")).clear();
+        driver.findElement(By.id("pass")).sendKeys("admin");
+        driver.findElement(By.id("loginButton")).click();
+
+        // wait until load the page
+        
wait.until(ExpectedConditions.visibilityOfElementLocated(By.linkText("Browse")));
+
+        driver.findElement(By.linkText("Browse")).click();
+        // wait until display APIs and select first API
+        wait.until(ExpectedConditions.visibilityOfElementLocated(
+                By.cssSelector(".thumbnail > a:nth-child(1)")));
+        driver.findElement(By.cssSelector(".thumbnail > 
a:nth-child(1)")).click();
+
+        // publish to external store
+        
wait.until(ExpectedConditions.visibilityOfElementLocated(By.linkText("External 
API Stores")));
+        driver.findElement(By.linkText("External API Stores")).click();
+        driver.findElement(By.id("store0.0")).click();
+        driver.findElement(By.id("updateButtonExt")).click();
+        // wait until doc link appear in API info page
+        wait.until(ExpectedConditions.visibilityOfElementLocated(
+                By.cssSelector("ul.nav:nth-child(2) > li:nth-child(5) > 
a:nth-child(1)")));
+
+        // change status in lifecycle tab
+        driver.findElement(By.cssSelector("#lifecyclesLink")).click();
+        new 
Select(driver.findElement(By.id("editStatus"))).selectByVisibleText(BLOCKED);
+        driver.findElement(By.id("updateStateButton")).click();
+
+        // Navigate to life cycle page and check for notification
+        driver.findElement(By.linkText("Browse")).click();
+        // wait until display APIs and select first API
+        wait.until(ExpectedConditions.visibilityOfElementLocated(
+                By.cssSelector(".thumbnail > a:nth-child(1)")));
+        driver.findElement(By.cssSelector(".thumbnail > 
a:nth-child(1)")).click();
+        
wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("#lifecyclesLink")));
+        driver.findElement(By.cssSelector("#lifecyclesLink")).click();
+
+        // check whether notification is there or not
+        
Assert.assertTrue(isElementPresent(By.id("removeFromExternalStoresMsg")));
+    }
+
+    private boolean isElementPresent(By by) {
+        try {
+            driver.findElement(by);
+            return true;
+        } catch (NoSuchElementException e) {
+            return false;
+        }
+    }
+
+    @AfterClass(alwaysRun = true)
+    public void tearDown() throws Exception {
+        driver.quit();
+    }
+}
Index: 
1.8.0/modules/integration/tests-ui/src/test/java/org/wso2/carbon/am/integration/ui/APIMANAGER3149SSOLogin.java
===================================================================
--- 
1.8.0/modules/integration/tests-ui/src/test/java/org/wso2/carbon/am/integration/ui/APIMANAGER3149SSOLogin.java
      (revision 0)
+++ 
1.8.0/modules/integration/tests-ui/src/test/java/org/wso2/carbon/am/integration/ui/APIMANAGER3149SSOLogin.java
      (working copy)
@@ -0,0 +1,80 @@
+/*
+*Copyright (c) 2005-2014, 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.carbon.am.integration.ui;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.support.ui.ExpectedConditions;
+import org.openqa.selenium.support.ui.WebDriverWait;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+import org.wso2.carbon.automation.core.BrowserManager;
+import org.wso2.carbon.automation.core.ProductConstant;
+import org.wso2.carbon.automation.core.annotations.ExecutionEnvironment;
+import org.wso2.carbon.automation.core.annotations.SetEnvironment;
+
+/*
+  This test should be run with following configurations
+  > Configure AM and IS to use in SSO mode
+  > Create a new tenant in IS side
+  > Create new user role and user in IS side
+  > User should be able to login to publisher just after user creation in IS 
side
+ */
+public class APIMANAGER3149SSOLogin extends AMIntegrationUiTestBase {
+    private WebDriver driver;
+
+    @BeforeClass(alwaysRun = true)
+    protected void init() throws Exception {
+        super.init(0);
+        driver = BrowserManager.getWebDriver();
+    }
+
+    @Test(groups = "wso2.am")
+    @SetEnvironment(executionEnvironments = 
{ExecutionEnvironment.platform_user})
+    public void loginToPublisher() throws Exception {
+        WebDriverWait wait = new WebDriverWait(driver, 10);
+        //login to publisher
+        driver.get(getPublisherURL(ProductConstant.AM_SERVER_NAME) + 
"/site/pages/login.jag");
+        // wait until load the page
+        
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("username")));
+        driver.findElement(By.id("username")).clear();
+        driver.findElement(By.id("username")).sendKeys(userInfo.getUserName());
+
+        // this is the password field in IS sso login page
+        if(driver.findElement(By.id("password"))!=null){
+            driver.findElement(By.id("password")).clear();
+            
driver.findElement(By.id("password")).sendKeys(userInfo.getPassword());
+        }else{
+            driver.findElement(By.id("pass")).clear();
+            driver.findElement(By.id("pass")).sendKeys(userInfo.getPassword());
+        }
+
+        driver.findElement(By.cssSelector(".btn")).click();
+
+        // wait until load the page
+        
wait.until(ExpectedConditions.visibilityOfElementLocated(By.linkText("Add")));
+        // if element present, test it successful
+    }
+
+    @AfterClass(alwaysRun = true)
+    public void tearDown() throws Exception {
+        driver.quit();
+    }
+}
Index: 
1.8.0/modules/integration/tests-ui/src/test/java/org/wso2/carbon/am/integration/ui/APIVersoinStatTestCase.java
===================================================================
--- 
1.8.0/modules/integration/tests-ui/src/test/java/org/wso2/carbon/am/integration/ui/APIVersoinStatTestCase.java
      (revision 210399)
+++ 
1.8.0/modules/integration/tests-ui/src/test/java/org/wso2/carbon/am/integration/ui/APIVersoinStatTestCase.java
      (working copy)
@@ -18,13 +18,16 @@
 
 package org.wso2.carbon.am.integration.ui;
 
+import org.apache.http.protocol.HttpContext;
 import org.openqa.selenium.By;
 import org.openqa.selenium.WebDriver;
 import org.openqa.selenium.WebElement;
 import org.openqa.selenium.support.ui.ExpectedConditions;
 import org.openqa.selenium.support.ui.WebDriverWait;
+import org.testng.annotations.AfterClass;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
+import org.wso2.carbon.am.integration.ui.util.TestUtil;
 import org.wso2.carbon.automation.core.BrowserManager;
 import org.wso2.carbon.automation.core.ProductConstant;
 
@@ -35,7 +38,7 @@
 public class APIVersoinStatTestCase extends AMIntegrationUiTestBase {
     private WebDriver driver;
 
-    private static final String TEST_DATA_API_NAME = "SubAvailabilityTestAPI";
+    private static final String TEST_DATA_API_NAME = "VersionTestAPI";
     private static final String TEST_DATA_API_VERSION = "1.0.0";
 
     @BeforeClass(alwaysRun = true)
@@ -45,7 +48,18 @@
         driver.get(getLoginURL(ProductConstant.AM_SERVER_NAME));
     }
 
-    @Test(groups = "wso2.am", description = "verify Bam api stats visibility")
+    @Test(groups = "wso2.am")
+    public void testCreateAndPublishAPI() throws Exception {
+        String loginURL = getPublisherURL(ProductConstant.AM_SERVER_NAME);
+        HttpContext httpContext = TestUtil.login(userInfo.getUserName(), 
userInfo.getPassword(), loginURL);
+
+        assertTrue(TestUtil.addAPI(userInfo.getUserName(), TEST_DATA_API_NAME, 
TEST_DATA_API_VERSION, httpContext, loginURL));
+        assertTrue(TestUtil.publishAPI(userInfo.getUserName(), 
TEST_DATA_API_NAME, TEST_DATA_API_VERSION, httpContext, loginURL));
+
+        System.out.println("API Create and Publish test case is completed ");
+    }
+
+    @Test(groups = "wso2.am", dependsOnMethods = "testCreateAndPublishAPI", 
description = "verify Bam api stats visibility")
     public void testVersionStats() throws Exception {
 
         driver.get(getPublisherURL(ProductConstant.AM_SERVER_NAME) );
@@ -68,7 +82,7 @@
         driver.findElement(By.id("loginButton")).click();
 
         wait.until(ExpectedConditions.visibilityOfElementLocated(
-                By.className("versionTxt")));
+                By.cssSelector(".version-provider-wrapper")));
         // Go to test API
         driver.navigate().to(getPublisherURL(ProductConstant.AM_SERVER_NAME) + 
"/info?name=" + TEST_DATA_API_NAME
                              + "&version=" + TEST_DATA_API_VERSION + 
"&provider=" + userInfo.getUserName());
@@ -89,7 +103,10 @@
         
assertTrue(driver.findElement(By.xpath("//div[@id=\"versionChart\"]/span")).getText().contains("No
 Data Found"));
         
assertTrue(driver.findElement(By.xpath("//div[@id=\"versionUserChart\"]/span")).getText().contains("No
 Data Found"));
 
-        driver.close();
+    }
 
+    @AfterClass(alwaysRun = true)
+    public void tearDown() throws Exception {
+        driver.quit();
     }
 }
Index: 
1.8.0/modules/integration/tests-ui/src/test/java/org/wso2/carbon/am/integration/ui/SubscriptionAvailabilityTestCase.java
===================================================================
--- 
1.8.0/modules/integration/tests-ui/src/test/java/org/wso2/carbon/am/integration/ui/SubscriptionAvailabilityTestCase.java
    (revision 210399)
+++ 
1.8.0/modules/integration/tests-ui/src/test/java/org/wso2/carbon/am/integration/ui/SubscriptionAvailabilityTestCase.java
    (working copy)
@@ -27,6 +27,7 @@
 import org.openqa.selenium.WebElement;
 import org.openqa.selenium.support.ui.ExpectedConditions;
 import org.openqa.selenium.support.ui.WebDriverWait;
+import org.testng.annotations.AfterClass;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
 import org.wso2.carbon.am.integration.ui.util.TestUtil;
@@ -129,9 +130,11 @@
         assertFalse(driver.getPageSource().contains("subscribe-button"), 
"Subscription availability of " + userInfo.getUserName() + "-" 
                                        + TEST_DATA_API_NAME + "-" + 
TEST_DATA_API_VERSION + " is \'Available to current Tenant only\'. " +
                                                        "Hence Subscribe option 
shouldn't be visible to Tenant " + TEST_DATA_TENANT_DOMAIN);
-        driver.close();
-        
+
        }
 
-
+    @AfterClass(alwaysRun = true)
+    public void tearDown() throws Exception {
+        driver.quit();
+    }
 }
Index: 
1.8.0/modules/integration/tests-ui/src/test/java/org/wso2/carbon/am/integration/ui/util/TestUtil.java
===================================================================
--- 
1.8.0/modules/integration/tests-ui/src/test/java/org/wso2/carbon/am/integration/ui/util/TestUtil.java
       (revision 210399)
+++ 
1.8.0/modules/integration/tests-ui/src/test/java/org/wso2/carbon/am/integration/ui/util/TestUtil.java
       (working copy)
@@ -22,6 +22,8 @@
 import java.util.ArrayList;
 import java.util.List;
 
+import net.minidev.json.JSONObject;
+import net.minidev.json.parser.JSONParser;
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpResponse;
 import org.apache.http.NameValuePair;
@@ -39,7 +41,7 @@
 
 
 public class TestUtil {
-       
+    private static JSONParser JSON_PARSER = new 
JSONParser(JSONParser.MODE_JSON_SIMPLE);
        public boolean createTenant(String adminUserName, String adminPassword, 
String serviceUrl) {
                return true;
        }
@@ -124,7 +126,8 @@
         * @return
         * @throws Exception
         */
-       public static boolean publishAPI(String providerName, String apiName, 
String apiVersion, HttpContext httpContext, String publisherURL) throws 
Exception{
+       public static boolean publishAPI(String providerName, String apiName, 
String apiVersion, HttpContext httpContext,
+                               String publisherURL) throws Exception{
                HttpClient httpclient = new DefaultHttpClient();
                HttpPost httppost = new HttpPost(publisherURL + 
APIMTestConstants.APIPUBLISHER_PUBLISH_URL);
                List<NameValuePair> paramVals = new ArrayList<NameValuePair>();
@@ -142,16 +145,22 @@
         HttpResponse response = httpclient.execute(httppost,httpContext);
         HttpEntity entity = response.getEntity();
         String responseString = EntityUtils.toString(entity, "UTF-8");
-        boolean isError = 
Boolean.parseBoolean(responseString.split(",")[0].split(":")[1].split("}")[0].trim());
-        //If API publishing success
-        if (!isError) {  
-            return true;
 
-        }else{
+        boolean isSuccess= false;
+        if(responseString !=null){
+            Object object= JSON_PARSER.parse(responseString);
+            if(object instanceof JSONObject){
+                Object value = ((JSONObject) object).get("error");
+                if("false".equalsIgnoreCase(value.toString()))
+                    isSuccess=true;
+            }
+        }
+
+        if(!isSuccess){
             String errorMsg = 
responseString.split(",")[1].split(":")[1].split("}")[0].trim();
             throw new Exception("Error while publishing the API- " + errorMsg);
-
         }
+        return isSuccess;
        }
        
        /**
@@ -185,7 +194,7 @@
         params.add(new BasicNameValuePair("https_checked", "https"));
 
         params.add(new BasicNameValuePair("tiersCollection", "Gold"));
-        params.add(new BasicNameValuePair("context", "subsAvailTest"));
+        params.add(new BasicNameValuePair("context", apiName));
 
         params.add(new BasicNameValuePair("resourceCount", "0"));
         params.add(new BasicNameValuePair("uriTemplate-0", "/*"));
Index: 
1.8.0/modules/integration/tests-ui/src/test/resources/testng-server-mgt.xml
===================================================================
--- 1.8.0/modules/integration/tests-ui/src/test/resources/testng-server-mgt.xml 
(revision 210399)
+++ 1.8.0/modules/integration/tests-ui/src/test/resources/testng-server-mgt.xml 
(working copy)
@@ -15,6 +15,9 @@
             <class 
name="org.wso2.carbon.am.integration.ui.SubscriptionAvailabilityTestCase"/>
             <class 
name="org.wso2.carbon.am.integration.ui.APIVersoinStatTestCase"/>
             <class 
name="org.wso2.carbon.am.integration.ui.OAuthConsumerAppsTestCase"/>
+            <class 
name="org.wso2.carbon.am.integration.ui.APIMANAGER2957EpochTimeTestCase" />
+            <class 
name="org.wso2.carbon.am.integration.ui.APIMANAGER3017ExternalStoreLifeCycleTestCase"
 />
+            <class 
name="org.wso2.carbon.am.integration.ui.APIMANAGER3149SSOLogin" />
         </classes>
     </test>
 </suite>
_______________________________________________
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to