|
|
@ -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.AutomationContext;
|
|
|
|
import org.wso2.carbon.automation.engine.context.ContextXpathConstants;
|
|
|
|
import org.wso2.carbon.automation.engine.context.ContextXpathConstants;
|
|
|
|
import org.wso2.carbon.automation.engine.context.TestUserMode;
|
|
|
|
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.engine.extensions.ExecutionListenerExtension;
|
|
|
|
import org.wso2.carbon.automation.extensions.ExtensionConstants;
|
|
|
|
import org.wso2.carbon.automation.extensions.ExtensionConstants;
|
|
|
|
import org.wso2.carbon.automation.extensions.servers.carbonserver.CarbonServerExtension;
|
|
|
|
import org.wso2.carbon.automation.extensions.servers.carbonserver.CarbonServerExtension;
|
|
|
@ -43,7 +42,7 @@ public class BrokerServerExtension extends ExecutionListenerExtension {
|
|
|
|
private final String BROKER_PORT_OFFSET = "3";
|
|
|
|
private final String BROKER_PORT_OFFSET = "3";
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void initiate() throws AutomationFrameworkException {
|
|
|
|
public void initiate() {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
automationContext = new AutomationContext("IOT", TestUserMode.SUPER_TENANT_USER);
|
|
|
|
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) {
|
|
|
@ -54,12 +53,12 @@ public class BrokerServerExtension extends ExecutionListenerExtension {
|
|
|
|
automationContext.getConfigurationValue(ContextXpathConstants.EXECUTION_ENVIRONMENT);
|
|
|
|
automationContext.getConfigurationValue(ContextXpathConstants.EXECUTION_ENVIRONMENT);
|
|
|
|
|
|
|
|
|
|
|
|
} catch (XPathExpressionException e) {
|
|
|
|
} catch (XPathExpressionException e) {
|
|
|
|
handleException("Error while initiating test environment", e);
|
|
|
|
throw new RuntimeException("Error while initiating test environment", e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onExecutionStart() throws AutomationFrameworkException {
|
|
|
|
public void onExecutionStart() {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
if (executionEnvironment.equalsIgnoreCase(ExecutionEnvironment.STANDALONE.name())) {
|
|
|
|
if (executionEnvironment.equalsIgnoreCase(ExecutionEnvironment.STANDALONE.name())) {
|
|
|
|
String carbonHome = serverManager.startServer("broker");
|
|
|
|
String carbonHome = serverManager.startServer("broker");
|
|
|
@ -67,23 +66,18 @@ public class BrokerServerExtension extends ExecutionListenerExtension {
|
|
|
|
System.setProperty(ExtensionConstants.CARBON_HOME, carbonHome);
|
|
|
|
System.setProperty(ExtensionConstants.CARBON_HOME, carbonHome);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
handleException("Fail to start carbon server ", e);
|
|
|
|
throw new RuntimeException("Fail to start carbon server ", e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onExecutionFinish() throws AutomationFrameworkException {
|
|
|
|
public void onExecutionFinish() {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
if (executionEnvironment.equalsIgnoreCase(ExecutionEnvironment.STANDALONE.name())) {
|
|
|
|
if (executionEnvironment.equalsIgnoreCase(ExecutionEnvironment.STANDALONE.name())) {
|
|
|
|
serverManager.stopServer();
|
|
|
|
serverManager.stopServer();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
|
|
} 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);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|