Search in sources :

Example 1 with ClearThException

use of com.exactprosystems.clearth.utils.ClearThException in project clearth by exactpro.

the class UsersManager method modifyUsers.

public void modifyUsers(List<XmlUser> originalUsers, List<XmlUser> newUsers) throws JAXBException, IOException, ClearThException {
    synchronized (usersListMonitor) {
        loadUsersList();
        for (int i = 0; i < newUsers.size(); i++) doModifyUser(originalUsers.get(i), newUsers.get(i));
        try {
            saveUsersList();
        } catch (Exception e) {
            String msg = "Error while saving users list after modifying it";
            logger.error(msg, e);
            throw new IOException(msg, e);
        }
        loadUsersList();
    }
}
Also used : IOException(java.io.IOException) UnmarshalException(javax.xml.bind.UnmarshalException) IOException(java.io.IOException) JAXBException(javax.xml.bind.JAXBException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) ClearThException(com.exactprosystems.clearth.utils.ClearThException) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Example 2 with ClearThException

use of com.exactprosystems.clearth.utils.ClearThException in project clearth by exactpro.

the class MvelExpressionValidator method validateExpression.

public void validateExpression(Serializable expression) throws ClearThException {
    ASTNode node = null;
    if (expression instanceof CompiledExpression) {
        CompiledExpression castedExpression = (CompiledExpression) expression;
        node = castedExpression.getFirstNode();
    } else if (expression instanceof ExecutableAccessor) {
        ExecutableAccessor castedExpression = (ExecutableAccessor) expression;
        node = castedExpression.getNode();
    }
    if (node != null && node.nextASTNode != null) {
        int operator = node.nextASTNode.getOperator();
        if (operator == Operator.TERNARY) {
            return;
        }
        throw new ClearThException("Invalid expression: '" + String.valueOf(node.getExpr()) + "'. Possibly it was" + " received from another reference.");
    }
}
Also used : ExecutableAccessor(org.mvel2.compiler.ExecutableAccessor) ASTNode(org.mvel2.ast.ASTNode) ClearThException(com.exactprosystems.clearth.utils.ClearThException) CompiledExpression(org.mvel2.compiler.CompiledExpression)

Example 3 with ClearThException

use of com.exactprosystems.clearth.utils.ClearThException in project clearth by exactpro.

the class ConfigMakerTool method makeConfig.

public File makeConfig(File matrixFile, File destDir, String resultConfigName) throws IOException, ClearThException {
    if (matrixFile == null || !matrixFile.exists())
        throw new ClearThException("Matrix file does not exist!");
    if (!checkMatrixFileExtension(matrixFile.getName()))
        throw new ClearThException("Unsupported matrix file format");
    String[] configHeader;
    List<Scheduler> schedulers = ClearThCore.getInstance().getSchedulersManager().getCommonSchedulers();
    StepFactory stepFactory;
    if (schedulers != null && !schedulers.isEmpty()) {
        Scheduler sch = schedulers.get(0);
        configHeader = sch.getSchedulerData().getConfigHeader();
        stepFactory = sch.getStepFactory();
    } else {
        configHeader = DefaultSchedulerData.CONFIG_HEADER;
        stepFactory = null;
    }
    List<String> stepsNames = null;
    stepsNames = readMatrixFile(matrixFile);
    if (stepsNames == null || stepsNames.isEmpty())
        throw new ClearThException("No steps references found in uploaded file " + resultConfigName + ". Please make sure that you upload a script file with right extension");
    List<Step> steps = new ArrayList<Step>();
    for (String stepName : stepsNames) {
        steps.add(createStep(stepName, stepFactory));
    }
    File configFile = File.createTempFile(resultConfigName + "_config_", ".cfg", destDir);
    SchedulerData.saveSteps(configFile, configHeader, steps);
    return configFile;
}
Also used : ArrayList(java.util.ArrayList) ClearThException(com.exactprosystems.clearth.utils.ClearThException) File(java.io.File)

Example 4 with ClearThException

use of com.exactprosystems.clearth.utils.ClearThException in project clearth by exactpro.

the class TestingExecutor method loadMatrices.

public void loadMatrices(Scheduler scheduler, File matricesDir) throws ClearThException {
    List<File> matrixFiles;
    try {
        matrixFiles = getMatricesFiles(matricesDir.toPath());
    } catch (IOException e) {
        throw new ClearThException("Error on matrix files getting", e);
    }
    matrixFiles.forEach(scheduler::addMatrix);
}
Also used : IOException(java.io.IOException) ClearThException(com.exactprosystems.clearth.utils.ClearThException) File(java.io.File)

Example 5 with ClearThException

use of com.exactprosystems.clearth.utils.ClearThException in project clearth by exactpro.

the class SchedulerTest method executeTest.

@Test
public void executeTest() throws ClearThException, AutomationException {
    Scheduler scheduler = clearThManager.getScheduler(schedulerName, userName);
    List<String> warnings = loadStepsForExecuteTest(scheduler);
    if (!warnings.isEmpty())
        throw new AutomationException("Steps loading errors:" + warnings);
    loadMatricesForExecuteTest(scheduler);
    scheduler.start(userName);
    waitForSchedulerToStop(scheduler, 100, 10000);
    List<XmlSchedulerLaunchInfo> launchesInfo = scheduler.getSchedulerData().getLaunches().getLaunchesInfo();
    if (launchesInfo == null || launchesInfo.isEmpty())
        throw new ClearThException("Launches data is not found");
    XmlSchedulerLaunchInfo currentLaunch = launchesInfo.get(0);
    allSuccessVerify(currentLaunch, scheduler.getExecutedMatricesPath());
    verifyStepsStatuses(scheduler.getSteps());
    checkReports(currentLaunch.getReportsPath());
}
Also used : XmlSchedulerLaunchInfo(com.exactprosystems.clearth.xmldata.XmlSchedulerLaunchInfo) AutomationException(com.exactprosystems.clearth.automation.exceptions.AutomationException) ClearThException(com.exactprosystems.clearth.utils.ClearThException) Test(org.junit.Test)

Aggregations

ClearThException (com.exactprosystems.clearth.utils.ClearThException)16 File (java.io.File)10 IOException (java.io.IOException)8 ArrayList (java.util.ArrayList)3 UploadedFile (org.primefaces.model.UploadedFile)3 XmlSchedulerLaunchInfo (com.exactprosystems.clearth.xmldata.XmlSchedulerLaunchInfo)2 Test (org.junit.Test)2 Matchers.anyString (org.mockito.Matchers.anyString)2 com.exactprosystems.clearth.automation (com.exactprosystems.clearth.automation)1 Scheduler (com.exactprosystems.clearth.automation.Scheduler)1 AutomationException (com.exactprosystems.clearth.automation.exceptions.AutomationException)1 MatrixProvider (com.exactprosystems.clearth.automation.matrix.linked.MatrixProvider)1 DefaultResult (com.exactprosystems.clearth.automation.report.results.DefaultResult)1 JsonAssert (com.exactprosystems.clearth.helpers.JsonAssert)1 ConfigMakerTool (com.exactprosystems.clearth.tools.ConfigMakerTool)1 Stopwatch (com.exactprosystems.clearth.utils.Stopwatch)1 FileOutputStream (java.io.FileOutputStream)1 InputStream (java.io.InputStream)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 SocketTimeoutException (java.net.SocketTimeoutException)1