org.wso2.carbon.automation.extensions.servers.utils.ArchiveExtractor Java Examples
The following examples show how to use
org.wso2.carbon.automation.extensions.servers.utils.ArchiveExtractor.
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: CarbonServerManager.java From micro-integrator with Apache License 2.0 | 5 votes |
/** * Unzip carbon zip file and return the carbon home. Based on the coverage configuration in automation.xml * This method will inject jacoco agent to the carbon server startup scripts. * * @param carbonServerZipFile - Carbon zip file, which should be specified in test module pom * @return - carbonHome - carbon home * @throws IOException - If pack extraction fails */ public synchronized String setUpCarbonHome(String carbonServerZipFile, String startupScriptName) throws IOException, AutomationFrameworkException { if (process != null) { // An instance of the server is running return carbonHome; } int indexOfZip = carbonServerZipFile.lastIndexOf(".zip"); if (indexOfZip == -1) { throw new IllegalArgumentException(carbonServerZipFile + " is not a zip file"); } String fileSeparator = (File.separator.equals("\\")) ? "\\" : "/"; if (fileSeparator.equals("\\")) { carbonServerZipFile = carbonServerZipFile.replace("/", "\\"); } String extractedCarbonDir = carbonServerZipFile .substring(carbonServerZipFile.lastIndexOf(fileSeparator) + 1, indexOfZip); FileManipulator.deleteDir(extractedCarbonDir); String extractDir = "carbontmp" + System.currentTimeMillis(); String baseDir = (System.getProperty("basedir", ".")) + File.separator + "target"; log.info("Extracting carbon zip file.. "); new ArchiveExtractor().extractFile(carbonServerZipFile, baseDir + File.separator + extractDir); carbonHome = new File(baseDir).getAbsolutePath() + File.separator + extractDir + File.separator + extractedCarbonDir; copyResources(); try { //read coverage status from automation.xml isCoverageEnable = Boolean.parseBoolean(automationContext.getConfigurationValue("//coverage")); } catch (XPathExpressionException e) { throw new AutomationFrameworkException("Coverage configuration not found in automation.xml", e); } //insert Jacoco agent configuration to carbon server startup script. This configuration //cannot be directly pass as server startup command due to script limitation. if (isCoverageEnable) { instrumentForCoverage(startupScriptName); } return carbonHome; }
Example #2
Source File: CarbonServerManager.java From product-ei with Apache License 2.0 | 5 votes |
/** * Unzip carbon zip file and return the carbon home. Based on the coverage configuration in automation.xml * This method will inject jacoco agent to the carbon server startup scripts. * * @param carbonServerZipFile - Carbon zip file, which should be specified in test module pom * @return - carbonHome - carbon home * @throws IOException - If pack extraction fails */ public synchronized String setUpCarbonHome(String carbonServerZipFile) throws IOException, AutomationFrameworkException { if (process != null) { // An instance of the server is running return carbonHome; } int indexOfZip = carbonServerZipFile.lastIndexOf(".zip"); if (indexOfZip == -1) { throw new IllegalArgumentException(carbonServerZipFile + " is not a zip file"); } String fileSeparator = (File.separator.equals("\\")) ? "\\" : "/"; if (fileSeparator.equals("\\")) { carbonServerZipFile = carbonServerZipFile.replace("/", "\\"); } String extractedCarbonDir = carbonServerZipFile.substring(carbonServerZipFile.lastIndexOf(fileSeparator) + 1, indexOfZip); FileManipulator.deleteDir(extractedCarbonDir); String extractDir = "carbontmp" + System.currentTimeMillis(); String baseDir = (System.getProperty("basedir", ".")) + File.separator + "target"; log.info("Extracting carbon zip file.. "); new ArchiveExtractor().extractFile(carbonServerZipFile, baseDir + File.separator + extractDir); carbonHome = new File(baseDir).getAbsolutePath() + File.separator + extractDir + File.separator + extractedCarbonDir; try { //read coverage status from automation.xml isCoverageEnable = Boolean.parseBoolean(automationContext.getConfigurationValue("//coverage")); } catch (XPathExpressionException e) { throw new AutomationFrameworkException("Coverage configuration not found in automation.xml", e); } //insert Jacoco agent configuration to carbon server startup script. This configuration //cannot be directly pass as server startup command due to script limitation. if (isCoverageEnable) { instrumentForCoverage(); } return carbonHome; }
Example #3
Source File: CarbonServerManagerExtension.java From product-iots with Apache License 2.0 | 5 votes |
/** * Unzip carbon zip file and return the carbon home. Based on the coverage configuration in automation.xml * This method will inject jacoco agent to the carbon server startup scripts. * * @param carbonServerZipFile - Carbon zip file, which should be specified in test module pom * @return - carbonHome - carbon home * @throws IOException - If pack extraction fails */ public synchronized String setUpCarbonHome(String carbonServerZipFile) throws IOException, AutomationFrameworkException { if(this.process != null) { return this.carbonHome; } else { int indexOfZip = carbonServerZipFile.lastIndexOf(".zip"); if(indexOfZip == -1) { throw new IllegalArgumentException(carbonServerZipFile + " is not a zip file"); } else { String fileSeparator = File.separator.equals("\\")?"\\":"/"; if(fileSeparator.equals("\\")) { carbonServerZipFile = carbonServerZipFile.replace("/", "\\"); } String extractedCarbonDir = carbonServerZipFile.substring(carbonServerZipFile.lastIndexOf(fileSeparator) + 1, indexOfZip); FileManipulator.deleteDir(extractedCarbonDir); String extractDir = "carbontmp" + System.currentTimeMillis(); String baseDir = System.getProperty("basedir", ".") + File.separator + "target"; log.info("Extracting carbon zip file.. "); (new ArchiveExtractor()).extractFile(carbonServerZipFile, baseDir + File.separator + extractDir); this.carbonHome = (new File(baseDir)).getAbsolutePath() + File.separator + extractDir + File.separator + extractedCarbonDir; try { this.isCoverageEnable = Boolean.parseBoolean(this.automationContext.getConfigurationValue("//coverage")); } catch (XPathExpressionException var8) { throw new AutomationFrameworkException("Coverage configuration not found in automation.xml", var8); } if(this.isCoverageEnable) { this.instrumentForCoverage(); } return this.carbonHome; } } }
Example #4
Source File: StratosTestServerManager.java From attic-stratos with Apache License 2.0 | 4 votes |
public synchronized String setUpCarbonHome(String carbonServerZipFile) throws IOException, AutomationFrameworkException { if (this.process != null) { return this.carbonHome; } else { int indexOfZip = carbonServerZipFile.lastIndexOf(".zip"); if (indexOfZip == -1) { throw new IllegalArgumentException(carbonServerZipFile + " is not a zip file"); } else { String fileSeparator = File.separator.equals("\\") ? "\\" : "/"; if (fileSeparator.equals("\\")) { carbonServerZipFile = carbonServerZipFile.replace("/", "\\"); } String extractedCarbonDir = carbonServerZipFile .substring(carbonServerZipFile.lastIndexOf(fileSeparator) + 1, indexOfZip); FileManipulator.deleteDir(extractedCarbonDir); String extractDir = "carbontmp" + System.currentTimeMillis(); String baseDir = System.getProperty("basedir", ".") + File.separator + "target"; log.info("Extracting carbon zip file.. "); (new ArchiveExtractor()).extractFile(carbonServerZipFile, baseDir + File.separator + extractDir); this.carbonHome = (new File(baseDir)).getAbsolutePath() + File.separator + extractDir + File.separator + extractedCarbonDir; try { this.isCoverageEnable = Boolean .parseBoolean(this.automationContext.getConfigurationValue("//coverage")); } catch (XPathExpressionException var8) { throw new AutomationFrameworkException("Coverage configuration not found in automation.xml", var8); } // Fix startup script issue by copying stratos.sh as stratos-server.sh // TODO: remove this class after automation engine provides a way to pass startup script name // currently startup script should be either wso2server.sh or contain the string 'server' FileUtils.copyFile(new File(carbonHome + File.separator + "bin" + File.separator + "stratos.sh"), new File(carbonHome + File.separator + "bin" + File.separator + "stratos-server.sh")); if (this.isCoverageEnable) { this.instrumentForCoverage(); } return this.carbonHome; } } }