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.1KB

1234567891011121314151617181920212223242526272829303132333435
  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. stringBuilder.append("\n");
  20. }
  21. }
  22. String res = stringBuilder.toString();
  23. return res.substring(0, res.length() - 1);
  24. }
  25. public ServerApplication getServer() throws Exception {
  26. ServerApplication app = new ServerApplication();
  27. app.loadExecutors();
  28. return app;
  29. }
  30. }