You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

AbstractTest.java 1.0KB

123456789101112131415161718192021222324252627282930313233
  1. package com.uqac.rthoni.java_rmi.server.executors;
  2. import com.uqac.rthoni.java_rmi.common.Command;
  3. import com.uqac.rthoni.java_rmi.server.ServerApplication;
  4. /**
  5. * Created by robin on 9/16/16.
  6. */
  7. public abstract class AbstractTest {
  8. public String runCommand(ServerApplication app, String str) throws Exception {
  9. Command command = Command.fromString(str);
  10. AbstractCommandExecutor executor = app.getExecutor(command);
  11. return executor.run(command, app);
  12. }
  13. public String runCommands(ServerApplication app, String ...str) throws Exception {
  14. StringBuilder stringBuilder = new StringBuilder();
  15. for (String s : str) {
  16. String res = runCommand(app, s);
  17. if (res != null) {
  18. stringBuilder.append(res);
  19. }
  20. }
  21. return stringBuilder.toString();
  22. }
  23. public ServerApplication getServer() throws Exception {
  24. ServerApplication app = new ServerApplication();
  25. app.loadExecutors();
  26. return app;
  27. }
  28. }