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.

NewInstanceExecutorTest.java 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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 NewInstanceExecutorTest extends AbstractTest {
  9. @Test
  10. public void test1() throws Exception
  11. {
  12. ServerApplication app = getServer();
  13. String res = runCommand(app, "creation#com.uqac.rthoni.java_rmi.server.executors.TestDbo#test");
  14. Assert.assertNull(res);
  15. Object obj = app.getObject("test");
  16. Assert.assertNotNull(obj);
  17. Assert.assertEquals(obj.toString(), "privateString=default_value, privateInt=24, publicInt=42, aPrivateField=0, publicFloat=0.420000, publicDouble=0.125000, publicBool=true");
  18. }
  19. @Test
  20. public void test2() throws Exception
  21. {
  22. ServerApplication app = getServer();
  23. String res = runCommand(app, "creation#java.lang.String#mystr");
  24. Assert.assertNull(res);
  25. Object obj = app.getObject("mystr");
  26. Assert.assertNotNull(obj);
  27. Assert.assertEquals(obj.toString(), "");
  28. }
  29. @Test(expected = ClassNotFoundException.class)
  30. public void test3() throws Exception
  31. {
  32. ServerApplication app = getServer();
  33. runCommand(app, "creation#not_existing_class#myobj");
  34. }
  35. }