no message
This commit is contained in:
@@ -3,67 +3,16 @@ import Common.Constants;
|
||||
import Common.Utils.Utils;
|
||||
import Repository.EmailMessage;
|
||||
import Repository.Server.ServerCode;
|
||||
import Repository.Server.ServerExchangeUnit_2021;
|
||||
import TestingSystem.Common.TestingPackage.TestingPackage;
|
||||
import TestingSystem.Common.TestingPackageToKill.TestingPackageToKill;
|
||||
import Repository.RepositoryClient;
|
||||
import Visual_DVM_2021.Passes.PassException;
|
||||
import Visual_DVM_2021.Passes.Server.TestingSystemPass;
|
||||
import javafx.util.Pair;
|
||||
|
||||
import java.io.FileWriter;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.Vector;
|
||||
public abstract class TestingPlanner<P extends TestingPackage> {
|
||||
public abstract class TestingPlanner<P extends TestingPackage> extends RepositoryClient {
|
||||
protected P testingPackage;
|
||||
protected int getSleepMillis() {
|
||||
return 2000;
|
||||
}
|
||||
//---
|
||||
protected Object ServerCommand(ServerCode code_in, String arg, Serializable object_in) throws Exception {
|
||||
System.out.println("Команда серверу " + code_in.toString() + "arg=" + arg + " object=" + object_in);
|
||||
TestingSystemPass<Object> pass = new TestingSystemPass<Object>() {
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "";
|
||||
}
|
||||
@Override
|
||||
protected void ServerAction() throws Exception {
|
||||
Command(new ServerExchangeUnit_2021(code_in, arg, object_in));
|
||||
target = response.object;
|
||||
}
|
||||
@Override
|
||||
protected boolean validate() {
|
||||
return Log.isEmpty();
|
||||
}
|
||||
};
|
||||
if (!pass.Do())
|
||||
ServerConnectionError(code_in, pass.Log.toString());
|
||||
return pass.target;
|
||||
}
|
||||
protected Object ServerCommand(ServerCode code_in, Serializable object_in) throws Exception {
|
||||
return ServerCommand(code_in, "", object_in);
|
||||
}
|
||||
protected Object ServerCommand(ServerCode code_in) throws Exception {
|
||||
return ServerCommand(code_in, "", null);
|
||||
}
|
||||
//---
|
||||
protected boolean isPrintOn() {
|
||||
return true;
|
||||
}
|
||||
protected void Print(String message) {
|
||||
try {
|
||||
if (isPrintOn()) {
|
||||
FileWriter testLog = new FileWriter(getClass().getSimpleName() + "_Log.txt", true);
|
||||
String dmessage = Utils.Brackets(new Date()) + " " + message;
|
||||
System.out.println(dmessage);
|
||||
testLog.write(dmessage + "\n");
|
||||
testLog.close();
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
//---
|
||||
void UpdatePackageState(TasksPackageState state_in) throws Exception {
|
||||
testingPackage.state = state_in;
|
||||
@@ -111,9 +60,6 @@ public abstract class TestingPlanner<P extends TestingPackage> {
|
||||
}
|
||||
protected void MachineConnectionError() {
|
||||
}
|
||||
protected void ServerConnectionError(ServerCode code_in, String logText) throws Exception {
|
||||
throw new PassException("Ошибка взаимодействия с сервером " + code_in);
|
||||
}
|
||||
// ---
|
||||
protected void PerformPackage(TestingPackage package_in) throws Exception {
|
||||
testingPackage = (P) package_in;
|
||||
@@ -187,17 +133,11 @@ public abstract class TestingPlanner<P extends TestingPackage> {
|
||||
System.gc();
|
||||
//--
|
||||
}
|
||||
public void Perform() {
|
||||
try {
|
||||
testingPackage = null;
|
||||
Vector<P> activePackages = (Vector<P>) ServerCommand(getActivePackagesCode());
|
||||
// System.out.println(this.getClass().getSimpleName()+": found "+activePackages.size()+" active packages"); //Тесты:
|
||||
for (P activePackage : activePackages)
|
||||
PerformPackage(activePackage);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
} finally {
|
||||
Utils.sleep(getSleepMillis());
|
||||
}
|
||||
@Override
|
||||
public void perform() throws Exception {
|
||||
testingPackage = null;
|
||||
Vector<P> activePackages = (Vector<P>) ServerCommand(getActivePackagesCode());
|
||||
for (P activePackage : activePackages)
|
||||
PerformPackage(activePackage);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user