Search in sources :

Example 11 with AutomationFrameworkException

use of org.wso2.carbon.automation.engine.exceptions.AutomationFrameworkException in project product-iots by wso2.

the class CarbonServerManagerExtension method generateCoverageReport.

private void generateCoverageReport(File classesDir) throws IOException, AutomationFrameworkException {
    checkJacocoDataFileSizes(FrameworkPathUtil.getJacocoCoverageHome());
    CodeCoverageUtils.executeMerge(FrameworkPathUtil.getJacocoCoverageHome(), FrameworkPathUtil.getCoverageMergeFilePath());
    ReportGenerator reportGenerator = new ReportGenerator(new File(FrameworkPathUtil.getCoverageMergeFilePath()), classesDir, new File(CodeCoverageUtils.getJacocoReportDirectory()), (File) null);
    reportGenerator.create();
    log.info("Jacoco coverage dump file path : " + FrameworkPathUtil.getCoverageDumpFilePath());
    log.info("Jacoco class file path : " + classesDir);
    log.info("Jacoco coverage HTML report path : " + CodeCoverageUtils.getJacocoReportDirectory() + File.separator + "index.html");
}
Also used : ReportGenerator(org.wso2.carbon.automation.engine.frameworkutils.ReportGenerator) File(java.io.File)

Example 12 with AutomationFrameworkException

use of org.wso2.carbon.automation.engine.exceptions.AutomationFrameworkException in project product-iots by wso2.

the class CarbonServerManagerExtension method setUpCarbonHome.

/**
 * Unzip carbon zip file and return the carbon home. Based on the coverage configuration in automation.xml
 * This method will inject jacoco agent to the carbon server startup scripts.
 *
 * @param carbonServerZipFile - Carbon zip file, which should be specified in test module pom
 * @return - carbonHome - carbon home
 * @throws IOException - If pack extraction fails
 */
public synchronized String setUpCarbonHome(String carbonServerZipFile) throws IOException, AutomationFrameworkException {
    if (this.process != null) {
        return this.carbonHome;
    } else {
        int indexOfZip = carbonServerZipFile.lastIndexOf(".zip");
        if (indexOfZip == -1) {
            throw new IllegalArgumentException(carbonServerZipFile + " is not a zip file");
        } else {
            String fileSeparator = File.separator.equals("\\") ? "\\" : "/";
            if (fileSeparator.equals("\\")) {
                carbonServerZipFile = carbonServerZipFile.replace("/", "\\");
            }
            String extractedCarbonDir = carbonServerZipFile.substring(carbonServerZipFile.lastIndexOf(fileSeparator) + 1, indexOfZip);
            FileManipulator.deleteDir(extractedCarbonDir);
            String extractDir = "carbontmp" + System.currentTimeMillis();
            String baseDir = System.getProperty("basedir", ".") + File.separator + "target";
            log.info("Extracting carbon zip file.. ");
            (new ArchiveExtractor()).extractFile(carbonServerZipFile, baseDir + File.separator + extractDir);
            this.carbonHome = (new File(baseDir)).getAbsolutePath() + File.separator + extractDir + File.separator + extractedCarbonDir;
            try {
                this.isCoverageEnable = Boolean.parseBoolean(this.automationContext.getConfigurationValue("//coverage"));
            } catch (XPathExpressionException var8) {
                throw new AutomationFrameworkException("Coverage configuration not found in automation.xml", var8);
            }
            if (this.isCoverageEnable) {
                this.instrumentForCoverage();
            }
            return this.carbonHome;
        }
    }
}
Also used : AutomationFrameworkException(org.wso2.carbon.automation.engine.exceptions.AutomationFrameworkException) XPathExpressionException(javax.xml.xpath.XPathExpressionException) ArchiveExtractor(org.wso2.carbon.automation.extensions.servers.utils.ArchiveExtractor) File(java.io.File)

Example 13 with AutomationFrameworkException

use of org.wso2.carbon.automation.engine.exceptions.AutomationFrameworkException in project product-iots by wso2.

the class IOTServerExtension method initiate.

@Override
public void initiate() throws AutomationFrameworkException {
    try {
        automationContext = new AutomationContext("IOT", TestUserMode.SUPER_TENANT_USER);
        if (getParameters().get(ExtensionConstants.SERVER_STARTUP_PORT_OFFSET_COMMAND) == null) {
            getParameters().put(ExtensionConstants.SERVER_STARTUP_PORT_OFFSET_COMMAND, "0");
        }
        serverManager = new CustomTestServerManager(getAutomationContext(), null, getParameters());
        executionEnvironment = automationContext.getConfigurationValue(ContextXpathConstants.EXECUTION_ENVIRONMENT);
    } catch (XPathExpressionException e) {
        handleException("Error while initiating test environment", e);
    }
}
Also used : AutomationContext(org.wso2.carbon.automation.engine.context.AutomationContext) XPathExpressionException(javax.xml.xpath.XPathExpressionException)

Example 14 with AutomationFrameworkException

use of org.wso2.carbon.automation.engine.exceptions.AutomationFrameworkException in project product-iots by wso2.

the class AnalyticsServerExtension method initiate.

@Override
public void initiate() throws AutomationFrameworkException {
    try {
        automationContext = new AutomationContext("IOT", TestUserMode.SUPER_TENANT_USER);
        if (getParameters().get(ExtensionConstants.SERVER_STARTUP_PORT_OFFSET_COMMAND) == null) {
            getParameters().put(ExtensionConstants.SERVER_STARTUP_PORT_OFFSET_COMMAND, "2");
        }
        serverManager = new CustomTestServerManager(getAutomationContext(), null, getParameters());
        executionEnvironment = automationContext.getConfigurationValue(ContextXpathConstants.EXECUTION_ENVIRONMENT);
    } catch (XPathExpressionException e) {
        handleException("Error while initiating test environment", e);
    }
}
Also used : AutomationContext(org.wso2.carbon.automation.engine.context.AutomationContext) XPathExpressionException(javax.xml.xpath.XPathExpressionException)

Example 15 with AutomationFrameworkException

use of org.wso2.carbon.automation.engine.exceptions.AutomationFrameworkException in project product-iots by wso2.

the class AndroidDeviceManagementAPIJmeterTestCase method listServices.

@Test(description = "Testing the basic android device management API calls", dependsOnMethods = { "permutationTest" })
public void listServices() throws AutomationFrameworkException {
    URL url = Thread.currentThread().getContextClassLoader().getResource("jmeter-scripts" + File.separator + "NewAndroidDeviceManagementAPI.jmx");
    JMeterTest script = new JMeterTest(new File(url.getPath()));
    JMeterTestManager manager = new JMeterTestManager();
    log.info("Running API service test using jmeter scripts");
    manager.runTest(script);
}
Also used : JMeterTest(org.wso2.carbon.automation.extensions.jmeter.JMeterTest) File(java.io.File) URL(java.net.URL) JMeterTestManager(org.wso2.carbon.automation.extensions.jmeter.JMeterTestManager) JMeterTest(org.wso2.carbon.automation.extensions.jmeter.JMeterTest) Test(org.testng.annotations.Test)

Aggregations

Test (org.testng.annotations.Test)15 File (java.io.File)12 URL (java.net.URL)8 JMeterTest (org.wso2.carbon.automation.extensions.jmeter.JMeterTest)8 JMeterTestManager (org.wso2.carbon.automation.extensions.jmeter.JMeterTestManager)8 XPathExpressionException (javax.xml.xpath.XPathExpressionException)7 HttpResponse (org.wso2.carbon.automation.test.utils.http.client.HttpResponse)7 JsonObject (com.google.gson.JsonObject)4 AutomationFrameworkException (org.wso2.carbon.automation.engine.exceptions.AutomationFrameworkException)4 AutomationContext (org.wso2.carbon.automation.engine.context.AutomationContext)3 IOException (java.io.IOException)2 User (org.wso2.carbon.automation.engine.context.beans.User)2 BeforeClass (org.testng.annotations.BeforeClass)1 ReportGenerator (org.wso2.carbon.automation.engine.frameworkutils.ReportGenerator)1 ArchiveExtractor (org.wso2.carbon.automation.extensions.servers.utils.ArchiveExtractor)1 ServerLogReader (org.wso2.carbon.automation.extensions.servers.utils.ServerLogReader)1 LogViewerClient (org.wso2.carbon.integration.common.admin.client.LogViewerClient)1