use of com.centurylink.mdw.dataaccess.file.VersionControlGit in project mdw-designer by CenturyLinkCloud.
the class AutoTestAntTask method execute.
@Override
public void execute() throws BuildException {
try {
if (sslTrustStore != null)
System.setProperty("javax.net.ssl.trustStore", sslTrustStore.getAbsolutePath());
DesignerDataAccess.getAuthenticator().authenticate(user, password);
RestfulServer restfulServer = new RestfulServer(jdbcUrl == null ? "dummy" : jdbcUrl, user, serverUrl.toString());
if (workflowDir != null) {
// vcs-based assets
VersionControl versionControl = new VersionControlGit();
versionControl.connect(null, null, null, workflowDir);
restfulServer.setVersionControl(versionControl);
restfulServer.setRootDirectory(workflowDir);
restfulServer.setDatabaseUrl("jdbc://dummy");
designerDataAccess = new DesignerDataAccess(restfulServer, null, user, false);
designerDataAccess.setCurrentServer(restfulServer);
} else {
designerDataAccess = new DesignerDataAccess(restfulServer, null, user, oldNamespaces);
if (designerDataAccess.getUser(user) == null)
throw new BuildException("User '" + user + "' not found to run automated tests for this environment.");
if (!designerDataAccess.getUser(user).hasRole(UserGroupVO.COMMON_GROUP, UserRoleVO.PROCESS_EXECUTION) && !designerDataAccess.getUser(user).hasRole(UserGroupVO.SITE_ADMIN_GROUP, UserRoleVO.PROCESS_EXECUTION))
throw new BuildException("User '" + user + "' not authorized to run automated tests for this environment.");
}
VariableTypeCache.loadCache(designerDataAccess.getVariableTypes());
log("Setup completed for test suite: '" + suiteName + "'", Project.MSG_ERR);
try {
if (stubbing) {
Stubber stubber = new Stubber() {
public String processMessage(String masterRequestId, String request) {
try {
TestCaseRun run = masterRequestRunMap.get(masterRequestId);
if (run == null) {
JSONObject requestJson = null;
// mdw6
ActivityStubRequest activityStubRequest = null;
ActivityRuntimeContext activityRuntimeContext = null;
// mdw6
AdapterStubRequest adapterStubRequest = null;
if (request != null && request.trim().startsWith("{")) {
try {
requestJson = new JSONObject(request);
} catch (JSONException ex) {
// unparseable -- handle old way for
// adapter stubbing
}
if (requestJson != null) {
if (requestJson.has(ActivityStubRequest.JSON_NAME)) {
activityStubRequest = new ActivityStubRequest(requestJson);
activityRuntimeContext = activityStubRequest.getRuntimeContext();
} else if (requestJson.has("ActivityRuntimeContext")) {
activityRuntimeContext = new ActivityRuntimeContext(requestJson);
} else if (requestJson.has(AdapterStubRequest.JSON_NAME)) {
adapterStubRequest = new AdapterStubRequest(requestJson);
}
}
}
if (activityRuntimeContext != null) {
if (activityStubRequest != null) {
// mdw6+
ActivityStubResponse activityStubResponse = new ActivityStubResponse();
activityStubResponse.setPassthrough(true);
return activityStubResponse.getJson().toString(2);
} else {
return "(EXECUTE_ACTIVITY)";
}
} else {
if (adapterStubRequest != null) {
// mdw6+
AdapterStubResponse stubResponse = new AdapterStubResponse(AdapterActivity.MAKE_ACTUAL_CALL);
stubResponse.setPassthrough(true);
return stubResponse.getJson().toString(2);
} else {
return AdapterActivity.MAKE_ACTUAL_CALL;
}
}
}
return run.getStubResponse(masterRequestId, request, run.getRunNumber());
} catch (Exception ex) {
log(ex.getMessage(), ex, Project.MSG_ERR);
return null;
}
}
};
if (StubServer.isRunning())
StubServer.stop();
StubServer.start(restfulServer, stubPort, stubber, this.oldNamespaces);
}
runTests();
} finally {
// try not to leave the socket connection open
StubServer.stop();
}
} catch (BuildException ex) {
throw ex;
} catch (Exception ex) {
try {
updateResults(true);
} catch (BuildException bex) {
throw bex;
} catch (IOException ioex) {
log(ioex.getMessage(), ioex, Project.MSG_ERR);
}
log(ex.getMessage(), ex, Project.MSG_ERR);
throw new BuildException(ex);
}
}
Aggregations