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.

WriteExecutorTest.java 3.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. package com.uqac.rthoni.java_rmi.server.executors;
  2. import com.uqac.rthoni.java_rmi.server.ServerApplication;
  3. import org.junit.Assert;
  4. import org.junit.Test;
  5. /**
  6. * Created by robin on 9/16/16.
  7. */
  8. public class WriteExecutorTest extends AbstractTest {
  9. @Test
  10. public void test1() throws Exception
  11. {
  12. ServerApplication app = getServer();
  13. String res = runCommands(app, "creation#com.uqac.rthoni.java_rmi.server.executors.TestDbo#test",
  14. "ecriture#test#publicInt#24",
  15. "lecture#test#publicInt");
  16. Assert.assertEquals(res, "24");
  17. Object obj = app.getObject("test");
  18. Assert.assertNotNull(obj);
  19. Assert.assertEquals("privateString=default_value, privateInt=24, publicInt=24, aPrivateField=0, publicFloat=0.420000, publicDouble=0.125000, publicBool=true", obj.toString());
  20. }
  21. @Test
  22. public void test2() throws Exception
  23. {
  24. ServerApplication app = getServer();
  25. String res = runCommands(app, "creation#com.uqac.rthoni.java_rmi.server.executors.TestDbo#test",
  26. "ecriture#test#privateInt#42",
  27. "lecture#test#privateInt");
  28. Assert.assertEquals(res, "42");
  29. Object obj = app.getObject("test");
  30. Assert.assertNotNull(obj);
  31. Assert.assertEquals("privateString=default_value, privateInt=42, publicInt=42, aPrivateField=0, publicFloat=0.420000, publicDouble=0.125000, publicBool=true", obj.toString());
  32. }
  33. @Test
  34. public void test3() throws Exception
  35. {
  36. ServerApplication app = getServer();
  37. String res = runCommands(app, "creation#com.uqac.rthoni.java_rmi.server.executors.TestDbo#test",
  38. "ecriture#test#privateString#a_value",
  39. "lecture#test#privateString");
  40. Assert.assertEquals(res, "a_value");
  41. Object obj = app.getObject("test");
  42. Assert.assertNotNull(obj);
  43. Assert.assertEquals("privateString=a_value, privateInt=24, publicInt=42, aPrivateField=0, publicFloat=0.420000, publicDouble=0.125000, publicBool=true", obj.toString());
  44. }
  45. @Test
  46. public void test4() throws Exception
  47. {
  48. ServerApplication app = getServer();
  49. String res = runCommands(app, "creation#com.uqac.rthoni.java_rmi.server.executors.TestDbo#test",
  50. "ecriture#test#publicFloat#4242.5",
  51. "lecture#test#publicFloat");
  52. Assert.assertEquals(res, "4242.5");
  53. Object obj = app.getObject("test");
  54. Assert.assertNotNull(obj);
  55. Assert.assertEquals("privateString=default_value, privateInt=24, publicInt=42, aPrivateField=0, publicFloat=4242.500000, publicDouble=0.125000, publicBool=true", obj.toString());
  56. }
  57. @Test
  58. public void test5() throws Exception
  59. {
  60. ServerApplication app = getServer();
  61. String res = runCommands(app, "creation#com.uqac.rthoni.java_rmi.server.executors.TestDbo#test",
  62. "ecriture#test#publicBool#false",
  63. "lecture#test#publicBool");
  64. Assert.assertEquals(res, "false");
  65. Object obj = app.getObject("test");
  66. Assert.assertNotNull(obj);
  67. Assert.assertEquals("privateString=default_value, privateInt=24, publicInt=42, aPrivateField=0, publicFloat=0.420000, publicDouble=0.125000, publicBool=false", obj.toString());
  68. }
  69. }