From e2108e5c2924ec119701f2bd69c53a6aa56b8ca1 Mon Sep 17 00:00:00 2001 From: madhawap Date: Tue, 30 May 2017 11:37:48 +0530 Subject: [PATCH 1/6] Upgraded carbon.device.mgt and carbon.device.mgt.plugins versions Upgraded the versions carbon.device.mgt.version to 2.0.69 and carbon.device.mgt.plugins.version to 3.0.37 --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 643baf36..04b80c00 100644 --- a/pom.xml +++ b/pom.xml @@ -1512,7 +1512,7 @@ - 2.0.68 + 2.0.69 [2.0.0, 3.0.0) @@ -1520,7 +1520,7 @@ - 3.0.36 + 3.0.37 6.1.80 From 5c782a6c15257242c5062b90b02e7033d42f8486 Mon Sep 17 00:00:00 2001 From: GDLMadushanka Date: Mon, 5 Jun 2017 16:40:45 +0530 Subject: [PATCH 2/6] CarbonServerManager moved to IOTS from platform integration test tools --- .../CarbonServerManagerExtension.java | 335 ++++++++++++++++++ .../extensions/CustomTestServerManager.java | 12 +- modules/integration/tests-iot-web-ui/pom.xml | 4 + .../extension/CustomTestServerManager.java | 15 +- pom.xml | 4 +- 5 files changed, 354 insertions(+), 16 deletions(-) create mode 100644 modules/integration/tests-common/integration-common/src/main/java/org/wso2/iot/integration/common/extensions/CarbonServerManagerExtension.java diff --git a/modules/integration/tests-common/integration-common/src/main/java/org/wso2/iot/integration/common/extensions/CarbonServerManagerExtension.java b/modules/integration/tests-common/integration-common/src/main/java/org/wso2/iot/integration/common/extensions/CarbonServerManagerExtension.java new file mode 100644 index 00000000..7fb761f1 --- /dev/null +++ b/modules/integration/tests-common/integration-common/src/main/java/org/wso2/iot/integration/common/extensions/CarbonServerManagerExtension.java @@ -0,0 +1,335 @@ + + +// +// Source code recreated from a .class file by IntelliJ IDEA +// (powered by Fernflower decompiler) +// + +package org.wso2.iot.integration.common.extensions; + +import org.apache.commons.lang3.ArrayUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.automation.engine.context.AutomationContext; +import org.wso2.carbon.automation.engine.context.beans.User; +import org.wso2.carbon.automation.engine.exceptions.AutomationFrameworkException; +import org.wso2.carbon.automation.engine.frameworkutils.CodeCoverageUtils; +import org.wso2.carbon.automation.engine.frameworkutils.FrameworkPathUtil; +import org.wso2.carbon.automation.engine.frameworkutils.ReportGenerator; +import org.wso2.carbon.automation.engine.frameworkutils.TestFrameworkUtils; +import org.wso2.carbon.automation.extensions.servers.utils.ArchiveExtractor; +import org.wso2.carbon.automation.extensions.servers.utils.ClientConnectionUtil; +import org.wso2.carbon.automation.extensions.servers.utils.FileManipulator; +import org.wso2.carbon.automation.extensions.servers.utils.ServerLogReader; + +import javax.xml.xpath.XPathExpressionException; +import java.io.File; +import java.io.IOException; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; + + +public class CarbonServerManagerExtension { + private static final Log log = LogFactory.getLog(CarbonServerManagerExtension.class); + private Process process; + private String carbonHome; + private AutomationContext automationContext; + private ServerLogReader inputStreamHandler; + private ServerLogReader errorStreamHandler; + private boolean isCoverageEnable = false; + private String coverageDumpFilePath; + private int portOffset = 0; + private static final String SERVER_SHUTDOWN_MESSAGE = "Halting JVM"; + private static final String SERVER_STARTUP_MESSAGE = "Mgt Console URL"; + private static final long DEFAULT_START_STOP_WAIT_MS = 400000L; + private static final String CMD_ARG = "cmdArg"; + private static int defaultHttpPort = Integer.parseInt("9763"); + private static int defaultHttpsPort = Integer.parseInt("9443"); + + public CarbonServerManagerExtension(AutomationContext context) { + this.automationContext = context; + } + + public synchronized void startServerUsingCarbonHome(String carbonHome, Map commandMap) throws AutomationFrameworkException { + if(this.process == null) { + this.portOffset = this.checkPortAvailability(commandMap); + Process tempProcess = null; + + try { + if(!commandMap.isEmpty() && this.getPortOffsetFromCommandMap(commandMap) == 0) { + System.setProperty("carbon.home", carbonHome); + } + + File commandDir = new File(carbonHome); + log.info("Starting carbon server............. "); + String scriptName = TestFrameworkUtils.getStartupScriptFileName(carbonHome); + String[] parameters = this.expandServerStartupCommandList(commandMap); + String[] cmdArray; + if(System.getProperty("os.name").toLowerCase().contains("windows")) { + commandDir = new File(carbonHome + File.separator + "bin"); + cmdArray = new String[]{"cmd.exe", "/c", scriptName + ".bat"}; + cmdArray = this.mergePropertiesToCommandArray(parameters, cmdArray); + tempProcess = Runtime.getRuntime().exec(cmdArray, (String[])null, commandDir); + } else { + cmdArray = new String[]{"sh", "bin/" + scriptName + ".sh"}; + cmdArray = this.mergePropertiesToCommandArray(parameters, cmdArray); + tempProcess = Runtime.getRuntime().exec(cmdArray, (String[])null, commandDir); + } + + this.errorStreamHandler = new ServerLogReader("errorStream", tempProcess.getErrorStream()); + this.inputStreamHandler = new ServerLogReader("inputStream", tempProcess.getInputStream()); + this.inputStreamHandler.start(); + this.errorStreamHandler.start(); + Runtime.getRuntime().addShutdownHook(new Thread() { + public void run() { + try { + CarbonServerManagerExtension.this.serverShutdown(CarbonServerManagerExtension.this.portOffset); + } catch (Exception var2) { + CarbonServerManagerExtension.log.error("Error while server shutdown ..", var2); + } + + } + }); + ClientConnectionUtil.waitForPort(defaultHttpPort + this.portOffset, 300000L, false, (String)this.automationContext.getInstance().getHosts().get("default")); + long time = System.currentTimeMillis() + 60000L; + + while(true) { + if(this.inputStreamHandler.getOutput().contains("Mgt Console URL") || System.currentTimeMillis() >= time) { + int httpsPort = defaultHttpsPort + this.portOffset; + String backendURL = this.automationContext.getContextUrls().getSecureServiceUrl().replaceAll("(:\\d+)", ":" + httpsPort); + User superUser = this.automationContext.getSuperTenant().getTenantAdmin(); + ClientConnectionUtil.waitForLogin(backendURL, superUser); + log.info("Server started successfully."); + break; + } + } + } catch (XPathExpressionException | IOException var13) { + throw new IllegalStateException("Unable to start server", var13); + } + + this.process = tempProcess; + } + } + + private int checkPortAvailability(Map commandMap) throws AutomationFrameworkException { + int portOffset = this.getPortOffsetFromCommandMap(commandMap); + if(ClientConnectionUtil.isPortOpen(defaultHttpPort + portOffset)) { + throw new AutomationFrameworkException("Unable to start carbon server on port " + (defaultHttpPort + portOffset) + " : Port already in use"); + } else if(ClientConnectionUtil.isPortOpen(defaultHttpsPort + portOffset)) { + throw new AutomationFrameworkException("Unable to start carbon server on port " + (defaultHttpsPort + portOffset) + " : Port already in use"); + } else { + return portOffset; + } + } + + private String[] mergePropertiesToCommandArray(String[] parameters, String[] cmdArray) { + if(parameters != null) { + cmdArray = this.mergerArrays(cmdArray, parameters); + } + + return cmdArray; + } + + 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; + } + } + } + + public synchronized void serverShutdown(int portOffset) throws AutomationFrameworkException { + if(this.process != null) { + log.info("Shutting down server.."); + if(ClientConnectionUtil.isPortOpen(Integer.parseInt("9443") + portOffset)) { + int httpsPort = defaultHttpsPort + portOffset; + String url = null; + + try { + url = this.automationContext.getContextUrls().getBackEndUrl(); + } catch (XPathExpressionException var10) { + throw new AutomationFrameworkException("Get context failed", var10); + } + + String backendURL = url.replaceAll("(:\\d+)", ":" + httpsPort); + + try { + ClientConnectionUtil.sendForcefulShutDownRequest(backendURL, this.automationContext.getSuperTenant().getContextUser().getUserName(), this.automationContext.getSuperTenant().getContextUser().getPassword()); + } catch (AutomationFrameworkException var8) { + throw new AutomationFrameworkException("Get context failed", var8); + } catch (XPathExpressionException var9) { + throw new AutomationFrameworkException("Get context failed", var9); + } + + long time = System.currentTimeMillis() + 300000L; + + while(!this.inputStreamHandler.getOutput().contains("Halting JVM") && System.currentTimeMillis() < time) { + ; + } + + log.info("Server stopped successfully..."); + } + + this.inputStreamHandler.stop(); + this.errorStreamHandler.stop(); + this.process.destroy(); + this.process = null; + if(this.isCoverageEnable) { + try { + log.info("Generating Jacoco code coverage..."); + this.generateCoverageReport(new File(this.carbonHome + File.separator + "repository" + File.separator + "components" + File.separator + "plugins" + File.separator)); + } catch (IOException var7) { + log.error("Failed to generate code coverage ", var7); + throw new AutomationFrameworkException("Failed to generate code coverage ", var7); + } + } + + if(portOffset == 0) { + System.clearProperty("carbon.home"); + } + } + + } + + private void generateCoverageReport(File classesDir) throws IOException, AutomationFrameworkException { + CodeCoverageUtils.executeMerge(FrameworkPathUtil.getJacocoCoverageHome(), FrameworkPathUtil.getCoverageMergeFilePath()); + ReportGenerator reportGenerator = new ReportGenerator(new File(FrameworkPathUtil.getCoverageMergeFilePath()), classesDir, new File(CodeCoverageUtils.getJacocoReportDirectory()), (File)null); + reportGenerator.create(); + log.info("Jacoco coverage dump file path : " + FrameworkPathUtil.getCoverageDumpFilePath()); + log.info("Jacoco class file path : " + classesDir); + log.info("Jacoco coverage HTML report path : " + CodeCoverageUtils.getJacocoReportDirectory() + File.separator + "index.html"); + } + + public synchronized void restartGracefully() throws AutomationFrameworkException { + try { + int httpsPort = defaultHttpsPort + this.portOffset; + String backendURL = this.automationContext.getContextUrls().getSecureServiceUrl().replaceAll("(:\\d+)", ":" + httpsPort); + User superUser = this.automationContext.getSuperTenant().getTenantAdmin(); + ClientConnectionUtil.sendGraceFullRestartRequest(backendURL, superUser.getUserName(), superUser.getPassword()); + } catch (XPathExpressionException var5) { + throw new AutomationFrameworkException("restart failed", var5); + } + + long time = System.currentTimeMillis() + 300000L; + + while(!this.inputStreamHandler.getOutput().contains("Halting JVM") && System.currentTimeMillis() < time) { + ; + } + + time = System.currentTimeMillis(); + + while(System.currentTimeMillis() < time + 5000L) { + ; + } + + try { + ClientConnectionUtil.waitForPort(Integer.parseInt((String)this.automationContext.getInstance().getPorts().get("https")), (String)this.automationContext.getInstance().getHosts().get("default")); + ClientConnectionUtil.waitForLogin(this.automationContext); + } catch (XPathExpressionException var4) { + throw new AutomationFrameworkException("Connection attempt to carbon server failed", var4); + } + } + + private String[] expandServerStartupCommandList(Map commandMap) { + if(commandMap != null && commandMap.size() != 0) { + String[] cmdParaArray = null; + String cmdArg = null; + if(commandMap.containsKey("cmdArg")) { + cmdArg = (String)commandMap.get("cmdArg"); + cmdParaArray = cmdArg.trim().split("\\s+"); + commandMap.remove("cmdArg"); + } + + String[] parameterArray = new String[commandMap.size()]; + int arrayIndex = 0; + Set> entries = commandMap.entrySet(); + + String parameter; + for(Iterator i$ = entries.iterator(); i$.hasNext(); parameterArray[arrayIndex++] = parameter) { + Map.Entry entry = (Map.Entry)i$.next(); + String key = (String)entry.getKey(); + String value = (String)entry.getValue(); + if(value != null && !value.isEmpty()) { + parameter = key + "=" + value; + } else { + parameter = key; + } + } + + if(cmdArg != null) { + commandMap.put("cmdArg", cmdArg); + } + + if(cmdParaArray != null && cmdParaArray.length != 0) { + return (String[]) ArrayUtils.addAll(parameterArray, cmdParaArray); + } else { + return parameterArray; + } + } else { + return null; + } + } + + private int getPortOffsetFromCommandMap(Map commandMap) { + return commandMap.containsKey("-DportOffset")?Integer.parseInt((String)commandMap.get("-DportOffset")):0; + } + + private String[] mergerArrays(String[] array1, String[] array2) { + return (String[])ArrayUtils.addAll(array1, array2); + } + + private void insertJacocoAgentToShellScript(String scriptName) throws IOException { + String jacocoAgentFile = CodeCoverageUtils.getJacocoAgentJarLocation(); + this.coverageDumpFilePath = FrameworkPathUtil.getCoverageDumpFilePath(); + CodeCoverageUtils.insertStringToFile(new File(this.carbonHome + File.separator + "bin" + File.separator + scriptName + ".sh"), new File(this.carbonHome + File.separator + "tmp" + File.separator + scriptName + ".sh"), "-Dwso2.server.standalone=true", "-javaagent:" + jacocoAgentFile + "=destfile=" + this.coverageDumpFilePath + "" + ",append=true,includes=" + CodeCoverageUtils.getInclusionJarsPattern(":") + " \\"); + } + + 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(":")); + } + + private void instrumentForCoverage() throws IOException, AutomationFrameworkException { + String scriptName = TestFrameworkUtils.getStartupScriptFileName(this.carbonHome); + if(System.getProperty("os.name").toLowerCase().contains("windows")) { + this.insertJacocoAgentToBatScript(scriptName); + if(log.isDebugEnabled()) { + log.debug("Included files " + CodeCoverageUtils.getInclusionJarsPattern(":")); + log.debug("Excluded files " + CodeCoverageUtils.getExclusionJarsPattern(":")); + } + } else { + this.insertJacocoAgentToShellScript(scriptName); + } + + } +} diff --git a/modules/integration/tests-common/integration-common/src/main/java/org/wso2/iot/integration/common/extensions/CustomTestServerManager.java b/modules/integration/tests-common/integration-common/src/main/java/org/wso2/iot/integration/common/extensions/CustomTestServerManager.java index 44e038a6..b296eb5c 100644 --- a/modules/integration/tests-common/integration-common/src/main/java/org/wso2/iot/integration/common/extensions/CustomTestServerManager.java +++ b/modules/integration/tests-common/integration-common/src/main/java/org/wso2/iot/integration/common/extensions/CustomTestServerManager.java @@ -23,8 +23,6 @@ import org.wso2.carbon.automation.engine.FrameworkConstants; import org.wso2.carbon.automation.engine.context.AutomationContext; import org.wso2.carbon.automation.engine.exceptions.AutomationFrameworkException; import org.wso2.carbon.automation.extensions.ExtensionConstants; -import org.wso2.carbon.automation.extensions.servers.carbonserver.CarbonServerManager; - import javax.xml.xpath.XPathExpressionException; import java.io.File; import java.io.IOException; @@ -32,7 +30,7 @@ import java.util.HashMap; import java.util.Map; public class CustomTestServerManager { - protected CarbonServerManager carbonServer; + protected CarbonServerManagerExtension carbonServer; protected String carbonZip; protected int portOffset; protected Map commandMap = new HashMap(); @@ -40,23 +38,23 @@ public class CustomTestServerManager { protected String carbonHome; public CustomTestServerManager(AutomationContext context) { - carbonServer = new CarbonServerManager(context); + carbonServer = new CarbonServerManagerExtension(context); } public CustomTestServerManager(AutomationContext context, String carbonZip) { - carbonServer = new CarbonServerManager(context); + carbonServer = new CarbonServerManagerExtension(context); this.carbonZip = carbonZip; } public CustomTestServerManager(AutomationContext context, int portOffset) { - carbonServer = new CarbonServerManager(context); + carbonServer = new CarbonServerManagerExtension(context); this.portOffset = portOffset; commandMap.put(ExtensionConstants.SERVER_STARTUP_PORT_OFFSET_COMMAND, String.valueOf(portOffset)); } public CustomTestServerManager(AutomationContext context, String carbonZip, Map commandMap) { - carbonServer = new CarbonServerManager(context); + carbonServer = new CarbonServerManagerExtension(context); this.carbonZip = carbonZip; if (commandMap.get(ExtensionConstants.SERVER_STARTUP_PORT_OFFSET_COMMAND) != null) { this.portOffset = Integer.parseInt(commandMap.get(ExtensionConstants.SERVER_STARTUP_PORT_OFFSET_COMMAND)); diff --git a/modules/integration/tests-iot-web-ui/pom.xml b/modules/integration/tests-iot-web-ui/pom.xml index 779940fb..95823ee9 100644 --- a/modules/integration/tests-iot-web-ui/pom.xml +++ b/modules/integration/tests-iot-web-ui/pom.xml @@ -264,6 +264,10 @@ org.wso2.carbon.automationutils org.wso2.carbon.integration.common.extensions + + org.wso2.iot + org.wso2.carbon.iot.integration.common + diff --git a/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/extension/CustomTestServerManager.java b/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/extension/CustomTestServerManager.java index fa9c34d8..2f7ddb80 100644 --- a/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/extension/CustomTestServerManager.java +++ b/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/extension/CustomTestServerManager.java @@ -23,15 +23,16 @@ import org.wso2.carbon.automation.engine.FrameworkConstants; import org.wso2.carbon.automation.engine.context.AutomationContext; import org.wso2.carbon.automation.engine.exceptions.AutomationFrameworkException; import org.wso2.carbon.automation.extensions.ExtensionConstants; -import org.wso2.carbon.automation.extensions.servers.carbonserver.CarbonServerManager; - import javax.xml.xpath.XPathExpressionException; import java.io.IOException; import java.util.HashMap; import java.util.Map; +import org.wso2.iot.integration.common.extensions.CarbonServerManagerExtension; + + public class CustomTestServerManager { - protected CarbonServerManager carbonServer; + protected CarbonServerManagerExtension carbonServer; protected String carbonZip; protected int portOffset; protected Map commandMap = new HashMap(); @@ -39,23 +40,23 @@ public class CustomTestServerManager { protected String carbonHome; public CustomTestServerManager(AutomationContext context) { - carbonServer = new CarbonServerManager(context); + carbonServer = new CarbonServerManagerExtension(context); } public CustomTestServerManager(AutomationContext context, String carbonZip) { - carbonServer = new CarbonServerManager(context); + carbonServer = new CarbonServerManagerExtension(context); this.carbonZip = carbonZip; } public CustomTestServerManager(AutomationContext context, int portOffset) { - carbonServer = new CarbonServerManager(context); + carbonServer = new CarbonServerManagerExtension(context); this.portOffset = portOffset; commandMap.put(ExtensionConstants.SERVER_STARTUP_PORT_OFFSET_COMMAND, String.valueOf(portOffset)); } public CustomTestServerManager(AutomationContext context, String carbonZip, Map commandMap) { - carbonServer = new CarbonServerManager(context); + carbonServer = new CarbonServerManagerExtension(context); this.carbonZip = carbonZip; if (commandMap.get(ExtensionConstants.SERVER_STARTUP_PORT_OFFSET_COMMAND) != null) { this.portOffset = Integer.parseInt(commandMap.get(ExtensionConstants.SERVER_STARTUP_PORT_OFFSET_COMMAND)); diff --git a/pom.xml b/pom.xml index 04b80c00..1dcd62a0 100644 --- a/pom.xml +++ b/pom.xml @@ -1512,7 +1512,7 @@ - 2.0.69 + 2.0.72-SNAPSHOT [2.0.0, 3.0.0) @@ -1520,7 +1520,7 @@ - 3.0.37 + 3.0.39-SNAPSHOT 6.1.80 From f94713b70a9292a496779b6cb36de630ac9cdfaf Mon Sep 17 00:00:00 2001 From: GDLMadushanka Date: Mon, 5 Jun 2017 16:46:23 +0530 Subject: [PATCH 3/6] pom modified to version --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 1dcd62a0..04b80c00 100644 --- a/pom.xml +++ b/pom.xml @@ -1512,7 +1512,7 @@ - 2.0.72-SNAPSHOT + 2.0.69 [2.0.0, 3.0.0) @@ -1520,7 +1520,7 @@ - 3.0.39-SNAPSHOT + 3.0.37 6.1.80 From 43d8dc38b102574d8a15bca6a28b02a0170a28ce Mon Sep 17 00:00:00 2001 From: GDLMadushanka Date: Tue, 6 Jun 2017 07:49:42 +0530 Subject: [PATCH 4/6] Clean up code --- .../CarbonServerManagerExtension.java | 23 ++++++++++++++----- .../extension/CustomTestServerManager.java | 2 -- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/modules/integration/tests-common/integration-common/src/main/java/org/wso2/iot/integration/common/extensions/CarbonServerManagerExtension.java b/modules/integration/tests-common/integration-common/src/main/java/org/wso2/iot/integration/common/extensions/CarbonServerManagerExtension.java index 7fb761f1..08acb0c1 100644 --- a/modules/integration/tests-common/integration-common/src/main/java/org/wso2/iot/integration/common/extensions/CarbonServerManagerExtension.java +++ b/modules/integration/tests-common/integration-common/src/main/java/org/wso2/iot/integration/common/extensions/CarbonServerManagerExtension.java @@ -1,9 +1,20 @@ - - -// -// Source code recreated from a .class file by IntelliJ IDEA -// (powered by Fernflower decompiler) -// +/* +* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. +* +* WSO2 Inc. licenses this file to you under the Apache License, +* Version 2.0 (the "License"); you may not use this file except +* in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ package org.wso2.iot.integration.common.extensions; diff --git a/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/extension/CustomTestServerManager.java b/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/extension/CustomTestServerManager.java index 2f7ddb80..9c26a4e8 100644 --- a/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/extension/CustomTestServerManager.java +++ b/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/extension/CustomTestServerManager.java @@ -29,8 +29,6 @@ import java.util.HashMap; import java.util.Map; import org.wso2.iot.integration.common.extensions.CarbonServerManagerExtension; - - public class CustomTestServerManager { protected CarbonServerManagerExtension carbonServer; protected String carbonZip; From d376a91745cc342d6bdeb4e0cd30d38131f5d963 Mon Sep 17 00:00:00 2001 From: GDLMadushanka Date: Tue, 6 Jun 2017 10:44:24 +0530 Subject: [PATCH 5/6] JavaDocs added --- .../CarbonServerManagerExtension.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/modules/integration/tests-common/integration-common/src/main/java/org/wso2/iot/integration/common/extensions/CarbonServerManagerExtension.java b/modules/integration/tests-common/integration-common/src/main/java/org/wso2/iot/integration/common/extensions/CarbonServerManagerExtension.java index 08acb0c1..cd2074df 100644 --- a/modules/integration/tests-common/integration-common/src/main/java/org/wso2/iot/integration/common/extensions/CarbonServerManagerExtension.java +++ b/modules/integration/tests-common/integration-common/src/main/java/org/wso2/iot/integration/common/extensions/CarbonServerManagerExtension.java @@ -142,6 +142,14 @@ public class CarbonServerManagerExtension { return cmdArray; } + /** + * 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; @@ -318,18 +326,35 @@ public class CarbonServerManagerExtension { return (String[])ArrayUtils.addAll(array1, array2); } + /** + * 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(); this.coverageDumpFilePath = FrameworkPathUtil.getCoverageDumpFilePath(); CodeCoverageUtils.insertStringToFile(new File(this.carbonHome + File.separator + "bin" + File.separator + scriptName + ".sh"), new File(this.carbonHome + File.separator + "tmp" + File.separator + scriptName + ".sh"), "-Dwso2.server.standalone=true", "-javaagent:" + jacocoAgentFile + "=destfile=" + this.coverageDumpFilePath + "" + ",append=true,includes=" + CodeCoverageUtils.getInclusionJarsPattern(":") + " \\"); } + /** + * This methods will insert jacoco agent settings into windows bat script + * + * @param scriptName - Name of the startup script + * @throws IOException - throws if shell script edit fails + */ 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(":")); } + /** + * This method will check the OS and edit server startup script to inject jacoco agent + * + * @throws IOException - If agent insertion fails. + */ private void instrumentForCoverage() throws IOException, AutomationFrameworkException { String scriptName = TestFrameworkUtils.getStartupScriptFileName(this.carbonHome); if(System.getProperty("os.name").toLowerCase().contains("windows")) { From c3ad20b18a9caa38c7caf30dfb389f45a4f1d1c5 Mon Sep 17 00:00:00 2001 From: Janak Amarasena Date: Wed, 7 Jun 2017 14:26:29 +0530 Subject: [PATCH 6/6] Add new supported grant type --- .../src/core/conf/identity/identity.xml | 33 +++---------------- 1 file changed, 4 insertions(+), 29 deletions(-) diff --git a/modules/distribution/src/core/conf/identity/identity.xml b/modules/distribution/src/core/conf/identity/identity.xml index ab4b7b80..1156d979 100644 --- a/modules/distribution/src/core/conf/identity/identity.xml +++ b/modules/distribution/src/core/conf/identity/identity.xml @@ -212,34 +212,9 @@ org.wso2.carbon.identity.oauth2.grant.jwt.JWTGrantValidator - urn:ietf:params:oauth:grant-type:jwt-bearer - org.wso2.carbon.device.mgt.oauth.extensions.handlers.grant.ExtendedJWTGrantHandler - org.wso2.carbon.identity.oauth2.grant.jwt.JWTGrantValidator - - - urn:ietf:params:oauth:grant-type:jwt-bearer - org.wso2.carbon.device.mgt.oauth.extensions.handlers.grant.ExtendedJWTGrantHandler - org.wso2.carbon.identity.oauth2.grant.jwt.JWTGrantValidator - - - urn:ietf:params:oauth:grant-type:jwt-bearer - org.wso2.carbon.device.mgt.oauth.extensions.handlers.grant.ExtendedJWTGrantHandler - org.wso2.carbon.identity.oauth2.grant.jwt.JWTGrantValidator - - - urn:ietf:params:oauth:grant-type:jwt-bearer - org.wso2.carbon.device.mgt.oauth.extensions.handlers.grant.ExtendedJWTGrantHandler - org.wso2.carbon.identity.oauth2.grant.jwt.JWTGrantValidator - - - urn:ietf:params:oauth:grant-type:jwt-bearer - org.wso2.carbon.device.mgt.oauth.extensions.handlers.grant.ExtendedJWTGrantHandler - org.wso2.carbon.identity.oauth2.grant.jwt.JWTGrantValidator - - - urn:ietf:params:oauth:grant-type:jwt-bearer - org.wso2.carbon.device.mgt.oauth.extensions.handlers.grant.ExtendedJWTGrantHandler - org.wso2.carbon.identity.oauth2.grant.jwt.JWTGrantValidator + access_token + org.wso2.carbon.device.mgt.oauth.extensions.handlers.grant.AccessTokenGrantHandler + org.wso2.carbon.device.mgt.oauth.extensions.validators.AccessTokenGrantValidator @@ -510,4 +485,4 @@ 300 - \ No newline at end of file +