Java Code Examples for org.wso2.carbon.automation.engine.frameworkutils.FrameworkPathUtil#getSystemResourceLocation()

The following examples show how to use org.wso2.carbon.automation.engine.frameworkutils.FrameworkPathUtil#getSystemResourceLocation() . 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: PropertyIntegrationHTTP_SCTestCase.java    From product-ei with Apache License 2.0 6 votes vote down vote up
@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 2
Source File: ServerUtils.java    From micro-integrator with 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 3
Source File: InvalidBPMNPackageDeploymentTestCase.java    From product-ei with Apache License 2.0 6 votes vote down vote up
/**
 * 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 4
Source File: NhttpMaximumOpenConnections.java    From product-ei with 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 5
Source File: StreamingXpathExceptionTestCase.java    From product-ei with Apache License 2.0 6 votes vote down vote up
@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 6
Source File: LifecycleUtil.java    From product-es with 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 7
Source File: CallOutMediatorWithMTOMTestCase.java    From product-ei with Apache License 2.0 5 votes vote down vote up
@Test(groups = { "wso2.esb" },
      description = "callOutMediatorWithMTOMTest")
public void callOutMediatorWithMTOMTest() throws IOException {
    String targetEPR = getProxyServiceURLHttp("CallOutMediatorWithMTOMProxy");
    String fileName =
            FrameworkPathUtil.getSystemResourceLocation() + "artifacts" + File.separator + "ESB" + File.separator
                    + "mtom" + File.separator + "asf-logo.gif";
    sendUsingMTOM(fileName, targetEPR);
}
 
Example 8
Source File: TcpClient.java    From product-ei with Apache License 2.0 5 votes vote down vote up
public TcpClient() {
    String repositoryPath = /*ProductConstant.getModuleClientPath()*/FrameworkPathUtil.getSystemResourceLocation()+File.separator+"client";


    File repository = new File(repositoryPath);
    try {
        cfgCtx =
                ConfigurationContextFactory.createConfigurationContextFromFileSystem(repository.getCanonicalPath(),
                                                                                     /*ProductConstant.getResourceLocations(ProductConstant.ESB_SERVER_NAME)*/FrameworkPathUtil.getSystemResourceLocation()+File.separator + "artifacts"+File.separator + "ESB"
                                                                                     + File.separator + "tcp" + File.separator + "transport" + File.separator + "client_axis2.xml");
        serviceClient = new ServiceClient(cfgCtx, null);
    } catch (Exception e) {
        log.error(e);
    }
}
 
Example 9
Source File: ESBJAVA4909MultipartRelatedTestCase.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
@Test(groups = { "wso2.esb" }, description = "ESBJAVA4909MultipartTest")
public void callOutMediatorWithMTOMTest() throws IOException {
    String targetEPR = getProxyServiceURLHttp("MTOMChecker");
    String fileName =
            FrameworkPathUtil.getSystemResourceLocation() + "artifacts" + File.separator + "ESB" + File.separator
                    + "mtom" + File.separator + "content.xml";
    sendUsingMTOM(fileName, targetEPR);
}
 
Example 10
Source File: PublisherLoginTestCase.java    From product-es with 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");
}
 
Example 11
Source File: RestResourcePublisherESTestCase.java    From product-es with Apache License 2.0 5 votes vote down vote up
@BeforeClass(alwaysRun = true)
public void init() throws Exception {
    super.init(userMode);
    genericRestClient = new GenericRestClient();
    queryParamMap = new HashMap<String, String>();
    headerMap = new HashMap<String, String>();
    resourcePath = FrameworkPathUtil.getSystemResourceLocation()
                   + "artifacts" + File.separator + "GREG" + File.separator;
    publisherUrl = publisherContext.getContextUrls()
            .getSecureServiceUrl().replace("services", "publisher/apis");
}
 
Example 12
Source File: RestResourceSearchAndAdvanceSearchTestCase.java    From product-es with Apache License 2.0 5 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");
    crudTestCommonUtils = new ESTestCommonUtils(genericRestClient, publisherUrl, headerMap);
    resourceAdminServiceClient = new ResourceAdminServiceClient(automationContext.getContextUrls().getBackEndUrl(),
            sessionCookie);

    deteleExistingData();
}
 
Example 13
Source File: ThriftServer.java    From product-ei with Apache License 2.0 5 votes vote down vote up
public String getResourceFilePath(String testCaseFolderName, String resourceFileName) {
	String relativeFilePath = FrameworkPathUtil.getSystemResourceLocation() +
	                          "artifacts" + File.separator + "ESB" + File.separator +
	                          testCaseFolderName +
	                          File.separator +
	                          resourceFileName;
	return relativeFilePath.replaceAll("[\\\\/]", Matcher.quoteReplacement(File.separator));
}
 
Example 14
Source File: CallOutMediatorWithMTOMTestCase.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
@Test(groups = { "wso2.esb" }, description = "callOutMediatorWithMTOMTest")
public void callOutMediatorWithMTOMTest() throws IOException {
    String targetEPR = getProxyServiceURLHttp("CallOutMediatorWithMTOMProxy");
    String fileName =
            FrameworkPathUtil.getSystemResourceLocation() + "artifacts" + File.separator + "ESB" + File.separator
                    + "mtom" + File.separator + "asf-logo.gif";
    sendUsingMTOM(fileName, targetEPR);
}
 
Example 15
Source File: Sample153TestCase.java    From product-ei with 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 16
Source File: CustomAssetCRUDTestCase.java    From product-es with 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 = publisherContext.getContextUrls()
            .getSecureServiceUrl().replace("services", "publisher/apis");
    setTestEnvironment();
}
 
Example 17
Source File: PropertyIntegrationForceSCAcceptedPropertyTestCase.java    From product-ei with Apache License 2.0 5 votes vote down vote up
@Test(groups = "wso2.esb", description = "Testing functionality of FORCE_SC_ACCEPTED " +
                                         "- Enabled False")
public void testFORCE_SC_ACCEPTEDPropertyEnabledFalseScenario() throws Exception {
    verifyProxyServiceExistence("FORCE_SC_ACCEPTED_FalseTestProxy");

    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("FORCE_SC_ACCEPTED_FalseTestProxy"));
    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, 200, "Response status should be 200");

}
 
Example 18
Source File: AssertNotesESTestCase.java    From product-es with Apache License 2.0 5 votes vote down vote up
@BeforeClass(alwaysRun = true)
public void init() throws Exception {
    super.init(userMode);
    noteName = "testNote33";
    assetType = "restservice";
    genericRestClient = new GenericRestClient();
    queryParamMap = new HashMap<String, String>();
    headerMap = new HashMap<String, String>();
    resourcePath = FrameworkPathUtil.getSystemResourceLocation()
                   + "artifacts" + File.separator + "GREG" + File.separator + "json" + File.separator;
    publisherUrl = publisherContext.getContextUrls()
            .getSecureServiceUrl().replace("services", "publisher/apis");
    SetTestEnvironment();
}
 
Example 19
Source File: TestConfigurationProvider.java    From micro-integrator with Apache License 2.0 4 votes vote down vote up
public static String getResourceLocation(String productName) {
    return FrameworkPathUtil.getSystemResourceLocation() + File.separator + "artifacts" + File.separator
            + productName;
}
 
Example 20
Source File: JMSPublisherClient.java    From product-cep with Apache License 2.0 3 votes vote down vote up
/**
 * Construct the data file location using the testcase folder name and the file name
 *
 * @param testCaseFolderName    Testcase folder name which is in the test artifacts folder
 * @param dataFileName          data file name with the extension to be read
 *
 */
private static String getTestDataFileLocation(String testCaseFolderName, String dataFileName){
    String relativeFilePath = FrameworkPathUtil.getSystemResourceLocation() + CEPIntegrationTestConstants
            .RELATIVE_PATH_TO_TEST_ARTIFACTS + testCaseFolderName + File.separator + dataFileName;
    relativeFilePath = relativeFilePath.replaceAll("[\\\\/]", Matcher.quoteReplacement(File.separator));
    return relativeFilePath;
}