org.wso2.carbon.automation.engine.exceptions.AutomationFrameworkException Java Examples

The following examples show how to use org.wso2.carbon.automation.engine.exceptions.AutomationFrameworkException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JSONPayloadProperFormatTenantModeTestCase.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
@Test(groups = "wso2.esb", description = "Check whether JSON message formatting works properly in tenant mode")
public void testJSONFormattingInTenantMode() throws MalformedURLException, AutomationFrameworkException {
    String JSON_PAYLOAD = "{\"emails\": [{\"value\": \"[email protected]\"}]}";
    Map<String, String> headers = new HashMap<>();
    headers.put("Content-Type", "application/json");
    HttpResponse response = HttpRequestUtil
            .doPost(new URL("http://localhost:8480/json/payload"), JSON_PAYLOAD, headers);

    //checking whether JSON payload of wrong format is received
    assertFalse(response.getData().equals("{\"emails\":{\"value\":\"[email protected]\"}}"),
            "Incorrect format received!");

    //checking whether JSON payload of correct format is present
    assertTrue(response.getData().equals("{\"emails\": [{\"value\": \"[email protected]\"}]}"),
            "Expected format not received!");
}
 
Example #2
Source File: JSONPayloadXMLSpecialCharEscapeTest.java    From product-ei with Apache License 2.0 6 votes vote down vote up
@Test(groups = "wso2.esb", description = "JSONPayload with XMLSpecialChar Escape Test")
public void JSONPayloadWithXMLSpecialCharEscapeTest()
        throws AxisFault, MalformedURLException, AutomationFrameworkException {

    //json request payload.
    String payload = "<text>{\"chars\" : \"266/W, Simple Text &#60; &#62; &#38;,&#xd;\n" +
            "line2,&#xd;\n" +
            "line 3\"}</text>";

    Reader data = new StringReader(payload);
    Writer writer = new StringWriter();

    String serviceURL = this.getApiInvocationURL("testEnterAPI");

    String response = HttpURLConnectionClient.sendPostRequestAndReadResponse(data,
            new URL(serviceURL), writer, "application/xml");
    assertNotNull(response, "Response is null");
    //should return the response without throwing any errors.
    assertTrue(response.contains("{\"chars\" : \"266/W, Simple Text < > &,\\r\\nline2,\\r\\nline 3\"}"));
}
 
Example #3
Source File: JsonResponseWithCacheTestCase.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
@Test(groups = "wso2.esb", description = "Test cache mediator with  Json response having a single element array", enabled = false)
public void testJsonResponseWithCacheMediator() throws IOException, AutomationFrameworkException {

    Map<String, String> requestHeader = new HashMap<>();
    requestHeader.put("Content-type", "application/json");

    //will not be a cache hit
    HttpRequestUtil.doGet((getApiInvocationURL("cachingEnabledApi") + "/singleElementArrayBackend"), requestHeader);

    //will be a cache hit
    HttpResponse response = HttpRequestUtil.
            doGet((getApiInvocationURL("cachingEnabledApi") + "/singleElementArrayBackend"), requestHeader);

    //check if [] are preserved in response
    Assert.assertTrue(response.getData().contains("[ \"water\" ]"),
            "Expected response was not" + " received. Got " + response.getData());
}
 
Example #4
Source File: ESBJAVA4721PIWithCacheTestCase.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
@Test(groups = "wso2.esb", description = "Test cache mediator with  Json response having a single element array with PI enabled")
public void testJsonResponseWithCacheMediator() throws IOException, AutomationFrameworkException {

    Map<String, String> requestHeader = new HashMap<>();
    requestHeader.put("Content-type", "application/json");

    //will not be a cache hit
    HttpRequestUtil.doGet((getApiInvocationURL("cachingEnabledApi") + "/singleElementArrayBackend"), requestHeader);

    //will be a cache hit
    HttpResponse response = HttpRequestUtil.
            doGet((getApiInvocationURL("cachingEnabledApi") + "/singleElementArrayBackend"), requestHeader);

    //check if [] are preserved in response
    Assert.assertTrue(response.getData().contains("[ \"water\" ]"),
            "Expected response was not" + " received. Got " + response.getData());
}
 
Example #5
Source File: ESBJAVA5030PayloadFormatArgumentWithTrailingSpaceTestCase.java    From product-ei with Apache License 2.0 6 votes vote down vote up
@Test(groups = "wso2.esb", description = "invoke service - Trailing space trim check")
public void testPayloadFactoryArgsWithTrailingSpaces()
        throws AxisFault, MalformedURLException, AutomationFrameworkException {

    //json request payload.
    String payload = "{\n" +
                     "  \"input\": { \"value\": \"<abc>sample</abc> \" }\n" +
                     "}";

    Reader data = new StringReader(payload);
    Writer writer = new StringWriter();

    String serviceURL = this.getApiInvocationURL("trailingSpaceAPI");

    String response = HttpURLConnectionClient.sendPostRequestAndReadResponse(data,
                                                                             new URL(serviceURL), writer, "application/json");

    assertNotNull(response, "Response is null");
    //should return the response without throwing any errors.
    assertTrue(response.contains("output\": \"{\"abc\":\"sample\"}"));
}
 
Example #6
Source File: ESBJAVA4721PIWithCacheTestCase.java    From product-ei with Apache License 2.0 6 votes vote down vote up
@Test(groups = "wso2.esb",
      description = "Test cache mediator with  Json response having a single element array with PI enabled")
public void testJsonResponseWithCacheMediator() throws IOException, AutomationFrameworkException {

    Map<String, String> requestHeader = new HashMap<>();
    requestHeader.put("Content-type", "application/json");

    //will not be a cache hit
    HttpRequestUtil.doGet((getApiInvocationURL("cachingEnabledApi") + "/singleElementArrayBackend"), requestHeader);

    //will be a cache hit
    HttpResponse response = HttpRequestUtil.
            doGet((getApiInvocationURL("cachingEnabledApi") + "/singleElementArrayBackend"), requestHeader);

    //check if [] are preserved in response
    Assert.assertTrue(response.getData().contains("[ \"water\" ]"),
            "Expected response was not" + " received. Got " + response.getData());
}
 
Example #7
Source File: JsonResponseWithCacheTestCase.java    From product-ei with Apache License 2.0 6 votes vote down vote up
@Test(groups = "wso2.esb", description = "Test cache mediator with  Json response having a single element array", enabled = false)
public void testJsonResponseWithCacheMediator() throws IOException, AutomationFrameworkException {

    Map<String, String> requestHeader = new HashMap<>();
    requestHeader.put("Content-type", "application/json");

    //will not be a cache hit
    HttpRequestUtil.doGet((getApiInvocationURL("cachingEnabledApi") + "/singleElementArrayBackend"), requestHeader);

    //will be a cache hit
    HttpResponse response = HttpRequestUtil.
            doGet((getApiInvocationURL("cachingEnabledApi") + "/singleElementArrayBackend"), requestHeader);

    //check if [] are preserved in response
    Assert.assertTrue(response.getData().contains("[ \"water\" ]"), "Expected response was not"
            + " received. Got " + response.getData());
}
 
Example #8
Source File: Axis2ServerExtension.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
public void onExecutionStart() throws AutomationFrameworkException {
    serverManager = new Axis2ServerManager();
    //To set the socket can be bound even though a previous connection is still in a timeout state.
    if (System.getProperty(CoreConnectionPNames.SO_REUSEADDR) == null) {
        System.setProperty(CoreConnectionPNames.SO_REUSEADDR, "true");
    }
    try {
        serverManager.start();
        log.info(".................Deploying services..............");
        serverManager.deployService(ServiceNameConstants.LB_SERVICE_1);
        serverManager.deployService(ServiceNameConstants.SIMPLE_STOCK_QUOTE_SERVICE);
        serverManager.deployService(ServiceNameConstants.SECURE_STOCK_QUOTE_SERVICE);
        serverManager.deployService(ServiceNameConstants.SIMPLE_AXIS2_SERVICE);
    } catch (IOException e) {
        handleException("Error While Deploying services", e);
    }
}
 
Example #9
Source File: ESBJAVA5135ResponseBodyWith202TestCase.java    From product-ei with Apache License 2.0 6 votes vote down vote up
/**
 * Test response with 202 and body is built by ESB and responds client
 *
 * @throws AxisFault                    in case of an axis2 level issue when sending
 * @throws MalformedURLException        in case of url is malformed
 * @throws AutomationFrameworkException in case of any other test suite level issue
 */
@Test(groups = "wso2.esb", description = "Test response with 202 and body is built by ESB and responds client "
        + "properly")
public void testResponseWith202() throws AxisFault, MalformedURLException, AutomationFrameworkException {
    Map<String, String> requestHeader = new HashMap<>();
    requestHeader.put("Content-type", "text/xml");
    requestHeader.put("SOAPAction", "urn:mediate");
    String message = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap"
            + ".org/soap/envelope/\">\n"
            + "   <soapenv:Header/>\n"
            + "   <soapenv:Body/>\n"
            + "</soapenv:Envelope>";

    HttpResponse response = HttpRequestUtil.
            doPost(new URL(getProxyServiceURLHttp("mockProxy")), message, requestHeader);

    Assert.assertTrue(response.getData().contains("Hello World"), "Expected response was not"
            + " received. Got " + response.getData());
}
 
Example #10
Source File: CarbonServerManager.java    From product-ei with Apache License 2.0 6 votes vote down vote up
private void generateCoverageReport(File classesDir)
        throws IOException, AutomationFrameworkException {

    CodeCoverageUtils.executeMerge(FrameworkPathUtil.getJacocoCoverageHome(),
                                   FrameworkPathUtil.getCoverageMergeFilePath());
    ReportGenerator reportGenerator =
            new ReportGenerator(new File(FrameworkPathUtil.getCoverageMergeFilePath()),
                                classesDir,
                                new File(CodeCoverageUtils.getJacocoReportDirectory()),
                                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");
}
 
Example #11
Source File: Axis2ServerExtension.java    From product-ei with Apache License 2.0 6 votes vote down vote up
public void onExecutionStart() throws AutomationFrameworkException {
    serverManager = new Axis2ServerManager();
    //To set the socket can be bound even though a previous connection is still in a timeout state.
    if (System.getProperty(CoreConnectionPNames.SO_REUSEADDR) == null) {
        System.setProperty(CoreConnectionPNames.SO_REUSEADDR, "true");
    }
    try {
        serverManager.start();
        log.info(".................Deploying services..............");
        serverManager.deployService(ServiceNameConstants.LB_SERVICE_1);
        serverManager.deployService(ServiceNameConstants.SIMPLE_STOCK_QUOTE_SERVICE);
        serverManager.deployService(ServiceNameConstants.SECURE_STOCK_QUOTE_SERVICE);
        serverManager.deployService(ServiceNameConstants.SIMPLE_AXIS2_SERVICE);
    } catch (IOException e) {
        handleException("Error While Deploying services", e);
    }
}
 
Example #12
Source File: ESBJAVA3573PayloadFormatWithBeginHtmlTagArgument.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
@Test(groups = "wso2.esb", description = "invoke service - EvaluatorCheck")
public void testPayloadFactoryArgsWithXmlBeginAndEndTags()
        throws AxisFault, MalformedURLException, AutomationFrameworkException {

    // json request payload.
    String payload = "{\n" + "  \"input\": { \"value\": \"<ta>&$@%*\\\"\\\" '>\" }\n" + "}";

    Reader data = new StringReader(payload);
    Writer writer = new StringWriter();

    String serviceURL = this.getApiInvocationURL("deepCheckAPI");

    String response = HttpURLConnectionClient
            .sendPostRequestAndReadResponse(data, new URL(serviceURL), writer, "application/json");

    assertNotNull(response, "Response is null");
    //should return the response without throwing any errors.
    assertTrue(response.contains("\"output\": \"<ta>&$@%*\\\"\\\" '>\""));
}
 
Example #13
Source File: JSONPayloadXMLSpecialCharEscapeTest.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
@Test(groups = "wso2.esb", description = "JSONPayload with XMLSpecialChar Escape Test")
public void JSONPayloadWithXMLSpecialCharEscapeTest()
        throws AxisFault, MalformedURLException, AutomationFrameworkException {

    //json request payload.
    String payload = "<text>{\"chars\" : \"266/W, Simple Text &#60; &#62; &#38;,&#xd;\n" + "line2,&#xd;\n"
            + "line 3\"}</text>";

    Reader data = new StringReader(payload);
    Writer writer = new StringWriter();

    String serviceURL = this.getApiInvocationURL("testEnterAPI");

    String response = HttpURLConnectionClient
            .sendPostRequestAndReadResponse(data, new URL(serviceURL), writer, "application/xml");
    assertNotNull(response, "Response is null");
    //should return the response without throwing any errors.
    assertTrue(response.contains("{\"chars\" : \"266/W, Simple Text < > &,\\r\\nline2,\\r\\nline 3\"}"));
}
 
Example #14
Source File: ESBJAVA5030PayloadFormatArgumentWithTrailingSpaceTestCase.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
@Test(groups = "wso2.esb", description = "invoke service - Trailing space trim check")
public void testPayloadFactoryArgsWithTrailingSpaces()
        throws AxisFault, MalformedURLException, AutomationFrameworkException {

    //json request payload.
    String payload = "{\n" + "  \"input\": { \"value\": \"<abc>sample</abc> \" }\n" + "}";

    Reader data = new StringReader(payload);
    Writer writer = new StringWriter();

    String serviceURL = this.getApiInvocationURL("trailingSpaceAPI");

    String response = HttpURLConnectionClient
            .sendPostRequestAndReadResponse(data, new URL(serviceURL), writer, "application/json");

    assertNotNull(response, "Response is null");
    //should return the response without throwing any errors.
    assertTrue(response.contains("output\": \"{\"abc\":\"sample\"}"));
}
 
Example #15
Source File: MultipleServersManager.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
public void startServersWithDepSync(boolean mountRegistry, TestServerManager... serverManagers)
        throws AutomationFrameworkException {

    int noOfServers = serverManagers.length;
    for (int index = 0; index < noOfServers; ++index) {
        log.info("============================== Configuring server " + (servers.size() + 1)
                         + " ==============================");
        TestServerManager testServerManager = serverManagers[index];
        try {
            String carbonHome;
            if (deploymentDirectory == null) {
                carbonHome = testServerManager.startServer();
                deploymentDirectory = String.join(File.separator, carbonHome, "repository", "deployment");
                if (mountRegistry) {
                    registryDirectory = String.join(File.separator, carbonHome, "registry");
                }
            } else {
                carbonHome = testServerManager.startServer(deploymentDirectory, registryDirectory);
            }
            servers.put(carbonHome, testServerManager);
        } catch (Exception ex) {
            throw new AutomationFrameworkException(ex);
        }
    }
}
 
Example #16
Source File: MultipleServersManager.java    From product-ei with Apache License 2.0 6 votes vote down vote up
public void startServers(TestServerManager... serverManagers) throws AutomationFrameworkException {
    TestServerManager[] arr$ = serverManagers;
    int len$ = serverManagers.length;

    for (int i$ = 0; i$ < len$; ++i$) {
        TestServerManager zip = arr$[i$];
        String carbonHome = null;

        try {
            carbonHome = zip.startServer();
        } catch (IOException var8) {
            throw new AutomationFrameworkException("Server start failed", var8);
        } catch (AutomationFrameworkException var9) {
            throw new AutomationFrameworkException("Server start failed", var9);
        } catch (XPathExpressionException var10) {
            throw new AutomationFrameworkException("Server start failed", var10);
        }

        this.servers.put(carbonHome, zip);
    }

}
 
Example #17
Source File: testInfiniteLoopingWithCallMediatorTestCase.java    From product-ei with Apache License 2.0 6 votes vote down vote up
/**
 * Send a empty SOAP message and see if we get expected reply.
 *
 * @throws AxisFault                    in case of an axis2 level issue when sending
 * @throws MalformedURLException        in case of url is malformed
 * @throws AutomationFrameworkException in case of any other test suite level issue
 */
@Test(groups = "wso2.esb", description = "Test call mediator with foreach mediator has expected message flow")
public void testForeachMediatorMessageFlow() throws AxisFault, MalformedURLException, AutomationFrameworkException {
    Map<String, String> requestHeader = new HashMap<>();
    requestHeader.put("Content-type", "text/xml");
    requestHeader.put("SOAPAction", "urn:mediate");
    String message = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap"
            + ".org/soap/envelope/\">\n"
            + "   <soapenv:Header/>\n"
            + "   <soapenv:Body/>\n"
            + "</soapenv:Envelope>";

    HttpResponse response = HttpRequestUtil.
            doPost(new URL(getProxyServiceURLHttp("acceptProxy")), message, requestHeader);

    Assert.assertTrue(response.getData().contains("<company>wso2</company>"), "Expected response was not"
            + " received. Got " + response.getData());
}
 
Example #18
Source File: CarbonServerManager.java    From product-ei with Apache License 2.0 5 votes vote down vote up
/**
 * 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 (process != null) { // An instance of the server is running
        return carbonHome;
    }
    int indexOfZip = carbonServerZipFile.lastIndexOf(".zip");
    if (indexOfZip == -1) {
        throw new IllegalArgumentException(carbonServerZipFile + " is not a zip file");
    }
    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);
    carbonHome = new File(baseDir).getAbsolutePath() + File.separator + extractDir + File.separator +
                 extractedCarbonDir;
    try {
        //read coverage status from automation.xml
        isCoverageEnable = Boolean.parseBoolean(automationContext.getConfigurationValue("//coverage"));
    } catch (XPathExpressionException e) {
        throw new AutomationFrameworkException("Coverage configuration not found in automation.xml", e);
    }

    //insert Jacoco agent configuration to carbon server startup script. This configuration
    //cannot be directly pass as server startup command due to script limitation.
    if (isCoverageEnable) {
        instrumentForCoverage();
    }

    return carbonHome;
}
 
Example #19
Source File: DatabaseManager.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
private void populateParameters() throws AutomationFrameworkException {

        Map<String, String> parameters = getParameters();
        for (Map.Entry<String, String> entry : parameters.entrySet()) {
            String key = entry.getKey();
            String value = entry.getValue();
            switch (key) {
            case "toml-path":
                parseToml(value);
                break;
            case "script-basedir":
                scriptBaseDir = value;
                break;
            case "script-suffix":
                scriptSuffix = value;
                break;
            case "data-source":
                dataSource = value;
                break;
            case "script-delimiter":
                delimiter = value;
                break;
            case "db-clear-scripts-base-dir":
                dbClearScripts = value;
                break;
            default:
                logger.error("Unknown property : " + key);
                break;
            }
        }
    }
 
Example #20
Source File: ActiveMQServerExtension.java    From product-ei with Apache License 2.0 5 votes vote down vote up
@Override
public void onExecutionStart() throws AutomationFrameworkException {
    if (!JMSBrokerController.isBrokerStarted()) {
        log.info("Starting JMS Broker...");
        activeMqBroker.start();
    }
}
 
Example #21
Source File: NewInstanceTestCase.java    From product-ei with Apache License 2.0 5 votes vote down vote up
/**
 * Starts up the product with offset.
 *
 * @throws XPathExpressionException
 * @throws AutomationFrameworkException
 */
@SetEnvironment(executionEnvironments = {ExecutionEnvironment.STANDALONE})
@BeforeClass(groups = {"mb.server.startup"})
public void testStartServers() throws XPathExpressionException, AutomationFrameworkException {
    AutomationContext context = new AutomationContext();
    startupParameterMap1.put("-DportOffset", "2");
    CarbonTestServerManager server1 = new CarbonTestServerManager(context, System.getProperty("carbon.zip"),
            startupParameterMap1);
    manager.startServers(server1);
}
 
Example #22
Source File: CarbonServerManager.java    From product-ei with Apache License 2.0 5 votes vote down vote up
/**
 * This method will check the OS and edit server startup script to inject jacoco agent
 *
 * @throws IOException - If agent insertion fails.
 */
private void instrumentForCoverage() throws IOException, AutomationFrameworkException {
    String scriptName = TestFrameworkUtils.getStartupScriptFileName(carbonHome);

    if (System.getProperty("os.name").toLowerCase().contains("windows")) {
        insertJacocoAgentToBatScript(scriptName);
        if (log.isDebugEnabled()) {
            log.debug("Included files " + CodeCoverageUtils.getInclusionJarsPattern(":"));
            log.debug("Excluded files " + CodeCoverageUtils.getExclusionJarsPattern(":"));
        }
    } else {
        insertJacocoAgentToShellScript(scriptName);
    }

}
 
Example #23
Source File: TestCoverageGenerator.java    From product-ei with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws AutomationFrameworkException, IOException {
    if (carbonZip == null) {
        carbonZip = FrameworkPathUtil.getCarbonZipLocation();
        log.info("Using carbon zip file at  " + carbonZip);
    }
    if (carbonZip == null) {
        throw new IllegalArgumentException("carbon zip file cannot find in the given location " +
                FrameworkPathUtil.getCarbonZipLocation());
    }
    String carbonHome = ArchiveExtractorUtil.setUpCarbonHome(carbonZip);
    File parentDirectory = new File(System.getProperty("basedir")).getParentFile();

    CodeCoverageUtils.executeMerge(parentDirectory.getAbsolutePath(), FrameworkPathUtil.getCoverageMergeFilePath());

    File carbonPluginDir =
            new File(carbonHome + File.separator + "wso2" +
                    File.separator + "components" + File.separator + "plugins" + File.separator);


    ReportGenerator reportGenerator =
            new ReportGenerator(new File(FrameworkPathUtil.getCoverageMergeFilePath()),
                    carbonPluginDir,
                    new File(CodeCoverageUtils.getJacocoReportDirectory()),
                    null);
    reportGenerator.create();

    File carbonHomeDir = new File(carbonHome);

    if (carbonHomeDir.exists()) {
        FileUtils.deleteQuietly(new File(carbonHome)); //delete extracted dir
    }

    log.info("Jacoco coverage merged file : " + FrameworkPathUtil.getCoverageMergeFilePath());
    log.info("Jacoco class file path : " + carbonPluginDir.getAbsolutePath());
    log.info("Jacoco coverage HTML report path : " + CodeCoverageUtils.getJacocoReportDirectory() + File.separator + "index.html");
}
 
Example #24
Source File: TestServerManager.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
private void setUpCarbonHome(String deploymentDirectory, String registryDir)
        throws IOException, AutomationFrameworkException {
    if (carbonZip == null) {
        carbonZip = System.getProperty(FrameworkConstants.SYSTEM_PROPERTY_CARBON_ZIP_LOCATION);
    }
    if (carbonZip == null) {
        throw new IllegalArgumentException("carbon zip file cannot find in the given location");
    }
    carbonHome = carbonServer.setUpCarbonHome(carbonZip, commandMap.get("startupScript"));
    configureServer(deploymentDirectory, registryDir);
}
 
Example #25
Source File: MultipleServersManager.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
public void startServers(TestServerManager... serverManagers) throws AutomationFrameworkException {

        int noOfServers = serverManagers.length;
        for (int index = 0; index < noOfServers; ++index) {
            log.info("============================== Configuring server " + (servers.size() + 1)
                             + " ==============================");
            TestServerManager testServerManager = serverManagers[index];
            try {
                String carbonHome = testServerManager.startServer();
                servers.put(carbonHome, testServerManager);
            } catch (Exception ex) {
                throw new AutomationFrameworkException(ex);
            }
        }
    }
 
Example #26
Source File: FaultSeqInvokeWithAggregateTimeoutTestCase.java    From product-ei with Apache License 2.0 5 votes vote down vote up
@Test(groups = "wso2.esb", description = "Add a non-existing mediator and check if fault sequence is hit upon " +
        "onComplete of aggregate mediator with timeout condition")
public void testFaultResponseIsReceived() throws AxisFault, MalformedURLException, AutomationFrameworkException {
    Map<String, String> requestHeader = new HashMap<>();
    requestHeader.put("Content-type", "application/xml");
    String message = "<marketDetail>\n" +
            "    <market>\n" +
            "        <id>100</id>\n" +
            "        <openTime>10.00AM</openTime>\n" +
            "        <closeTime>4.00PM</closeTime>\n" +
            "        <name>New York</name>\n" +
            "    </market>\n" +
            "    <market>\n" +
            "        <id>200</id>\n" +
            "        <openTime>9.00AM</openTime>\n" +
            "        <closeTime>5.00PM</closeTime>\n" +
            "        <name>London</name>\n" +
            "    </market>\n" +
            "    <market>\n" +
            "        <id>300</id>\n" +
            "        <openTime>8.00AM</openTime>\n" +
            "        <closeTime>3.00PM</closeTime>\n" +
            "        <name>Colombo</name>\n" +
            "    </market>\n" +
            "    <market>\n" +
            "        <id>250</id>\n" +
            "        <openTime>8.00AM</openTime>\n" +
            "        <closeTime>8.00PM</closeTime>\n" +
            "        <name>London</name>\n" +
            "    </market>\n" +
            "</marketDetail>";
    HttpResponse response = HttpRequestUtil.
            doPost(new URL(getApiInvocationURL("testApiAggregate")), message, requestHeader);

    Assert.assertTrue(response.getData().contains("SEQUENCE_ERROR_HANDLER"), "Expected response was not"
            + " received. Got " + response.getData());
}
 
Example #27
Source File: TestServerManager.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
void restartServer() throws AutomationFrameworkException {

        log.info("Preparing to restart the server ...");
        carbonServer.serverShutdown(portOffset, true);
        carbonServer.startServerUsingCarbonHome(carbonHome, commandMap);
        log.info("Server restarted successfully ...");
    }
 
Example #28
Source File: NullValueTransportHeaderTestCase.java    From product-ei with Apache License 2.0 5 votes vote down vote up
@Test(groups = "wso2.esb", description = "Property mediator test with null value set as transport header")
public void testRespondMediator() throws AxisFault, MalformedURLException, AutomationFrameworkException {
    Map<String, String> requestHeader = new HashMap<>();
    requestHeader.put("Content-type", "application/json");
    HttpResponse response = HttpRequestUtil.doPost(new URL(getApiInvocationURL("nullValueTransportHeaderTestFrontEnd")),
            "{\"test\" : \"nullHeaderVal\"}", requestHeader);
    Assert.assertTrue(response.getData().contains("{\"company\" : \"wso2\"}"), "Expected response was not"
            + "received. Got " + response.getData());
}
 
Example #29
Source File: TestServerManager.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * Restarting server already started by the method startServer.
 */
public void restartGracefully() throws AutomationFrameworkException {
    if (carbonHome == null) {
        throw new AutomationFrameworkException(
                "No Running Server found to restart. " + "Please make sure whether server is started");
    }
    carbonServer.restartGracefully();
}
 
Example #30
Source File: TestCoverageGenerator.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws AutomationFrameworkException, IOException {
    if (carbonZip == null) {
        carbonZip = FrameworkPathUtil.getCarbonZipLocation();
        log.info("Using carbon zip file at  " + carbonZip);
    }
    if (carbonZip == null) {
        throw new IllegalArgumentException(
                "carbon zip file cannot find in the given location " + FrameworkPathUtil.getCarbonZipLocation());
    }
    String carbonHome = ArchiveExtractorUtil.setUpCarbonHome(carbonZip);
    File parentDirectory = new File(System.getProperty("basedir")).getParentFile();

    CodeCoverageUtils.executeMerge(parentDirectory.getAbsolutePath(), FrameworkPathUtil.getCoverageMergeFilePath());

    File carbonPluginDir = new File(
            carbonHome + File.separator + "wso2" + File.separator + "components" + File.separator + "plugins"
                    + File.separator);

    ReportGenerator reportGenerator = new ReportGenerator(new File(FrameworkPathUtil.getCoverageMergeFilePath()),
                                                          carbonPluginDir,
                                                          new File(CodeCoverageUtils.getJacocoReportDirectory()),
                                                          null);
    reportGenerator.create();

    File carbonHomeDir = new File(carbonHome);

    if (carbonHomeDir.exists()) {
        FileUtils.deleteQuietly(new File(carbonHome)); //delete extracted dir
    }

    log.info("Jacoco coverage merged file : " + FrameworkPathUtil.getCoverageMergeFilePath());
    log.info("Jacoco class file path : " + carbonPluginDir.getAbsolutePath());
    log.info("Jacoco coverage HTML report path : " + CodeCoverageUtils.getJacocoReportDirectory() + File.separator
                     + "index.html");
}