Java Code Examples for org.wso2.carbon.automation.engine.frameworkutils.FrameworkPathUtil

The following examples show how to use org.wso2.carbon.automation.engine.frameworkutils.FrameworkPathUtil. These examples are extracted from open source projects. 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 Project: micro-integrator   Source File: Sample153TestCase.java    License: Apache License 2.0 6 votes vote down vote up
@Test(groups = "wso2.esb", description = "Custom sequences and endpoints with proxy services")
public void sample153Test() throws Exception {
    String policyPath = FrameworkPathUtil.getSystemResourceLocation() + "security" + File.separator + "policies"
            + File.separator + "scenario27-policy.xml";
    OMElement response = new SecureStockQuoteClient()
            .sendSecuredSimpleStockQuoteRequest(null, null, getProxyServiceURLHttp("StockQuoteProxy"), policyPath,
                    "Secured");

    String lastPrice = response.getFirstElement()
            .getFirstChildWithName(new QName("http://services.samples/xsd", "last")).getText();
    assertNotNull(lastPrice, "Fault: response message 'last' price null");

    String symbol = response.getFirstElement()
            .getFirstChildWithName(new QName("http://services.samples/xsd", "symbol")).getText();
    assertEquals(symbol, "Secured", "Fault: value 'symbol' mismatched");

}
 
Example 2
@BeforeClass(alwaysRun = true)
public void setEnvironment() throws Exception {
    super.init();
    serverManager = new ServerConfigurationManager(new AutomationContext("ESB", TestUserMode.SUPER_TENANT_ADMIN));
    File sourceFile = new File(
            FrameworkPathUtil.getSystemResourceLocation() + "artifacts" + File.separator + "ESB" + File.separator
                    + "streamingxpath" + File.separator + "synapse.properties");
    serverManager.applyConfiguration(sourceFile);
    super.init();
    String relativePath = "artifacts" + File.separator + "ESB" + File.separator + "streamingxpath" + File.separator
            + "StreamingException.xml";
    ESBTestCaseUtils util = new ESBTestCaseUtils();
    OMElement proxyConfig = util.loadResource(relativePath);

    try {
        addProxyService(proxyConfig);
    } catch (Exception ignore) {
        exceptionCaught = true;
    }

}
 
Example 3
@BeforeClass(alwaysRun = true)
public void init() throws Exception {
    super.init(userMode);
    genericRestClient = new GenericRestClient();
    publisherUrl = automationContext.getContextUrls()
            .getSecureServiceUrl().replace("services", "publisher/apis");
    manageGenericArtifactAdminServiceClient =
            new ManageGenericArtifactAdminServiceClient(backendURL, sessionCookie);
    lifeCycleAdminServiceClient = new LifeCycleManagementClient(backendURL, sessionCookie);
    resourceAdminServiceClient = new ResourceAdminServiceClient(backendURL, sessionCookie);
    serverConfigurationManager = new ServerConfigurationManager(automationContext);
    resourcePath = FrameworkPathUtil.getSystemResourceLocation()
                   + "artifacts" + File.separator + "GREG" + File.separator;
    resourceRegistryPath = "/_system/governance/repository/components" +
                           "/org.wso2.carbon.governance/types/updated-serviceLC.rxt";
    lifeCycleName = "ServiceLifeCycleLC2";
    restServiceResourcePath = "/_system/governance/trunk/restservices/1.0.0/testservice1234";
}
 
Example 4
Source Project: product-es   Source File: LifecycleUtil.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * add a life cycle to a collection or resource
 *
 * @param path path of the collection or resource to be subscribed
 * @return true if the life cycle is added to the resource or collection,
 *         false otherwise
 * @throws Exception
 */
private boolean addLifeCycle(String path) throws Exception {
    LifeCycleManagementClient lifeCycleManagementClient =
            new LifeCycleManagementClient(
                    backEndUrl, sessionCookie);
    String filePath =
            FrameworkPathUtil.getSystemResourceLocation() + "artifacts" +

            File.separator + "es" + File.separator + "lifecycle" +
            File.separator + "StateDemoteLifeCycle.xml";
    String lifeCycleConfiguration = FileManager.readFile(filePath);
    // add life cycle
    lifeCycleManagementClient.addLifeCycle(lifeCycleConfiguration);
    wsRegistryServiceClient.associateAspect(path, ASPECT_NAME);
    return (lifeCycleAdminServiceClient.getLifecycleBean(path) != null);
}
 
Example 5
Source Project: micro-integrator   Source File: HttpAccessLogTestCase.java    License: Apache License 2.0 6 votes vote down vote up
@BeforeClass(alwaysRun = true)
public void init() throws Exception {

    super.init();
    serverConfigurationManager = new ServerConfigurationManager(
            new AutomationContext("ESB", TestUserMode.SUPER_TENANT_ADMIN));
    String accessLogFile =
            FrameworkPathUtil.getSystemResourceLocation() + "artifacts" + separator + "ESB" + separator + "passthru"
                    + separator + "transport" + separator + "httpaccesslogs" + separator + "access-log.properties";

    File srcFile = new File(accessLogFile);
    String carbonHome = System.getProperty(ServerConstants.CARBON_HOME);
    httpLogDir = carbonHome + File.separator + "repository" + File.separator + "logs" + File.separator + "httpLogs";
    File log4jProperties = new File(carbonHome + File.separator + "conf" + File.separator + "log4j2.properties");
    String propertyName = "nhttp.log.directory";
    CarbonServerExtension.shutdownServer();
    createNewDir(httpLogDir);
    applyProperty(srcFile, propertyName, httpLogDir);
    String loggers = getProperty(log4jProperties, "loggers");
    applyLog4j2Properties(loggers, log4jProperties);
    CarbonServerExtension.startServer();
    super.init();
}
 
Example 6
@Test(groups = "wso2.esb", description = "Getting HTTP status code number ")
public void testHttpResponseCode() throws Exception {

    int responseStatus = 0;

    String strXMLFilename = FrameworkPathUtil.getSystemResourceLocation() + "artifacts"
                            + File.separator + "ESB" + File.separator + "mediatorconfig" +
                            File.separator + "property" + File.separator + "GetQuoteRequest.xml";

    File input = new File(strXMLFilename);
    PostMethod post = new PostMethod(getProxyServiceURLHttp("HTTP_SCTestProxy"));
    RequestEntity entity = new FileRequestEntity(input, "text/xml");
    post.setRequestEntity(entity);
    post.setRequestHeader("SOAPAction", "getQuote");

    HttpClient httpclient = new HttpClient();

    try {
        responseStatus = httpclient.executeMethod(post);
    } finally {
        post.releaseConnection();
    }

    assertEquals(responseStatus, 404, "Response status should be 404");
}
 
Example 7
@Test(groups = "wso2.esb", description = "Testing functionality of FORCE_SC_ACCEPTED " + "Enabled True  - "
        + "Client should receive 202 message", dependsOnMethods = "testFORCE_SC_ACCEPTEDPropertyEnabledFalseScenario")
public void testWithFORCE_SC_ACCEPTEDPropertyEnabledTrueScenario() throws Exception {
    int responseStatus = 0;

    String strXMLFilename =
            FrameworkPathUtil.getSystemResourceLocation() + "artifacts" + File.separator + "ESB" + File.separator
                    + "mediatorconfig" + File.separator + "property" + File.separator + "PlaceOrder.xml";

    File input = new File(strXMLFilename);
    PostMethod post = new PostMethod(getProxyServiceURLHttp("FORCE_SC_ACCEPTED_TrueTestProxy"));
    RequestEntity entity = new FileRequestEntity(input, "text/xml");
    post.setRequestEntity(entity);
    post.setRequestHeader("SOAPAction", "placeOrder");

    HttpClient httpclient = new HttpClient();

    try {
        responseStatus = httpclient.executeMethod(post);
    } finally {
        post.releaseConnection();
    }

    assertEquals(responseStatus, 202, "Response status should be 202");
}
 
Example 8
@Test(groups = "wso2.esb", description = "Getting HTTP status code number ")
public void testHttpResponseCode() throws Exception {

    int responseStatus = 0;

    String strXMLFilename =
            FrameworkPathUtil.getSystemResourceLocation() + "artifacts" + File.separator + "ESB" + File.separator
                    + "mediatorconfig" + File.separator + "property" + File.separator + "GetQuoteRequest.xml";

    File input = new File(strXMLFilename);
    PostMethod post = new PostMethod(getProxyServiceURLHttp("HTTP_SCTestProxy"));
    RequestEntity entity = new FileRequestEntity(input, "text/xml");
    post.setRequestEntity(entity);
    post.setRequestHeader("SOAPAction", "getQuote");

    HttpClient httpclient = new HttpClient();

    try {
        responseStatus = httpclient.executeMethod(post);
    } finally {
        post.releaseConnection();
    }

    assertEquals(responseStatus, 404, "Response status should be 404");
}
 
Example 9
@BeforeClass(alwaysRun = true)
public void setEnvironment() throws Exception {
    super.init();
    serverManager = new ServerConfigurationManager(new AutomationContext("ESB", TestUserMode.SUPER_TENANT_ADMIN));
    File sourceFile = new File(FrameworkPathUtil.getSystemResourceLocation() + "artifacts" + File.separator +
            "ESB" + File.separator + "streamingxpath" + File.separator + "synapse.properties");
    serverManager.applyConfiguration(sourceFile);
    super.init();
    String relativePath = "artifacts" + File.separator + "ESB" + File.separator + "streamingxpath" +
            File.separator + "StreamingException.xml";
    ESBTestCaseUtils util = new ESBTestCaseUtils();
    OMElement proxyConfig = util.loadResource(relativePath);

    try {
        addProxyService(proxyConfig);
    } catch (Exception ignore) {
       exceptionCaught=true;
    }

}
 
Example 10
@BeforeClass(alwaysRun = true)
public void setEnvironment() throws Exception {

    super.init();
    String axis2XmlPath = FrameworkPathUtil.getSystemResourceLocation()
            + "/artifacts/ESB/mediatorconfig/callout/client_repo/conf/axis2.xml";
    String uriSynapse = FrameworkPathUtil.getSystemResourceLocation()
            + "/artifacts/ESB/mediatorconfig/callout/ValidPath_Axis2Xml.xml";

    OMElement lineItem = AXIOMUtil.stringToOM(FileManager.readFile(uriSynapse));
    AXIOMXPath xPath = new AXIOMXPath("//ns:configuration");
    xPath.addNamespace("ns", "http://ws.apache.org/ns/synapse");
    OMElement configuration = (OMElement) xPath.selectSingleNode(lineItem);
    //replacing the path
    configuration.getAttribute(new QName("axis2xml")).setAttributeValue(axis2XmlPath);
    updateESBConfiguration(lineItem);

}
 
Example 11
Source Project: micro-integrator   Source File: CarbonServerManager.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * This methods will insert jacoco agent settings into startup script under JAVA_OPTS
 *
 * @param scriptName - Name of the startup script
 * @throws IOException - throws if shell script edit fails
 */
private void insertJacocoAgentToShellScript(String scriptName) throws IOException {

    String jacocoAgentFile = CodeCoverageUtils.getJacocoAgentJarLocation();
    coverageDumpFilePath = FrameworkPathUtil.getCoverageDumpFilePath();

    File inFile = Paths.get(carbonHome, "bin", scriptName + ".sh").toFile();
    File tmpFile = Paths.get(carbonHome, "tmp" + scriptName + ".sh").toFile();
    String lineToBeChecked = "-Dwso2.server.standalone=true";
    String lineToBeInserted =
            "-javaagent:" + jacocoAgentFile + "=destfile=" + coverageDumpFilePath + "" + ",append=true,includes="
                    + CodeCoverageUtils.getInclusionJarsPattern(":") + ",excludes=" + CodeCoverageUtils
                    .getExclusionJarsPattern(":") + " \\";

    CodeCoverageUtils.insertStringToFile(inFile, tmpFile, lineToBeChecked, lineToBeInserted);
}
 
Example 12
Source Project: micro-integrator   Source File: TestServerManager.java    License: Apache License 2.0 6 votes vote down vote up
private void configureServer(String deploymentDirectory, String registryDir) throws IOException {

        if ("ESB".equalsIgnoreCase(System.getProperty("server.list"))) {
            //copying the files before server start. Ex: synapse artifacts, conf, etc...
            ServerUtils.copyResources("ESB", this.getCarbonHome(), deploymentDirectory, registryDir);
            String resourceHome =
                    FrameworkPathUtil.getSystemResourceLocation() + File.separator + "artifacts" + File.separator
                            + "ESB" + File.separator + "server";
            File dropinsDirectorySource = new File(resourceHome + File.separator + "dropins");
            File dropinsDestination = new File(this.getCarbonHome() + File.separator + "dropins");
            if (dropinsDirectorySource.exists() && dropinsDirectorySource.isDirectory()) {
                try {
                    log.info("Copying " + dropinsDirectorySource.getPath() + " to " + dropinsDestination.getPath());
                    FileUtils.copyDirectory(dropinsDirectorySource, dropinsDestination);
                } catch (IOException e) {
                    log.error("Error while copying lib directory.", e);
                }
            }
        } else if ("DSS".equalsIgnoreCase(System.getProperty("server.list"))) {
            ServerUtils.copyResources("DSS", this.getCarbonHome(), deploymentDirectory, registryDir);
        }
    }
 
Example 13
Source Project: micro-integrator   Source File: ServerUtils.java    License: Apache License 2.0 6 votes vote down vote up
static void copyResources(String product, String destCarbonHome, String clusterDepDir, String clusterRegDir)
        throws IOException {

    String carbonHome =
            FrameworkPathUtil.getSystemResourceLocation() + File.separator + "artifacts" + File.separator + product
                    + File.separator + "server";
    copyFolders(new File(carbonHome + File.separator + "conf"), new File(destCarbonHome + File.separator + "conf"));
    copyFolders(new File(carbonHome + File.separator + "lib"), new File(destCarbonHome + File.separator + "lib"));

    File destinationDeploymentDirectory = new File(
            String.join(File.separator, destCarbonHome, "repository", "deployment"));
    if (clusterDepDir == null) {
        copyFolders(new File(String.join(File.separator, carbonHome, "repository", "deployment")),
                    destinationDeploymentDirectory);
    } else {
        createSymlink(new File(clusterDepDir), destinationDeploymentDirectory);
    }

    File regDest = new File(destCarbonHome + File.separator + "registry");
    if (clusterRegDir == null) {
        copyFolders(new File(carbonHome + File.separator + "registry"), regDest);
    } else {
        createSymlink(new File(clusterRegDir), regDest);
    }

}
 
Example 14
Source Project: product-ei   Source File: HumanTaskCoordinationTest.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Apply WS-Coordination enabled config files.
 * Copy humantask.xml and b4p-coordination-config.xml configuration files and restart server
 *
 * @throws Exception
 */
private void applyWSCoordinationConfig() throws Exception {
	final String artifactLocation =
			FrameworkPathUtil.getSystemResourceLocation() + BPSTestConstants.DIR_CONFIG + File.separator +
			HumanTaskTestConstants.DIR_WS_COORDINATION + File.separator;

	File humantaskConfigNew = new File(artifactLocation + BPSTestConstants.HUMANTASK_XML);
	File humantaskConfigOriginal = new File(
			FrameworkPathUtil.getCarbonHome() + File.separator + BPSTestConstants.NEW_CONF_DIR + File.separator + BPSTestConstants.HUMANTASK_XML);
	// Do not restart server. We need to apply another config file.
	serverConfigurationManager.applyConfiguration(humantaskConfigNew, humantaskConfigOriginal, true, false);

	File b4pConfigNew = new File(artifactLocation + BPSTestConstants.B4P_COORDINATION_CONFIG_XML);
	File b4pConfigOriginal = new File(FrameworkPathUtil.getCarbonHome() + File.separator + BPSTestConstants.NEW_CONF_DIR + File.separator +
	                                  BPSTestConstants.B4P_COORDINATION_CONFIG_XML);
	serverConfigurationManager.applyConfiguration(b4pConfigNew, b4pConfigOriginal, true, true);
}
 
Example 15
Source Project: product-ei   Source File: BPMNCappDeploymentTestCase.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Deploy the uploaded C-App file
 */

@BeforeClass(alwaysRun = true)
public void deployTask() throws Exception {
    super.init();
    CarbonAppUploaderClient carbonAppUploaderClient =
            new CarbonAppUploaderClient(backEndUrl, sessionCookie);

    carbonAppUploaderClient.uploadCarbonAppArtifact(carFileName + BPMNTestConstants.CAR_EXTENSION
            , new DataHandler(new URL("file:" + File.separator + File.separator +
            FrameworkPathUtil.getSystemResourceLocation() + "artifacts"
            + File.separator + "bpmn" + File.separator + carFileName + BPMNTestConstants.CAR_EXTENSION)));
    isCarFileUploaded = true;
    applicationAdminClient = new ApplicationAdminClient(backEndUrl, sessionCookie);
    boolean result = isCarFileDeployed(carFileName);
    Assert.assertTrue(result, "Car file deployment failed");
}
 
Example 16
@BeforeClass
public void envSetup() throws Exception {
    init();
    final String artifactLocation = FrameworkPathUtil.getSystemResourceLocation() + File
            .separator
                                    + BPMNTestConstants.DIR_ARTIFACTS + File.separator
                                    + BPMNTestConstants.DIR_BPMN + File.separator
                                    + "testArtifactid-1.0.jar";

    ServerConfigurationManager Loader = new ServerConfigurationManager(bpsServer);
    File javaArtifact = new File(artifactLocation);
    Loader.copyToComponentLib(javaArtifact);
    Loader.restartForcefully();

    //reinitialising, as session cookies and other configuration which expired during restart is
    // needs to be reset
    init();
}
 
Example 17
/**
 * The BPMN package being used to test is Invalid, it is used to test how gracefully
 * the system handles the invalid bpmn package,
 *
 * @throws Exception
 */
@Test(groups = {"wso2.bps.test.deploy.invalidPackage"}, description = "Deploy/UnDeploy " +
                                                                      "Invalid Package Test",
      priority = 1, singleThreaded = true)
public void deployUnDeployInvalidBPMNPackage() throws Exception {
    init();
    ActivitiRestClient tester = new ActivitiRestClient(bpsServer.getInstance().getPorts().get
            (BPMNTestConstants.HTTP), bpsServer.getInstance().getHosts().get
            (BPMNTestConstants.DEFAULT));
    String filePath = FrameworkPathUtil.getSystemResourceLocation() + File.separator
                      + BPMNTestConstants.DIR_ARTIFACTS + File.separator
                      + BPMNTestConstants.DIR_BPMN + File.separator + "InvalidHelloApprove.bar";
    String fileName = "InvalidHelloApprove.bar";

    //trying to deploy an invalid bpmn package will cause the server to throw an "error parsing
    //XML" we are using the this message to validate.
    try {
        String[] deploymentResponse;
        deploymentResponse = tester.deployBPMNPackage(filePath, fileName);
        Assert.fail("Invalid package was deployed.");
    } catch (RestClientException | IOException | JSONException exception) {
        Assert.assertTrue("Could not upload the invalid bpmn package",
                          "Error parsing XML".equals(exception.getMessage()));
    }
}
 
Example 18
Source Project: product-ei   Source File: NhttpMaximumOpenConnections.java    License: Apache License 2.0 6 votes vote down vote up
@BeforeClass(alwaysRun = true)
   public void init() throws Exception {
       super.init();

serverConfigurationManagerProp = new ServerConfigurationManager(new AutomationContext("ESB", TestUserMode.SUPER_TENANT_ADMIN));
       String nhttpFile = /*ProductConstant.getResourceLocations(ProductConstant.ESB_SERVER_NAME)*/FrameworkPathUtil.getSystemResourceLocation()  + "artifacts" + separator +
               "ESB" +separator + "synapseconfig" + separator + "MaxOpenConnections" + separator
               + "nhttp.properties";
       File srcFile = new File(nhttpFile);


       serverConfigurationManagerProp.applyConfigurationWithoutRestart(srcFile);

       serverConfigurationManagerAxis2 = new ServerConfigurationManager(new AutomationContext("ESB", TestUserMode.SUPER_TENANT_ADMIN));
       String nhttpAxis2xml = /*ProductConstant.getResourceLocations(ProductConstant.ESB_SERVER_NAME)*/FrameworkPathUtil.getSystemResourceLocation()  + "artifacts" + separator +
               "ESB" +separator +separator + "synapseconfig" + separator + "MaxOpenConnections" + separator + "nhttp"
               + separator + "axis2.xml";
       File axis2File = new File(nhttpAxis2xml);
       serverConfigurationManagerAxis2.applyConfiguration(axis2File);

       super.init();

       list = Collections.synchronizedList(new ArrayList());
       maxOpenConnectionClients = new MaximumOpenConnectionsClient[CONCURRENT_CLIENTS];
       clients = new Thread[CONCURRENT_CLIENTS];
   }
 
Example 19
Source Project: product-es   Source File: WildCardSearch.java    License: Apache License 2.0 6 votes vote down vote up
@BeforeClass(alwaysRun = true)
public void init() throws Exception {
    super.init(userMode);
    genericRestClient = new GenericRestClient();
    queryParamMap = new HashMap<>();
    headerMap = new HashMap<>();
    resourcePath =
            FrameworkPathUtil.getSystemResourceLocation() + "artifacts" + File.separator + "GREG" + File.separator;
    publisherUrl = publisherContext.getContextUrls().getSecureServiceUrl().replace("services", "publisher/apis");
    storeUrl = storeContext.getContextUrls().getSecureServiceUrl().replace("services", "store/apis");
    resourceAdminServiceClient = new ResourceAdminServiceClient(automationContext.getContextUrls().getBackEndUrl(),
            sessionCookie);

    deteleExistingData();

}
 
Example 20
Source Project: product-ei   Source File: ValidPathAxis2XmlTestCase.java    License: Apache License 2.0 6 votes vote down vote up
@BeforeClass(alwaysRun = true)
public void setEnvironment() throws Exception {

    super.init();
    String axis2XmlPath = FrameworkPathUtil.getSystemResourceLocation()
            + "/artifacts/ESB/mediatorconfig/callout/client_repo/conf/axis2.xml";
    String uriSynapse = FrameworkPathUtil.getSystemResourceLocation()
            + "/artifacts/ESB/mediatorconfig/callout/ValidPath_Axis2Xml.xml";

    OMElement lineItem = AXIOMUtil.stringToOM(FileManager.readFile(uriSynapse));
    AXIOMXPath xPath = new AXIOMXPath("//ns:configuration");
    xPath.addNamespace("ns", "http://ws.apache.org/ns/synapse");
    OMElement configuration = (OMElement) xPath.selectSingleNode(lineItem);
    //replacing the path
    configuration.getAttribute(new QName("axis2xml")).setAttributeValue(axis2XmlPath);
    updateESBConfiguration(lineItem);

}
 
Example 21
Source Project: micro-integrator   Source File: SecureStockQuoteClient.java    License: Apache License 2.0 5 votes vote down vote up
public OMElement sendSecuredSimpleStockQuoteRequest(String userName, String password, String trpUrl,
                                                    String securityPolicyPath, String symbol) throws Exception {

    return secureClient
            .sendReceive(userName, password, trpUrl, "getQuote", createStandardRequest(symbol), securityPolicyPath,
                         "alice", "bob",
                         FrameworkPathUtil.getSystemResourceLocation() + "keystores" + File.separator + "products"
                                 + File.separator + "store.jks", "password");

}
 
Example 22
Source Project: micro-integrator   Source File: SecureStockQuoteClient.java    License: Apache License 2.0 5 votes vote down vote up
public OMElement sendSecuredSimpleStockQuoteRequest(String userName, String password, String trpUrl,
                                                    int securityScenarioId, String symbol) throws Exception {

    return secureClient.sendReceive(userName, password, trpUrl, "getQuote", createStandardRequest(symbol),
                                    FrameworkPathUtil.getSystemResourceLocation() + File.separator + "security"
                                            + File.separator + "policies" + File.separator + "scenario"
                                            + securityScenarioId + "-policy.xml", "alice", "bob",
                                    FrameworkPathUtil.getSystemResourceLocation() + File.separator + "keystores"
                                            + File.separator + "products" + File.separator + "store.jks",
                                    "password");

}
 
Example 23
Source Project: micro-integrator   Source File: TestCoverageGenerator.java    License: 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 Project: product-es   Source File: SoapServiceVersioningTestCase.java    License: Apache License 2.0 5 votes vote down vote up
@BeforeClass(alwaysRun = true)
public void init() throws Exception {
    super.init(userMode);
    genericRestClient = new GenericRestClient();
    headerMap = new HashMap<>();
    resourcePath = FrameworkPathUtil.getSystemResourceLocation()
                   + "artifacts" + File.separator + "GREG" + File.separator;
    publisherUrl = automationContext.getContextUrls().getSecureServiceUrl().replace("services", "publisher/apis");
    publisherUrlForVersion = automationContext.getContextUrls().getSecureServiceUrl().replace("services",
                                                                                              "publisher/assets");
    String session = getSessionCookie();
    resourceAdminServiceClient = new ResourceAdminServiceClient(backendURL, session);
    updateEndpointRxt();
    setTestEnvironment();
}
 
Example 25
Source Project: attic-stratos   Source File: StratosTestServerManager.java    License: Apache License 2.0 5 votes vote down vote up
private void insertJacocoAgentToBatScript(String scriptName) throws IOException {
    String jacocoAgentFile = CodeCoverageUtils.getJacocoAgentJarLocation();
    this.coverageDumpFilePath = FrameworkPathUtil.getCoverageDumpFilePath();
    CodeCoverageUtils.insertJacocoAgentToStartupBat(
            new File(this.carbonHome + File.separator + "bin" + File.separator + scriptName + ".bat"),
            new File(this.carbonHome + File.separator + "tmp" + File.separator + scriptName + ".bat"),
            "-Dcatalina.base", "-javaagent:" + jacocoAgentFile + "=destfile=" + this.coverageDumpFilePath + "" +
                    ",append=true,includes=" + CodeCoverageUtils.getInclusionJarsPattern(":"));
}
 
Example 26
@BeforeClass(alwaysRun = true)
public void setUp() throws Exception {
    super.init();
    driver = new ESWebDriver(BrowserManager.getWebDriver());
    baseUrl = getWebAppURL();
    ESUtil.login(driver, baseUrl, PUBLISHER_APP, userInfo.getUserName(), userInfo.getPassword());
    resourcePath = "/_system/governance/servicesx/" + currentUserName + "/" + ASSET_NAME + "/" + VERSION;
    AutomationContext automationContext = new AutomationContext(PRODUCT_GROUP_NAME, TestUserMode.SUPER_TENANT_ADMIN);
    adminUserName = automationContext.getSuperTenant().getTenantAdmin().getUserName();
    adminUserPwd = automationContext.getSuperTenant().getTenantAdmin().getPassword();
    backendURL = automationContext.getContextUrls().getBackEndUrl();
    resourceAdminServiceClient = new ResourceAdminServiceClient(backendURL, adminUserName, adminUserPwd);
    driver.get(baseUrl + "/publisher/assets/servicex/list");
    driver.findElement(By.id("Addservicex")).click();
    driver.findElement(By.name("overview_name")).clear();
    driver.findElement(By.name("overview_name")).sendKeys(ASSET_NAME);
    driver.findElement(By.name("overview_version")).clear();
    driver.findElement(By.name("overview_version")).sendKeys(VERSION);
    driver.findElement(By.name("overview_scopes")).clear();
    driver.findElement(By.name("overview_scopes")).sendKeys(SCOPES);
    driver.findElement(By.name("overview_types")).clear();
    driver.findElement(By.name("overview_types")).sendKeys(TYPES);

    assertTrue(isElementPresent(driver, By.name("images_thumbnail")));
    driver.findElement(By.name("images_thumbnail")).sendKeys(FrameworkPathUtil.getReportLocation()
                                                             +"/../src/test/resources/images/thumbnail.jpg");

    driver.findElement(By.id("btn-create-asset")).click();
    driver.findElementPoll(By.linkText(ASSET_NAME), MAX_POLL_COUNT);
    driver.findElement(By.linkText(ASSET_NAME)).click();
    lifecycleUrl = driver.getCurrentUrl().replace("details", "lifecycle");
}
 
Example 27
Source Project: product-cep   Source File: MQTTEventPublisherClient.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * File path will be created for the file to be read with respect to the artifact folder and file name
 *
 * @param testCaseFolderName Artifact folder name
 * @param dataFileName       Text file to be read
 */
public static String getTestDataFileLocation(String testCaseFolderName, String dataFileName) throws Exception {
    String relativeFilePath = FrameworkPathUtil.getSystemResourceLocation() +
                              CEPIntegrationTestConstants.RELATIVE_PATH_TO_TEST_ARTIFACTS +
                              testCaseFolderName + File.separator + dataFileName;
    relativeFilePath = relativeFilePath.replaceAll("[\\\\/]", Matcher.quoteReplacement(File.separator));
    return relativeFilePath;
}
 
Example 28
Source Project: product-ei   Source File: Sample153TestCase.java    License: Apache License 2.0 5 votes vote down vote up
@Test(groups = "wso2.esb", description = "Custom sequences and endpoints with proxy services")
public void sample153Test() throws Exception {
    String policyPath = FrameworkPathUtil.getSystemResourceLocation() + "security"+ File.separator +"policies"+ File.separator +"scenario27-policy.xml";
    OMElement response = new SecureStockQuoteClient().sendSecuredSimpleStockQuoteRequest(null, null, getProxyServiceURLHttp("StockQuoteProxy"),
                                                                                         policyPath, "Secured");

    String lastPrice = response.getFirstElement().getFirstChildWithName(new QName("http://services.samples/xsd", "last"))
            .getText();
    assertNotNull(lastPrice, "Fault: response message 'last' price null");

    String symbol = response.getFirstElement().getFirstChildWithName(new QName("http://services.samples/xsd", "symbol"))
            .getText();
    assertEquals(symbol, "Secured", "Fault: value 'symbol' mismatched");

}
 
Example 29
@BeforeClass(alwaysRun = true)
public void init() throws Exception {

    super.init();
    serverConfigurationManager = new ServerConfigurationManager(context);
    String secureVaultConfDir =
            FrameworkPathUtil.getSystemResourceLocation() + "artifacts" + File.separator + "ESB" + File.separator
                    + "securevault" + File.separator;
    String confDir =
            CarbonBaseUtils.getCarbonHome() + File.separator + "conf" + File.separator;

    //copy deployment.toml
    String srcToml = secureVaultConfDir + TOML_FILE;
    String targetToml = confDir + TOML_FILE;

    File srcTomlFile = new File(srcToml);
    File targetTomlFile = new File(targetToml);
    serverConfigurationManager.applyConfigurationWithoutRestart(srcTomlFile, targetTomlFile, true);

    //copy password-tmp
    String srcPasswordTemp = secureVaultConfDir + PASSWD_FILE;
    String targetPasswordTemp = CarbonBaseUtils.getCarbonHome() + File.separator + PASSWD_FILE;

    File srcPasswordTempFile = new File(srcPasswordTemp);
    File targetPasswordTempFile = new File(targetPasswordTemp);
    serverConfigurationManager.applyConfigurationWithoutRestart(srcPasswordTempFile, targetPasswordTempFile, false);

    //start server with new configs
    serverConfigurationManager.restartGracefully();
    super.init();

    sender = RabbitMQServerInstance.createProducerWithDeclaration(RABBITMQ_EXCHANGE, RABBITMQ_RX_QUEUE);
    //The consumer proxy cannot be pre-deployed since the queue declaration(which is done in 'initRabbitMQBroker')
    // must happen before deployment.
    loadESBConfigurationFromClasspath(
            "artifacts" + File.separator + "ESB" + File.separator + "securevault" + File.separator
                    + SYNAPSE_CONFIG_FILE);
}
 
Example 30
Source Project: micro-integrator   Source File: TestUtils.java    License: Apache License 2.0 5 votes vote down vote up
public static void deployArtifacts(String depDir, ArtifactType type, String... tasks) throws Exception {

        for (int i = 0; i < tasks.length; i++) {
            File task = new File(FrameworkPathUtil.getSystemResourceLocation() + "artifacts" + File.separator + "ESB"
                                         + File.separator + type.getDirName() + File.separator + tasks[i] + ".xml");
            Utils.deploySynapseConfiguration(task, depDir, type);
        }
    }