Package org.springsource.loaded.test.infra

Examples of org.springsource.loaded.test.infra.Result


   * If we held on to the original method object, we should NOT be able to invoke it anymore (different return type should be
   * treated as different method!
   */
  @Test
  public void test_getDeclaredMethodCachedChangedReturnType() throws Exception {
    Result r = getDeclaredMethod("changeReturn", String.class);
    assertMethod("public java.lang.String " + TARGET_CLASS_NAME + ".changeReturn(java.lang.String)", r);
    Method m = (Method) r.returnValue;

    r = invoke(m, "hoho");
    Assert.assertEquals("hohoho!", r.returnValue);
View Full Code Here


   *
   * A method with two paramters - existed at first - then it was changed
   */
  @Test
  public void test_getDeclaredMethodTwoParamsChanged() throws Exception {
    Result r = getDeclaredMethod("changeThem", String.class, int.class);
    assertMethod("public java.lang.String " + TARGET_CLASS_NAME + ".changeThem(java.lang.String,int)", r);
    r = invoke((Method) r.returnValue, "ho", 2);
    Assert.assertEquals("ho2", r.returnValue);

    reloadType("002");
View Full Code Here

  /**
   * Invoking a private method by means of "invoke" call, from within the class containing the target method should be allowed.
   */
  @Test
  public void test_invokePrivateMethodAllowed() throws Exception {
    Result r = getDeclaredMethodAndInvoke("callPrivateMethod");
    Assert.assertEquals("privateMethod result", r.returnValue);

    reloadType("002");

    r = getDeclaredMethodAndInvoke("callPrivateMethod");
View Full Code Here

   */
  @Test
  public void test_invokePublicMethodInDefaultClassAllowed() throws Exception {
    ReloadableType defaultClass = reloadableClass(TARGET_PACKAGE + "." + "DefaultClass");

    Result r = getDeclaredMethodAndInvoke("callPublicMethodOnDefaultClass");
    Assert.assertEquals(82, r.returnValue);

    reloadType(defaultClass, "002");

    r = getDeclaredMethodAndInvoke("callPublicMethodOnDefaultClass");
View Full Code Here

  @Test
  public void test_invokePublicMethodInNonReloadableDefaultClassAllowed() throws Exception {
    //    Class<?> defaultClass =
    nonReloadableClass(TARGET_PACKAGE + "." + "DefaultClass");

    Result r = getDeclaredMethodAndInvoke("callPublicMethodOnDefaultClass");
    Assert.assertEquals(82, r.returnValue);
  }
View Full Code Here

    String methodToCall = scope + "Method";
    String expectMsg = "Class " + INVOKER_CLASS_NAME + " " + "can not access a member of class " + TARGET_CLASS_NAME + " "
        + "with modifiers \"" + (scope.equals("default") ? "" : scope) + "\"";

    //First... we do set the Access flag, it should work!
    Result r = runOnInstance(callerClazz, callerInstance, "callMethodWithAccess", methodToCall, true);
    Assert.assertEquals(r.returnValue, methodToCall + " result");

    //Then... we do not set the Access flag, it should fail!
    try {
      r = runOnInstance(callerClazz, callerInstance, "callMethodWithAccess", methodToCall, false);
View Full Code Here

    //Next check if we can call the super class method on the sub instance
    Object subInstance = subTarget.getClazz().newInstance();

    Method m = (Method) getDeclaredMethod("protectedMethod").returnValue;
    m.setAccessible(true); // because call is from different package!
    Result r = invokeOn(subInstance, m);
    Assert.assertEquals("protectedMethod result", r.returnValue);

    //Reload the subclass, method should now be defined on the subclass
    reloadType(subTarget, "002");
View Full Code Here

  @Test
  public void test_cacheReloadedMethod() throws Exception {
    reloadType("002");

    Method m = (Method) getDeclaredMethod("methodChanged").returnValue;
    Result r = invoke(m);
    assertEquals(2, r.returnValue);

    reloadType("003");
    r = invoke(m);
    assertEquals(3, r.returnValue);
View Full Code Here

   * gotten from the superclass).
   */
  @Test
  public void test_callInheritedOverridenMethod() throws Exception {

    Result r = getDeclaredMethod("overrideMethod");
    assertMethod("public java.lang.String " + TARGET_CLASS_NAME + ".overrideMethod()", r);
    Method m = (Method) r.returnValue;

    // Setup subClass and an instance of the subclass
    String subClassName = TARGET_PACKAGE + ".SubClassTarget";
View Full Code Here

   */
  @Test
  public void test_callInheritedOverridenMethod2() throws Exception {
    reloadType(target, "002");

    Result r = getDeclaredMethod("overrideMethod");
    assertMethod("public java.lang.String " + TARGET_CLASS_NAME + ".overrideMethod()", r);
    Method m = (Method) r.returnValue;

    // Double check if we are using the right version...
    r = invoke(m);
View Full Code Here

TOP

Related Classes of org.springsource.loaded.test.infra.Result

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.