Java Code Examples for org.wso2.carbon.automation.test.utils.common.FileManager

The following examples show how to use org.wso2.carbon.automation.test.utils.common.FileManager. 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
@BeforeClass(alwaysRun = true)
public void serviceDeployment() throws Exception {
    super.init();
    resourceFileLocation = getResourceLocation();
    String serviceFilePath = resourceFileLocation + File.separator + "dbs" + File.separator +
                             "rdbms" + File.separator + "MySql" + File.separator + serviceFile;
    
    createArtifact(serviceFilePath, getSqlScript());
    dataServiceAdminClient =
            new DataServiceFileUploaderClient(dssContext.getContextUrls().getBackEndUrl(), sessionCookie);

    ByteArrayDataSource dbs;
    String content = FileManager.readFile(serviceFilePath);
    Assert.assertTrue(content.contains("</query>"), "query tag missing");
    content = content.replaceFirst("</query>", "</que>");
    dbs = new ByteArrayDataSource(content.getBytes());
    dhArtifact = new DataHandler(dbs);

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

    super.init();
    addResource();
    try {
        checkResourceExist("/_system/config/automation/resources/excel/Products.xls");
        checkResourceExist("/_system/config/automation/resources/excel/transform.xslt");
    } catch (Exception e) {
        e.printStackTrace();
        Assert.fail("ExcelDataServiceTestCase::serviceDeployment Failed, Required resources does deployed correctly to registry");
    }
    deployService(serviceName,
                  AXIOMUtil.stringToOM(FileManager.readFile(getResourceLocation()
                                                            + File.separator + "dbs" + File.separator
                                                            + "excel" + File.separator
                                                            + "ExcelDataService.dbs")));

}
 
Example 3
Source Project: product-cep   Source File: HTTPXMLMessageTestCase.java    License: Apache License 2.0 6 votes vote down vote up
@BeforeClass(alwaysRun = true)
public void init()
        throws Exception {
    super.init(TestUserMode.SUPER_TENANT_ADMIN);
    serverManager = new ServerConfigurationManager(cepServer);

    try {
        String warFilePath = FrameworkPathUtil.getSystemResourceLocation() +
                             "artifacts" + File.separator + "CEP" + File.separator + "war"
                             + File.separator;

        webAppDirectoryPath = FrameworkPathUtil.getCarbonHome() + File.separator + "repository" + File.separator +
                              "deployment" + File.separator + "server" + File.separator + "webapps" + File.separator;
        FileManager.copyResourceToFileSystem(warFilePath + webAppFileName, webAppDirectoryPath, webAppFileName);
        Thread.sleep(5000);
    } catch (Exception e) {
        throw new RemoteException("Exception caught when deploying the war file into CEP server", e);
    }

    String loggedInSessionCookie = new LoginLogoutClient(cepServer).login();
    eventProcessorAdminServiceClient = configurationUtil.getEventProcessorAdminServiceClient(backendURL, loggedInSessionCookie);
    eventStreamManagerAdminServiceClient = configurationUtil.getEventStreamManagerAdminServiceClient(backendURL, loggedInSessionCookie);
    eventReceiverAdminServiceClient = configurationUtil.getEventReceiverAdminServiceClient(backendURL, loggedInSessionCookie);
    eventPublisherAdminServiceClient = configurationUtil.getEventPublisherAdminServiceClient(backendURL, loggedInSessionCookie);
}
 
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: JMXStatisticsTestCase.java    License: Apache License 2.0 5 votes vote down vote up
@BeforeClass(alwaysRun = true)
public void serviceDeployment() throws Exception {

    super.init();
    deployService(serviceName, AXIOMUtil.stringToOM(FileManager.readFile(
            getResourceLocation() + File.separator + "dbs" + File.separator + "gspread" + File.separator
                    + "GSpreadDataService.dbs")));
    //todo getting hostname
    jmxClient = new JMXClient(serviceName, "localhost", userInfo.getUserName(), userInfo.getPassword());
    jmxClient.connect();

}
 
Example 6
@BeforeClass(alwaysRun = true)
public void serviceDeployment() throws Exception {

    super.init();
    deployService(serviceName, AXIOMUtil.stringToOM(FileManager.readFile(
            getResourceLocation() + File.separator + "dbs" + File.separator + "gspread" + File.separator
                    + "GSpreadDataService.dbs")));

}
 
Example 7
@BeforeClass(alwaysRun = true)
public void serviceDeployment() throws Exception {

    super.init();

    deployService(serviceName, AXIOMUtil.stringToOM(FileManager.readFile(
            getResourceLocation() + File.separator + "dbs" + File.separator + "excel" + File.separator
                    + "ExcelSampleService.dbs")));
}
 
Example 8
Source Project: micro-integrator   Source File: CSVSampleServiceTestCase.java    License: Apache License 2.0 5 votes vote down vote up
@BeforeClass(alwaysRun = true)
public void serviceDeployment() throws Exception {

    super.init();
    deployService(serviceName, AXIOMUtil.stringToOM(FileManager.readFile(
            getResourceLocation() + File.separator + "dbs" + File.separator + "csv" + File.separator
                    + "CSVSampleService.dbs")));

}
 
Example 9
@BeforeClass(alwaysRun = true)
public void serviceDeployment() throws Exception {

    super.init();
    deployService(serviceName, AXIOMUtil.stringToOM(FileManager.readFile(
            getResourceLocation() + File.separator + "dbs" + File.separator + "gspread" + File.separator
                    + "GSpreadDataService.dbs")));

}
 
Example 10
/**
 * Copy content of Dynamic SSL profiles configuration files to the file configured in axis2.xml
 *
 * @throws IOException
 */
private void updateProfileConfigurationFiles() throws Exception {
    File sourceFile = new File(configLocation + "updatedlistenerprofiles.xml");
    FileManager.deleteFile(configLocation + "listenerprofiles.xml");

    try {
        FileManager.copyFile(sourceFile, (configLocation + "listenerprofiles.xml"));
    } catch (IOException e) {
        log.error("Error updating Dynamic SSL Profiles configuration ", e);
        throw new Exception(e);
    }
}
 
Example 11
/**
 * Restore Dynamic SSL configuration files to its original content
 *
 * @throws IOException
 */
private void rollbackProfileConfigurationFiles() throws Exception {
    File sourceFile = new File(configLocation + "restorelistenerprofiles.xml");
    FileManager.deleteFile(configLocation + "listenerprofiles.xml");

    try {
        FileManager.copyFile(sourceFile, (configLocation + "listenerprofiles.xml"));
    } catch (IOException e) {
        log.error("Error restoring Dynamic SSL Profiles configuration ", e);
        throw new Exception(e);
    }
}
 
Example 12
Source Project: micro-integrator   Source File: SpringMediationTestCase.java    License: Apache License 2.0 5 votes vote down vote up
private void updateSpringBeanXML()
        throws ResourceAdminServiceExceptionException, IOException, InterruptedException {

    ResourceAdminServiceClient resourceAdminServiceClient = new ResourceAdminServiceClient(
            contextUrls.getBackEndUrl(), getSessionCookie());
    String filePath = getESBResourceLocation() + File.separator + "mediatorconfig" + File.separator + "spring"
            + File.separator + "utils" + File.separator + "updating_spring.xml";

    resourceAdminServiceClient
            .updateTextContent("/_system/config/spring/springbean.xml", FileManager.readFile(filePath));
    Thread.sleep(20000);           //need to persist changes done to spring xml
}
 
Example 13
Source Project: product-ei   Source File: JMXStatisticsTestCase.java    License: Apache License 2.0 5 votes vote down vote up
@BeforeClass(alwaysRun = true)
public void serviceDeployment() throws Exception {

    super.init();
    deployService(serviceName,
                  AXIOMUtil.stringToOM(FileManager.readFile(getResourceLocation() + File.separator
                                                            + "dbs" + File.separator + "gspread" + File.separator
                                                            + "GSpreadDataService.dbs")));
    //todo getting hostname
    jmxClient = new JMXClient(serviceName, "localhost",
                              userInfo.getUserName(), userInfo.getPassword());
    jmxClient.connect();

}
 
Example 14
Source Project: product-ei   Source File: GSpreadDataServiceTestCase.java    License: Apache License 2.0 5 votes vote down vote up
@BeforeClass(alwaysRun = true)
public void serviceDeployment() throws Exception {

    super.init();
    deployService(serviceName,
                  AXIOMUtil.stringToOM(FileManager.readFile(getResourceLocation() + File.separator
                                                            + "dbs" + File.separator + "gspread" + File.separator
                                                            + "GSpreadDataService.dbs")));

}
 
Example 15
Source Project: product-ei   Source File: ExcelSampleServiceTestCase.java    License: Apache License 2.0 5 votes vote down vote up
@BeforeClass(alwaysRun = true)
public void serviceDeployment() throws Exception {

    super.init();

    deployService(serviceName,
                  AXIOMUtil.stringToOM(FileManager.readFile(getResourceLocation()
                                                            + File.separator + "dbs" + File.separator
                                                            + "excel" + File.separator + "ExcelSampleService.dbs")));
}
 
Example 16
Source Project: product-ei   Source File: CSVSampleServiceTestCase.java    License: Apache License 2.0 5 votes vote down vote up
@BeforeClass(alwaysRun = true)
public void serviceDeployment() throws Exception {

    super.init();
    deployService(serviceName,
                  AXIOMUtil.stringToOM(FileManager.readFile(getResourceLocation()
                                                            + File.separator + "dbs" + File.separator
                                                            + "csv" + File.separator + "CSVSampleService.dbs")));

}
 
Example 17
Source Project: product-ei   Source File: CSVDataServiceTestCase.java    License: Apache License 2.0 5 votes vote down vote up
@BeforeClass(alwaysRun = true)
public void serviceDeployment() throws Exception {

    super.init();
    addResource();
    deployService(serviceName,
                  AXIOMUtil.stringToOM(FileManager.readFile(getResourceLocation()
                                                            + File.separator + "dbs" + File.separator
                                                            + "csv" + File.separator
                                                            + "CSVDataService.dbs")));

}
 
Example 18
Source Project: product-ei   Source File: AGSpreadDataServiceTestCase.java    License: Apache License 2.0 5 votes vote down vote up
@BeforeClass(alwaysRun = true)
public void serviceDeployment() throws Exception {

    super.init();
    deployService(serviceName,
                  AXIOMUtil.stringToOM(FileManager.readFile(getResourceLocation() + File.separator
                                                            + "dbs" + File.separator + "gspread" + File.separator
                                                            + "GSpreadDataService.dbs")));

}
 
Example 19
/**
 * Copy content of Dynamic SSL profiles configuration files to the file configured in axis2.xml
 *
 * @throws IOException
 */
private void updateProfileConfigurationFiles() throws Exception {
    File sourceFile = new File(configLocation + "updatedlistenerprofiles.xml");
    FileManager.deleteFile(configLocation + "listenerprofiles.xml");

    try {
        FileManager.copyFile(sourceFile, (configLocation + "listenerprofiles.xml"));
    } catch (IOException e) {
        log.error("Error updating Dynamic SSL Profiles configuration ", e);
        throw new Exception(e);
    }
}
 
Example 20
/**
 * Restore Dynamic SSL configuration files to its original content
 *
 * @throws IOException
 */
private void rollbackProfileConfigurationFiles() throws Exception {
    File sourceFile = new File(configLocation + "restorelistenerprofiles.xml");
    FileManager.deleteFile(configLocation + "listenerprofiles.xml");

    try {
        FileManager.copyFile(sourceFile, (configLocation + "listenerprofiles.xml"));
    } catch (IOException e) {
        log.error("Error restoring Dynamic SSL Profiles configuration ", e);
        throw new Exception(e);
    }
}
 
Example 21
Source Project: product-ei   Source File: SpringMediationTestCase.java    License: Apache License 2.0 5 votes vote down vote up
private void updateSpringBeanXML()
        throws ResourceAdminServiceExceptionException, IOException, InterruptedException {

    ResourceAdminServiceClient resourceAdminServiceClient =
            new ResourceAdminServiceClient(contextUrls.getBackEndUrl(), getSessionCookie());
    String filePath = getESBResourceLocation() + File.separator + "mediatorconfig" + File.separator
                      + "spring" + File.separator + "utils" + File.separator + "updating_spring.xml";

    resourceAdminServiceClient
            .updateTextContent("/_system/config/spring/springbean.xml", FileManager.readFile(filePath));
    Thread.sleep(20000);           //need to persist changes done to spring xml
}
 
Example 22
Source Project: product-cep   Source File: HTTPXMLMessageTestCase.java    License: Apache License 2.0 5 votes vote down vote up
@AfterClass(alwaysRun = true)
public void destroy() throws Exception {
    if (webAppDirectoryPath != null) {
        FileManager.deleteFile(webAppDirectoryPath + webAppFileName);
    }
    super.cleanup();
}
 
Example 23
Source Project: product-es   Source File: RegistryConfiguratorTestCase.java    License: Apache License 2.0 5 votes vote down vote up
private void copyMimeMappingFile() throws IOException {

        String fileName = "mime.mappings";
        String targetPath = CarbonUtils.getCarbonHome() + File.separator + "repository" +
                File.separator + "conf" + File.separator + "etc";
        String sourcePath = getTestArtifactLocation() + "artifacts" +
                File.separator + "GREG" + File.separator + "config" + File.separator +
                "mime.mappings";
        FileManager.copyResourceToFileSystem(sourcePath, targetPath, fileName);
    }
 
Example 24
Source Project: product-es   Source File: RegistryConfiguratorTestCase.java    License: Apache License 2.0 5 votes vote down vote up
private void copyMimeMappingFile() throws IOException {

        String fileName = "mime.mappings";
        String targetPath = CarbonUtils.getCarbonHome() + File.separator + "repository" +
                File.separator + "conf" + File.separator + "etc";
        String sourcePath = getTestArtifactLocation() + "artifacts" +
                File.separator + "GREG" + File.separator + "config" + File.separator +
                "mime.mappings";
        FileManager.copyResourceToFileSystem(sourcePath, targetPath, fileName);
    }
 
Example 25
Source Project: product-cep   Source File: EventSimulatorTestCase.java    License: Apache License 2.0 4 votes vote down vote up
@Test(groups = {"wso2.cep"}, description = "Testing Event Simulation (Play, Pause and Resume)")
public void EventSimulatorTestScenario() throws Exception {
    int startESCount = eventStreamManagerAdminServiceClient.getEventStreamCount();
    int startEPCount = eventPublisherAdminServiceClient.getActiveEventPublisherCount();
    Wso2EventServer wso2EventServer = new Wso2EventServer("eventsimulatorFiles", CEPIntegrationTestConstants.TCP_PORT, true);


    //Add StreamDefinition
    String streamDefinitionAsString = getJSONArtifactConfiguration("eventsimulatorFiles",
            "TempStream_1.0.0.json");
    eventStreamManagerAdminServiceClient.addEventStreamAsString(streamDefinitionAsString);
    Assert.assertEquals(eventStreamManagerAdminServiceClient.getEventStreamCount(), startESCount + 1);

    //Add Text Logger
    String eventPublisherConfig = getXMLArtifactConfiguration("eventsimulatorFiles", "tempEventPublisher.xml");
    eventPublisherAdminServiceClient.addEventPublisherConfiguration(eventPublisherConfig);
    Assert.assertEquals(eventPublisherAdminServiceClient.getActiveEventPublisherCount(), startEPCount + 1);

    //Copy Event Simulator File
    String eventSimulatorFilePath = FrameworkPathUtil.getSystemResourceLocation() +
            "artifacts" + File.separator + "CEP" + File.separator + "eventsimulatorFiles"
            + File.separator;

    String eventSimulatorDirectoryPath = FrameworkPathUtil.getCarbonHome() + File.separator
            + "repository" + File.separator + "deployment" + File.separator + "server"
            + File.separator + "eventsimulatorfiles" + File.separator;
    try {
        FileManager.copyResourceToFileSystem(eventSimulatorFilePath + "events.csv", eventSimulatorDirectoryPath, "events.csv");
    } catch (Exception e) {
        throw new RemoteException("Exception caught when deploying the car file into CEP server", e);
    }
    log.info("deploying Event Simulator File...");
    Thread.sleep(35000);

    wso2EventServer.startServer();

    eventSimulatorAdminServiceClient.sendConfigDetails("events.csv", "TempStream:1.0.0", ",", 1000);
    Thread.sleep(10000);
    eventSimulatorAdminServiceClient.sendEventsViaFile("events.csv");
    Thread.sleep(3000);
    eventSimulatorAdminServiceClient.pauseEventsViaFile("events.csv");
    Thread.sleep(3000);
    eventSimulatorAdminServiceClient.resumeEventsViaFile("events.csv");
    Thread.sleep(10000);

    Assert.assertEquals(wso2EventServer.getMsgCount(), 13, "Incorrect number of messages consumed!");
    Thread.sleep(2000);

    eventStreamManagerAdminServiceClient.removeEventStream("org.wso2.event.sensor.stream", "1.0.0");
    eventPublisherAdminServiceClient.removeInactiveEventPublisherConfiguration("logger.xml");
    eventSimulatorAdminServiceClient.deleteFile("events.csv");
    wso2EventServer.stop();

    Thread.sleep(2000);

}
 
Example 26
Source Project: micro-integrator   Source File: DSSTestCaseUtils.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * @param filePath to the resource file
 * @return content of the file as String
 * @throws IOException
 */
public String getContentFrom(String filePath) throws IOException {
    return FileManager.readFile(new File(filePath));
}
 
Example 27
Source Project: product-ei   Source File: DSSTestCaseUtils.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * @param  filePath to the resource file
 * @return content of the file as String
 * @throws IOException
 */
public String getContentFrom(String filePath) throws IOException {
    return FileManager.readFile(new File(filePath));
}