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

The following examples show how to use org.wso2.carbon.automation.test.utils.common.FileManager. 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: 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 #2
Source File: HTTPXMLMessageTestCase.java    From product-cep with 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 #3
Source File: ExcelDataServiceTestCase.java    From product-ei with 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 #4
Source File: InvalidClosingTagUnDeployedServiceTestCase.java    From product-ei with Apache License 2.0 6 votes vote down vote up
@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 #5
Source File: ExcelSampleServiceTestCase.java    From product-ei with 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 #6
Source File: RegistryConfiguratorTestCase.java    From product-es with 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 #7
Source File: RegistryConfiguratorTestCase.java    From product-es with 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 #8
Source File: HTTPXMLMessageTestCase.java    From product-cep with 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 #9
Source File: SpringMediationTestCase.java    From product-ei with 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 #10
Source File: DynamicSSLProfilesPTTListenerTestCase.java    From product-ei with Apache License 2.0 5 votes vote down vote up
/**
 * 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 #11
Source File: DynamicSSLProfilesPTTListenerTestCase.java    From product-ei with Apache License 2.0 5 votes vote down vote up
/**
 * 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 #12
Source File: AGSpreadDataServiceTestCase.java    From product-ei with 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 #13
Source File: CSVDataServiceTestCase.java    From product-ei with 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 #14
Source File: CSVSampleServiceTestCase.java    From product-ei with 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 #15
Source File: GSpreadDataServiceTestCase.java    From product-ei with 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 #16
Source File: JMXStatisticsTestCase.java    From product-ei with 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 #17
Source File: SpringMediationTestCase.java    From micro-integrator with 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 #18
Source File: DynamicSSLProfilesPTTListenerTestCase.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * 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 #19
Source File: DynamicSSLProfilesPTTListenerTestCase.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * 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
Source File: AGSpreadDataServiceTestCase.java    From micro-integrator with 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 #21
Source File: CSVSampleServiceTestCase.java    From micro-integrator with 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 #22
Source File: ExcelSampleServiceTestCase.java    From micro-integrator with 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 #23
Source File: GSpreadDataServiceTestCase.java    From micro-integrator with 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 #24
Source File: JMXStatisticsTestCase.java    From micro-integrator with 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 #25
Source File: EventSimulatorTestCase.java    From product-cep with 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 File: DSSTestCaseUtils.java    From micro-integrator with 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 File: DSSTestCaseUtils.java    From product-ei with 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));
}