Code formatting and removed unnecessary methods.

application-manager-new
Menaka Jayawardena 7 years ago
parent caba24a1e1
commit 5597125dc7

@ -23,7 +23,6 @@ import org.wso2.carbon.automation.engine.annotations.ExecutionEnvironment;
import org.wso2.carbon.automation.engine.context.AutomationContext;
import org.wso2.carbon.automation.engine.context.ContextXpathConstants;
import org.wso2.carbon.automation.engine.context.TestUserMode;
import org.wso2.carbon.automation.engine.exceptions.AutomationFrameworkException;
import org.wso2.carbon.automation.engine.extensions.ExecutionListenerExtension;
import org.wso2.carbon.automation.extensions.ExtensionConstants;
import org.wso2.carbon.automation.extensions.servers.carbonserver.CarbonServerExtension;
@ -40,13 +39,13 @@ public class AnalyticsServerExtension extends ExecutionListenerExtension {
private static final Log log = LogFactory.getLog(CarbonServerExtension.class);
private String executionEnvironment;
private AutomationContext automationContext;
private final String ANALYTICS_PORT_OFFSET = "2";
private final String ANALYTICS_PORT_OFFSET = "2";
@Override
public void initiate() throws AutomationFrameworkException {
public void initiate() {
try {
automationContext = new AutomationContext("IOT", TestUserMode.SUPER_TENANT_USER);
if(getParameters().get(ExtensionConstants.SERVER_STARTUP_PORT_OFFSET_COMMAND) == null) {
if (getParameters().get(ExtensionConstants.SERVER_STARTUP_PORT_OFFSET_COMMAND) == null) {
getParameters().put(ExtensionConstants.SERVER_STARTUP_PORT_OFFSET_COMMAND, ANALYTICS_PORT_OFFSET);
}
serverManager = new CustomTestServerManager(getAutomationContext(), null, getParameters());
@ -54,34 +53,29 @@ public class AnalyticsServerExtension extends ExecutionListenerExtension {
automationContext.getConfigurationValue(ContextXpathConstants.EXECUTION_ENVIRONMENT);
} catch (XPathExpressionException e) {
handleException("Error while initiating test environment", e);
throw new RuntimeException("Error while initiating test environment", e);
}
}
@Override
public void onExecutionStart() throws AutomationFrameworkException {
public void onExecutionStart() {
try {
if (executionEnvironment.equalsIgnoreCase(ExecutionEnvironment.STANDALONE.name())) {
String carbonHome = serverManager.startServer("analytics");
}
} catch (Exception e) {
handleException("Fail to start carbon server ", e);
throw new RuntimeException("Fail to start carbon server ", e);
}
}
@Override
public void onExecutionFinish() throws AutomationFrameworkException {
public void onExecutionFinish() {
try {
if (executionEnvironment.equalsIgnoreCase(ExecutionEnvironment.STANDALONE.name())) {
serverManager.stopServer();
}
} catch (Exception e) {
handleException("Fail to stop carbon server ", e);
throw new RuntimeException("Fail to stop carbon server ", e);
}
}
private static void handleException(String msg, Exception e) {
log.error(msg, e);
throw new RuntimeException(msg, e);
}
}

@ -23,7 +23,6 @@ import org.wso2.carbon.automation.engine.annotations.ExecutionEnvironment;
import org.wso2.carbon.automation.engine.context.AutomationContext;
import org.wso2.carbon.automation.engine.context.ContextXpathConstants;
import org.wso2.carbon.automation.engine.context.TestUserMode;
import org.wso2.carbon.automation.engine.exceptions.AutomationFrameworkException;
import org.wso2.carbon.automation.engine.extensions.ExecutionListenerExtension;
import org.wso2.carbon.automation.extensions.ExtensionConstants;
import org.wso2.carbon.automation.extensions.servers.carbonserver.CarbonServerExtension;
@ -40,13 +39,13 @@ public class BrokerServerExtension extends ExecutionListenerExtension {
private static final Log log = LogFactory.getLog(CarbonServerExtension.class);
private String executionEnvironment;
private AutomationContext automationContext;
private final String BROKER_PORT_OFFSET = "3";
private final String BROKER_PORT_OFFSET = "3";
@Override
public void initiate() throws AutomationFrameworkException {
public void initiate() {
try {
automationContext = new AutomationContext("IOT", TestUserMode.SUPER_TENANT_USER);
if(getParameters().get(ExtensionConstants.SERVER_STARTUP_PORT_OFFSET_COMMAND) == null) {
if (getParameters().get(ExtensionConstants.SERVER_STARTUP_PORT_OFFSET_COMMAND) == null) {
getParameters().put(ExtensionConstants.SERVER_STARTUP_PORT_OFFSET_COMMAND, BROKER_PORT_OFFSET);
}
serverManager = new CustomTestServerManager(getAutomationContext(), null, getParameters());
@ -54,12 +53,12 @@ public class BrokerServerExtension extends ExecutionListenerExtension {
automationContext.getConfigurationValue(ContextXpathConstants.EXECUTION_ENVIRONMENT);
} catch (XPathExpressionException e) {
handleException("Error while initiating test environment", e);
throw new RuntimeException("Error while initiating test environment", e);
}
}
@Override
public void onExecutionStart() throws AutomationFrameworkException {
public void onExecutionStart() {
try {
if (executionEnvironment.equalsIgnoreCase(ExecutionEnvironment.STANDALONE.name())) {
String carbonHome = serverManager.startServer("broker");
@ -67,23 +66,18 @@ public class BrokerServerExtension extends ExecutionListenerExtension {
System.setProperty(ExtensionConstants.CARBON_HOME, carbonHome);
}
} catch (Exception e) {
handleException("Fail to start carbon server ", e);
throw new RuntimeException("Fail to start carbon server ", e);
}
}
@Override
public void onExecutionFinish() throws AutomationFrameworkException {
public void onExecutionFinish() {
try {
if (executionEnvironment.equalsIgnoreCase(ExecutionEnvironment.STANDALONE.name())) {
serverManager.stopServer();
}
} catch (Exception e) {
handleException("Fail to stop carbon server ", e);
throw new RuntimeException("Fail to stop carbon server ", e);
}
}
private static void handleException(String msg, Exception e) {
log.error(msg, e);
throw new RuntimeException(msg, e);
}
}

@ -23,7 +23,6 @@ import org.wso2.carbon.automation.engine.annotations.ExecutionEnvironment;
import org.wso2.carbon.automation.engine.context.AutomationContext;
import org.wso2.carbon.automation.engine.context.ContextXpathConstants;
import org.wso2.carbon.automation.engine.context.TestUserMode;
import org.wso2.carbon.automation.engine.exceptions.AutomationFrameworkException;
import org.wso2.carbon.automation.engine.extensions.ExecutionListenerExtension;
import org.wso2.carbon.automation.extensions.ExtensionConstants;
import org.wso2.carbon.automation.extensions.servers.carbonserver.CarbonServerExtension;
@ -40,13 +39,13 @@ public class IOTServerExtension extends ExecutionListenerExtension {
private static final Log log = LogFactory.getLog(CarbonServerExtension.class);
private String executionEnvironment;
private AutomationContext automationContext;
private final String IOT_CORE_PORT_OFFSET = "0";
private final String IOT_CORE_PORT_OFFSET = "0";
@Override
public void initiate() throws AutomationFrameworkException {
public void initiate() {
try {
automationContext = new AutomationContext("IOT", TestUserMode.SUPER_TENANT_USER);
if(getParameters().get(ExtensionConstants.SERVER_STARTUP_PORT_OFFSET_COMMAND) == null) {
if (getParameters().get(ExtensionConstants.SERVER_STARTUP_PORT_OFFSET_COMMAND) == null) {
getParameters().put(ExtensionConstants.SERVER_STARTUP_PORT_OFFSET_COMMAND, IOT_CORE_PORT_OFFSET);
}
serverManager = new CustomTestServerManager(getAutomationContext(), null, getParameters());
@ -54,12 +53,12 @@ public class IOTServerExtension extends ExecutionListenerExtension {
automationContext.getConfigurationValue(ContextXpathConstants.EXECUTION_ENVIRONMENT);
} catch (XPathExpressionException e) {
handleException("Error while initiating test environment", e);
throw new RuntimeException("Error while initiating test environment", e);
}
}
@Override
public void onExecutionStart() throws AutomationFrameworkException {
public void onExecutionStart() {
try {
if (executionEnvironment.equalsIgnoreCase(ExecutionEnvironment.STANDALONE.name())) {
String carbonHome = serverManager.startServer("core");
@ -70,23 +69,18 @@ public class IOTServerExtension extends ExecutionListenerExtension {
Thread.sleep(30000);
}
} catch (Exception e) {
handleException("Fail to start carbon server ", e);
throw new RuntimeException("Fail to start carbon server ", e);
}
}
@Override
public void onExecutionFinish() throws AutomationFrameworkException {
public void onExecutionFinish() {
try {
if (executionEnvironment.equalsIgnoreCase(ExecutionEnvironment.STANDALONE.name())) {
serverManager.stopServer();
}
} catch (Exception e) {
handleException("Fail to stop carbon server ", e);
throw new RuntimeException("Fail to stop carbon server ", e);
}
}
private static void handleException(String msg, Exception e) {
log.error(msg, e);
throw new RuntimeException(msg, e);
}
}

Loading…
Cancel
Save